Skip to content

feat: add FIM completions support to alibailian #2115

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PMExtra
Copy link

@PMExtra PMExtra commented Feb 19, 2025

Related #1522 #1795

百炼本身是支持 FIM (/v1/completions) 接口的,但取决于具体模型是否兼容。已知至少 qwen-coder-turboqwen2.5-coder-7b-instruct 是能支持的,截图如下:

image

Edit: 截图意外泄露API-Key了,已经回收该Key😂

测试命令:

curl -X POST "https://dashscope.aliyuncs.com/compatible-mode/v1/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-token>" \
  -d '{
        "model": "qwen-coder-turbo",
        "prompt": "def fib(a):",
        "suffix": "    return fib(a-1) + fib(a-2)",
        "max_tokens": 128
      }'

改动很小,一共两行代码一眼就能看完,望尽快合入。

@ShuguangSun
Copy link

能否请教一下通过one-api与直接链接原服务API的FIM的token情况,我这里通过one-api的FIM的token消耗大约是直连的5~10倍

@PMExtra
Copy link
Author

PMExtra commented Apr 8, 2025

@ShuguangSun 你是从哪里看的token消耗

@ShuguangSun
Copy link

root的日志,原服务的查询,一段时间里只有autocomplete

@ShuguangSun
Copy link

我是配合vscode的continue使用的

@PMExtra
Copy link
Author

PMExtra commented Apr 8, 2025

one-api 的计费本来就不太准,一大差异应该来自于 input 的 cache 。

自动补全场景的 cache 命中率是非常高的,但是 one-api 不区分 cache 和 input 。

你应该用同一个数据来源对比使用 one-api 和直连的 token 消耗。比如对比使用前后的原服务的账单明细。

@ShuguangSun
Copy link

多谢指教!

@ShuguangSun
Copy link

比较两个类似场景(vscode continue, 相同workspace,打开相同的一些文件,对同一个文件从0开始编辑类似的内容), one-api 比直连的 token 消耗及费用都要高,用两个不同的api key,可以在服务商网站上看到one-api出去的,token消耗量要10倍左右

从one-api的日志看,似乎补全的token异常高
image

@PMExtra
Copy link
Author

PMExtra commented Apr 10, 2025

Continue 配置的前后差异只有 apiBase 吗? provider 或者 model 是否有变化?

@ShuguangSun
Copy link

只有apibase的差异,从continue在vscode output panel里Continue - LLM Prompt/Completion的输出内容来看,这些4k的(默认maxtoken是4096)里的Completion:都是一些小补全片段的重复,就是当前"理想“的补全是一小段代码,比如 proc sort data=adsl; 然后返回的是以上代码片段的不断重复,直到maxtoken

@PMExtra
Copy link
Author

PMExtra commented Apr 10, 2025

原来是这个事情。我之前也遇到过,以为是偶然。不过我现在都用的 SiliconFlow 渠道,没再遇到这个问题。

由于 One-Api 看起来现在维护不太积极,我已经换用 One-Hub 了,所以不想在 One-Api 上继续分析这个问题。

不过 One-Hub 看起来也不支持阿里的 FIM ,我回头研究一下测试好再给 One-Hub 提 PR 吧。

总结就是:

  1. 临时解决方案,更换上游渠道;
  2. 根本解决方案,我会在 One-Hub 上 PR ,到时候 at 你。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants