uni-api icon indicating copy to clipboard operation
uni-api copied to clipboard

有没有可能加一个 random 模型,请求时,随机选择一个可用的模型请求就好

Open DemonJun opened this issue 1 year ago • 5 comments

DemonJun avatar Oct 12 '24 04:10 DemonJun

好的,最近在开发前端,等我把基础的前端写完,就写这个功能,开发完了,这里提醒你。❤️

yym68686 avatar Oct 12 '24 07:10 yym68686

好的,感恩的心

DemonJun avatar Oct 12 '24 07:10 DemonJun

这个功能完全可以在客户端实现,自己建一个list例如[gpt-4o,gpt-4o-mini]之类,然后每次请求的时候随机选一个填模型里

BenedictKing avatar Oct 13 '24 12:10 BenedictKing

好的,最近在开发前端,等我把基础的前端写完,就写这个功能,开发完了,这里提醒你。❤️

这里再实现的时候,能不能 random 的时候,如果第一个模型出错,可以自动重新选择下一个重试,直到成功返回?

DemonJun avatar Oct 14 '24 02:10 DemonJun

这个功能完全可以在客户端实现,自己建一个list例如[gpt-4o,gpt-4o-mini]之类,然后每次请求的时候随机选一个填模型里

前提要客户端自己开发,或者支持才行

DemonJun avatar Oct 14 '24 02:10 DemonJun

你好,现在已经支持随机选择渠道了。示例配置如下:

providers:
  - provider: provider_name
    base_url: https://api.your.com/v1/chat/completions
    api: sk-YgS6GTi0b4bEabc4C
api_keys:
  - api: sk-Pxxx
    model:
      - all
    preferences:
      SCHEDULING_ALGORITHM: random # 使用随机轮训负载均衡,随机使用拥有请求的模型的渠道。
      # 当 SCHEDULING_ALGORITHM 为 fixed_priority 时,使用固定优先级调度,永远执行第一个拥有请求的模型的渠道。
      # 修改默认开启的渠道轮询负载均衡。SCHEDULING_ALGORITHM 可选值为:fixed_priority,weighted_round_robin, lottery, random。

yym68686 avatar Oct 18 '24 21:10 yym68686

这里其实想要的是 在配置 model 列表中,进行模型随机,不仅限于 provider 之间随机。

DemonJun avatar Oct 23 '24 01:10 DemonJun

model 列表中进行模型随机 等于 provider 之间随机。因为你每次请求只能请求一个模型。举个例子:每个提供商只有一个 gpt-3.5-turbo 模型,不存在另外一个gpt-3.5-turbo跟同提供商的另外一个 gpt-3.5-turbo 随机选择的情况。只有不同提供商之间才会有两个 gpt-3.5-turbo 随机选择。

yym68686 avatar Oct 23 '24 11:10 yym68686