Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在随机模式下,如何通过URL连接指定所使用的AI服务? #82

Open
aaro-n opened this issue Oct 25, 2024 · 3 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@aaro-n
Copy link

aaro-n commented Oct 25, 2024

遇到的问题

在simple-one-api代理百度千帆、讯飞星火、Google gemini和CF 的AI,每次访问都会随机到上述AI的一种,有没有方法能通过URL指定所使用的后台AI ?我查找过文档,指定过models,但没用。

config.json

{
  "log_level": "prod",
  "server_port": ":9090",
  "api_key": "sk-dfKrzhtPruv4OQDG********c4dDdAbF0",
  "load_balancing": "random",
  "proxy": {},
  "services": {
    "qianfan": [
      {
        "models": ["ERNIE-Lite-8K"],
        "enabled": true,
        "model_map": {
          "baidu": "ERNIE-Lite-8K"
        },
        "model_redirect": {
          "gpt-3.5-turbo": "ERNIE-Lite-8K"
        },
        "limit": {
          "qps": 300
        },
        "credentials": {
          "api_key": "lku54*****NseB",
          "secret_key": "IG*****mXzfo"
        }
      }
    ],
    "xinghuo": [
      {
        "models": ["spark-lite"],
        "enabled": true,
        "model_map": {
          "xinghuo": "spark-lite"
        },
        "model_redirect": {
          "gpt-3.5-turbo": "spark-lite"
        },
        "limit": {},
        "credentials": {
          "appid": "866*****",
          "api_key": "a6******c8a5",
          "api_secret": "N******M0"
        }
      }
    ],
    "openai": [
      {
        "models": ["@cf/meta/llama-3-8b-instruct"],
        "enabled": true,
        "model_map": {
          "cf": "@cf/meta/llama-3-8b-instruct"
        },
        "model_redirect": {
          "gpt-3.5-turbo": "@cf/meta/llama-3-8b-instruct"
        },
        "limit": {},
        "credentials": {
          "api_key": "gEbUL******ZKxL"
        },
        "server_url": "https://api.cloudflare.com/client/v4/accounts/7d********138/ai/v1"
      }
    ],
    "gemini": [
      {
        "models": ["gemini-1.5-flash"],
        "enabled": true,
        "model_map": {
          "google": "gemini-1.5-flash"
        },
        "model_redirect": {
          "gpt-3.5-turbo": "gemini-1.5-flash"
        },
        "limit": {
          "qps": 15
        },
        "credentials": {
          "api_key": "AI******Os"
        }
      }
    ]
  }
}

测试的连接

http://104.3*6.4*7.2*4:19090/v1/google
http://104.3*6.4*7.2*4:19090/v1/baidu
http://104.3*6.4*7.2*4:19090/v1/gemini-1.5-flash

以上连接都无法指定后端所使用的Ai模型
我该如何做?

@lopins
Copy link

lopins commented Oct 31, 2024

启用哪个模型是由你的客户端决定的

@fruitbars
Copy link
Owner

模型是由消息中的model来决定的。可以参考下openai的文档https://platform.openai.com/docs/guides/text-generation

curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{
        "model": "gpt-4o",
        "messages": [
            {"role": "user", "content": "write a haiku about ai"}
        ]
    }'

@aaro-n
Copy link
Author

aaro-n commented Nov 4, 2024

@fruitbars @lopins 我希望simple-one-api可以像one-api那样指定simple-one-api所运行的后端AI,例如one-api密钥为sk-dfKrzhtPruv4OQDG********c4dDdAbF0,则sk-dfKrzhtPruv4OQDG********c4dDdAbF0-1为Google ai,sk-dfKrzhtPruv4OQDG********c4dDdAbF0-2为百度AI,我以为simple-one-api也可以使用类似的功能,只是要在URL中指定。

@fruitbars fruitbars added the enhancement New feature or request label Nov 13, 2024
@fruitbars fruitbars self-assigned this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants