에너지가 부족하여 일부 모델 업데이트가 제때 업데이트되지 않을 수 있습니다. 문제가 발생하면 문제를 제출해 주세요. 관심 있는 분들도 PR을 제출하실 수 있습니다.
다양한 대형 모델 API 간의 차이점을 보호하고, 대형 모델을 사용하기 위해 openai api 표준 형식을 사용하며, api-key의 2차 배포 관리에도 사용할 수 있으며 다양한 대형 모델의 호출 매개변수를 구성 및 관리할 수 있습니다. 대형 모델 사용 시 API 키 및 메시지에 주의해야 합니다.
http://0.0.0.0:8090/
(이 프런트 엔드 페이지와 상호 작용은 완전히 gpt로 작성되었습니다. 하하) 변경 로그
2024-04-03
프로젝트의 핵심 구성은 model-config.json 파일에 의존합니다. model-config.json이 없으면 기본적으로 model-config-default.json을 사용하여 시작합니다. , API 키 등이 구성되지 않았기 때문에 호출할 수 없습니다.
새 model-config.json 파일을 로컬에서 생성하고 아래 구성 파일 예제에 따라 구성한 후 다음 명령을 실행합니다.
docker pull tianminghui/openai-style-api
docker run -d -p 8090:8090 --name openai-style-api
-e ADMIN-TOKEN=admin
-v /path/to/your/model-config.json:/app/model-config.json
tianminghui/openai-style-api
/path/to/your/model-config.json
자신의 로컬 경로로 바꾸십시오.
이 프로젝트를 복제하거나 프로젝트에서 docker-compose.yml
파일을 다운로드하고 ./model-config.json
경로를 수정한 후 다음 명령을 실행합니다.
docker-compose up -d
git clone https://github.com/tian-minghui/openai-style-api.git
이 프로젝트 코드를 가져옵니다.cp model-config-default.json model-config.json
및 필요에 따라 구성 파일 model-config.json을 수정합니다.pip install -r requirements.txt
python open-api.py
실행 model-config.json 구성 파일의 간단한 예
[
{
"token": "f2b7295fc440db7f",
"type": "azure", // azure openai 模型
"config": {
"api_base": "https://xxxx.openai.azure.com/",
"deployment_id": "gpt-35-turbo",
"api_version": "2023-05-15",
"api_key": "xxxxxx",
"temperature": 0.8
}
}
]
curl http://localhost:8090/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer f2b7295fc440db7f"
-d '{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
openai<1.0.0은 다음 방법을 사용합니다.
import openai
openai.api_key = "f2b7295fc440db7f"
openai.api_base = "http://localhost:8090/v1"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])
print(completion.choices[0].message.content)
openai>=1.0.0은 다음 메소드를 사용하여 호출됩니다.
import os
from openai import OpenAI
client = OpenAI(
# This is the default and can be omitted
api_key='kimi-GxqT3BlbkFJj',
base_url = 'http://localhost:8090/v1'
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
)
print(chat_completion.choices[0].message.content)
채팅GPT 다음 웹
[
{
"token": "f2b7295fc440db7f",
"type": "azure", // azure openai 模型
"config": {
"api_base": "https://xxxx.openai.azure.com/",
"deployment_id": "gpt-35-turbo",
"api_version": "2023-05-15",
"api_key": "xxxxxx",
"temperature": 0.8
}
},
{
"token": "GxqT3BlbkFJj",
"type": "openai", // openai 模型
"config": {
"api_base": "https://api.openai.com/v1/",
"api_key": "sk-xxxxxx",
"model": "gpt-3.5-turbo"
}
},
{
"token": "sb-ede1529390cc",
"type": "proxy", // openai 代理
"config": {
"api_base": "https://api.openai-sb.com/v1/",
"api_key": "sb-xxxxxx",
"model": "gpt-3.5-turbo"
}
},
{
"token": "c115c8f5082",
"type": "claude-web", // claude-web
"config": {
"cookie": "xxxxxx",
"proxies": {
"https": "http://localhost:7890"
},
"conversation_id": "xxxxxx",
"prompt": "The information in [] is the context of the conversation. Please ignore the JSON format of the context during the conversation and answer the user's latest conversation: {newMessage} n {history}",
"single_conversation": true
}
},
{
"token": "7c7aa4a3549f5",
"type": "zhipu-api", // 智谱API
"config": {
"api_key": "xxxxxx",
"model": "chatglm_lite",
"temperature": 0.8,
"top_p": 0.7
}
},
{
"token": "7c7aa4a3549f11",
"type": "xunfei-spark-api", // 讯飞星火API
"config": {
"app_id": "xxxx",
"api_key": "xxxx",
"api_secret": "xxxxxx",
"api_model_version": "v2.0",
"top_k": 5
}
},
{
"token": "7c7aa4a3549f12",
"type": "router", // 路由 可以包含多个模型进行负载均衡
"config": {
"router_strategy": "round-robin", // 路由策略 round-robin 轮询 random 随机
"token_pool": [ // 路由的token池
"7c7aa4a3549f11",
"7c7aa4a3549f5"
]
}
},
{
"token": "7c7aa4a3549f13",
"type": "model-name-router", //根据req中的modelname进行路由, 可以方便的结合ChatGPT-Next-Web
"config": {
"model-2-token": { // 路由的token池
"spark-api-v2.0":"7c7aa4a3549f11",
"chatglm_lite": "7c7aa4a3549f5",
"router-round-robin": "7c7aa4a3549f12"
}
}
},
{
"token": "gemini-7c7aa4a3549f5",
"type": "gemini", // gemini
"config": {
"api_key": "xxxxx",
"proxies": {
"https": "http://localhost:7890"
}
}
},
{
"token": "bing-7c7aa4a3549f5", // 必应
"type": "bing-sydney",
"config": {
"cookie": "xxxxx",
"style": "balanced"
}
},
{
"token":"qwen-111111xxxx", // 通义千问
"type":"qwen",
"config":{
"api_key":"sk-xxxxxxxx",
"model":"qwen-turbo"
}
},
{
"token": "kimi-GxqT3BlbkFJj1", // kimi
"type": "openai", // kimi api与openai相同,因此使用openai就可以
"config": {
"api_base": "https://api.moonshot.cn/v1/",
"api_key": "sk-xxxxxx",
"model": "moonshot-v1-8k"
}
}
]