MartialBE / one-hub

OpenAI 接口管理 & 分发系统,改自songquanpeng/one-api。支持更多模型,加入统计页面,完善非openai模型的函数调用。
https://one-api-martialbe.vercel.app/
Apache License 2.0
1.02k stars 201 forks source link

支持 Perplexity AI? #232

Closed bentwnghk closed 3 months ago

bentwnghk commented 3 months ago

例行检查

问题描述 是否不支持 Perplexity AI? 复现步骤 如下圖添加自定義渠道,測試錯誤返回: Provider API error: bad response status code 404. 预期结果

相关截图 螢幕擷取畫面 2024-05-27 111037

MartialBE commented 3 months ago

看了他的api,区别是没有携带/v1。 目前请求时都会携带这个api的版本号 我晚点看看怎么处理比较好。

bentwnghk commented 3 months ago

辛苦了,先謝謝你!

MartialBE commented 3 months ago

晚点试试dev版本镜像。 在 自定义渠道 中 api版本中 填入disable 试试

image
bentwnghk commented 3 months ago

使用dev版本镜像,容器啟動錯誤: image

MartialBE commented 3 months ago

你在启动时 设置了 --config= 参数了吗

MartialBE commented 3 months ago

因为之前没有判断 用户传入的 配置文件地址 是否正确,这次加上判断了。你可能需要检查 --config 设置的文件地址是否存在, 在容器中 是容器的文件地址,而不是你宿主机的 文件地址

bentwnghk commented 3 months ago
version: '3.4'

services:
  one-api:
    image: martialbe/one-api:dev
    container_name: one-api
    restart: always
    # privileged: true
    command: --log-dir /app/logs
    ports:
      - "3099:3000"
    volumes:
      - /root/oneapi:/data
      - /root/oneapi/logs:/app/logs
    environment:
      - SQL_DSN=oneapi:xxx@tcp(db:3306)/one-api  # 修改此行,或注释掉以使用 SQLite 作为数据库
      - REDIS_CONN_STRING=redis://redis
      - SESSION_SECRET=xxx # 修改为随机字符串
      - TZ=Asia/Hong_Kong
      - STORAGE_SMMS_SECRET=xxx  # 设置之后将使用 sm.ms 作为图片存储服务
      - STORAGE_IMGUR_CLIENT_ID=xxx  # 设置之后将使用 imgur 作为图片存储服务
      # - GEMINI_VERSION=v1beta
    depends_on:
      - redis
      - db
    healthcheck:
      test: [ "CMD-SHELL", "wget -q -O - http://localhost:3099/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $2}'" ]
      interval: 30s
      timeout: 10s
      retries: 3

  redis:
    image: redis:latest
    container_name: oneapi-redis
    restart: always

  db:
    image: mysql:8.2.0
    restart: always
    container_name: oneapi-mysql
    volumes:
      - /root/oneapi/mysql:/var/lib/mysql  # 挂载目录,持久化存储
    ports:
      - '3307:3306'
    environment:
      TZ: Asia/Hong_Kong   # 设置时区
      MYSQL_ROOT_PASSWORD: 'xxx' # 设置 root 用户的密码
      MYSQL_USER: oneapi   # 创建专用用户
      MYSQL_PASSWORD: 'xxx'    # 设置专用用户密码
      MYSQL_DATABASE: one-api   # 自动创建数据库
MartialBE commented 3 months ago

我知道 哪里出问题了。稍等

MartialBE commented 3 months ago

好了 等 GitHub Actions 编译完成 再试试

bentwnghk commented 3 months ago

好了 等 GitHub Actions 编译完成 再试试

渠道测试成功,但實際調用報錯:

{
  "error": {
    "code": "bad_response_status_code",
    "message": "Provider API error: bad response status code 404 (request id: 20240529151626355463126xDDtWT65)",
    "param": "404",
    "type": "upstream_error"
  }
}

image

MartialBE commented 3 months ago

是否你使用的工具 传入了不支持的 参数? 因为我没有Perplexity AI 账户 无法进行测试。

bentwnghk commented 3 months ago

是否你使用的工具 传入了不支持的 参数? 因为我没有Perplexity AI 账户 无法进行测试。

我用的是chatgpt-web-midjourney-proxy,我只在CUSTOM_MODELS填入模型名稱llama-3-sonar-small-32k-chat,沒有設置其他参数: image

MartialBE commented 3 months ago

测试模型时, 你看看 容器中 返回了 什么内容

bentwnghk commented 3 months ago

测试模型时, 你看看 容器中 返回了 什么内容

[GIN] 2024/05/29 - 15:50:30 | 202405291550302878962655Te0QEv8 | 204 |      28.081µs |   118.140.249.2 | OPTIONS /v1/chat/completions
[GIN] 2024/05/29 - 15:50:31 | 20240529155030586731477TMnExRqB | 404 |  418.095222ms |   118.140.249.2 |    POST /v1/chat/completions
[ERR] 2024/05/29 - 15:50:31 | 20240529155030586731477TMnExRqB | relay error (channel #17(Perplexity)): Provider API error: bad response status code 404 (request id: 20240529155030586731477TMnExRqB) 
[GIN] 2024/05/29 - 15:51:05 | 20240529155105901005110vUbuFl9d | 200 |    1.499611ms |  123.202.36.176 |     GET /
[ERR] 2024/05/29 - 15:51:17 | 20240529155117112906266Vgd0s5mt | relay error (channel #17(Perplexity)): Provider API error: bad response status code 404 (request id: 20240529155117112906266Vgd0s5mt) 
[GIN] 2024/05/29 - 15:51:17 | 20240529155117112906266Vgd0s5mt | 404 |  129.726484ms |      172.18.0.1 |    POST /v1/chat/completions
MartialBE commented 3 months ago

看样子 地址有问题。 你确认你在 api 版本 填写了 disable吗? 前后是否有空格

bentwnghk commented 3 months ago

看样子 地址有问题。 你确认你在 api 版本 填写了 disable吗? 前后是否有空格

沒錯呢: image

MartialBE commented 3 months ago

我在本地测试 确实删除了版本号, 我无法给你更多帮助了。

image image
bentwnghk commented 3 months ago

我在本地测试 确实删除了版本号, 我无法给你更多帮助了。

image image

我發現,當我再次编辑渠道並按提交後,第一次調用模型是成功的,但再次調用便會失敗: image

容器 返回内容:

[GIN] 2024/05/29 - 16:12:26 | 20240529161226720086094zG3VDrIK | 200 |    2.350378ms |   118.140.249.2 |     GET /v1/dashboard/billing/subscription
[GIN] 2024/05/29 - 16:12:41 | 20240529161241805936261xQpGazik | 204 |      36.881µs |   118.140.249.2 | OPTIONS /v1/chat/completions
[GIN] 2024/05/29 - 16:12:42 | 20240529161242974098860ZDzoWQ3 | 200 |  580.923913ms |   118.140.249.2 |    POST /v1/chat/completions
[INFO] 2024/05/29 - 16:12:42 | 20240529161242974098860ZDzoWQ3 | record consume log: userId=1, channelId=17, promptTokens=209, completionTokens=35, modelName=llama-3-sonar-small-32k-chat, tokenName=chat.mystudies.net, quota=7320, content=模型费率 $0.06/1k,分组倍率 1.00 
[SYS] 2024/05/29 - 16:13:05 | syncing options from database 
[GIN] 2024/05/29 - 16:13:13 | 20240529161313914057603SJUnkQG2 | 204 |       37.52µs |   118.140.249.2 | OPTIONS /v1/chat/completions
[ERR] 2024/05/29 - 16:13:14 | 202405291613142006530620sMM3YAe | relay error (channel #17(Perplexity)): Provider API error: bad response status code 404 (request id: 202405291613142006530620sMM3YAe) 
[GIN] 2024/05/29 - 16:13:14 | 202405291613142006530620sMM3YAe | 404 |  147.943365ms |   118.140.249.2 |    POST /v1/chat/completions
[GIN] 2024/05/29 - 16:13:23 | 20240529161323179089447X2VhCLDl | 200 |     979.607µs |  123.202.36.176 |     GET /
MartialBE commented 3 months ago

我修改了一个 可能会出问题的地方。 等GitHub Actions编译完成后 再试试。 如果还不行,真的无法帮助你了🤣

bentwnghk commented 3 months ago

我修改了一个 可能会出问题的地方。 等GitHub Actions编译完成后 再试试。 如果还不行,真的无法帮助你了🤣

成功了!感激你的幫助!!