Git Product home page Git Product logo

oneapi-secondary-development's Introduction

手动部署

  1. 从源码编译:

    # 构建前端
    cd web
    npm install
    npm run build
    
    # 构建后端
    cd ..
    go mod download
    go build -ldflags "-s -w" -o azure-openai-one-api
    
    GOARCH=amd64 GOOS=linux go build -ldflags "-s -w" -o azure-openai-one-api
    
  2. 运行:

    chmod u+x azure-openai-one-api
    ./azure-openai-one-api --port 3000 --log-dir ./logs
  3. 访问 http://localhost:3000/ 并登录。初始账号用户名为 root,密码为 123456

  4. 使用

    import openai
    
    openai.api_key = 'sk-xxxxxxxxxxx' # 令牌处创建,获得
    openai.api_base = 'http://localhost:3000/v1'
    
    messages = [{"role": "user", "content": "你是谁"}]
    response = openai.ChatCompletion.create(
        #model='gpt-4',
        model='gpt-3.5-turbo',
        # model='gpt-4-32k',
        # model='gpt-3.5-turbo-16k',
        messages=messages
    )
    print(response['choices'][0]['message']['content'])
    

配置

系统本身开箱即用。

你可以通过设置环境变量或者命令行参数进行配置。

等到系统启动后,使用 root 用户登录系统并做进一步的配置。

Note:如果你不知道某个配置项的含义,可以临时删掉值以看到进一步的提示文字。

使用方法

渠道页面中添加你的 API Key,之后在令牌页面中新增访问令牌。

之后就可以使用你的令牌访问 One API 了,使用方式与 OpenAI API 一致。

你需要在各种用到 OpenAI API 的地方设置 API Base 为你的 One API 的部署地址,例如:https://openai.justsong.cn,API Key 则为你在 One API 中生成的令牌。

注意,具体的 API Base 的格式取决于你所使用的客户端。

例如对于 OpenAI 的官方库:

OPENAI_API_KEY="sk-xxxxxx"
OPENAI_API_BASE="https://<HOST>:<PORT>/v1" 
graph LR
    A(用户)
    A --->|使用 One API 分发的 key 进行请求| B(One API)
    B -->|中继请求| C(OpenAI)
    B -->|中继请求| D(Azure)
    B -->|中继请求| E(其他 OpenAI API 格式下游渠道)
    B -->|中继并修改请求体和返回体| F(非 OpenAI API 格式下游渠道)

可以通过在令牌后面添加渠道 ID 的方式指定使用哪一个渠道处理本次请求,例如:Authorization: Bearer ONE_API_KEY-CHANNEL_ID。 注意,需要是管理员用户创建的令牌才能指定渠道 ID。

不加的话将会使用负载均衡的方式使用多个渠道。

oneapi-secondary-development's People

Contributors

songquanpeng avatar sailaoda avatar mrhaoji avatar quzard avatar igophper avatar ckt1031 avatar glzjin avatar yangfan-sys avatar c121914yu avatar miniers avatar a497625414 avatar dependabot[bot] avatar anhao avatar ccbond avatar imsingee avatar diemus avatar eltociear avatar adevjoe avatar jungley8 avatar rockchinq avatar kidultx avatar leslieleung avatar dirname avatar aoaostar avatar redreamality avatar shiqimei avatar xyfacai avatar chunzhimoe avatar shao0222 avatar jsubnew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.