พลังงานของฉันมีจำกัด และการอัปเดตบางรุ่นอาจไม่ได้รับการอัปเดตทันเวลา หากคุณพบปัญหา โปรดส่งปัญหาเข้ามาด้วย
ป้องกันความแตกต่างระหว่าง API โมเดลขนาดใหญ่ต่างๆ ใช้รูปแบบมาตรฐาน openai api เพื่อใช้โมเดลขนาดใหญ่ และยังใช้สำหรับการจัดการการแจกจ่ายรองของคีย์ api ได้อีกด้วย กำหนดค่าและจัดการพารามิเตอร์การเรียกของโมเดลขนาดใหญ่ต่างๆ เพื่อให้คุณใช้งานได้เท่านั้น โมเดลขนาดใหญ่เมื่อใช้โมเดลขนาดใหญ่ ต้องใส่ใจกับคีย์ API และข้อความ
http://0.0.0.0:8090/
(ส่วนหน้าและการโต้ตอบนี้เขียนด้วย gpt อย่างสมบูรณ์ 555) บันทึกการเปลี่ยนแปลง
03-04-2024
การกำหนดค่าหลักของโปรเจ็กต์อาศัยไฟล์ 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)
ChatGPT เว็บถัดไป
[
{
"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"
}
}
]