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

[Bug] HUGGINGFACE_PROXY_URL 端点不正确 #5072

Closed
chai-mi opened this issue Dec 18, 2024 · 6 comments
Closed

[Bug] HUGGINGFACE_PROXY_URL 端点不正确 #5072

chai-mi opened this issue Dec 18, 2024 · 6 comments
Labels
🐛 Bug Something isn't working | 缺陷

Comments

@chai-mi
Copy link
Contributor

chai-mi commented Dec 18, 2024

📦 部署环境

Vercel

📌 软件版本

1.36.33

💻 系统环境

Windows

🌐 浏览器

Chrome

🐛 问题描述

HUGGINGFACE_PROXY_URL 设置后无法访问模型

HUGGINGFACE API 端点为以下形式
https://api-inference.huggingface.co/models/Qwen/QwQ-32B-Preview/v1/chat/completions

设置例如 HUGGINGFACE_PROXY_URL=https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface 后访问的端点变为 https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface/v1/chat/completions,无法正确访问模型

返回错误信息:

{
  "error": "Model v1/chat/completions does not exist"
}

📷 复现步骤

No response

🚦 期望结果

No response

📝 补充信息

No response

@chai-mi chai-mi added the 🐛 Bug Something isn't working | 缺陷 label Dec 18, 2024
@github-project-automation github-project-automation bot moved this to Roadmap - Chat 1.x in Lobe Chat Routine Dec 18, 2024
@lobehubbot
Copy link
Member

👀 @chai-mi

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

Copy link

dosubot bot commented Dec 18, 2024

@chai-mi 你好! 我是Dosu,一个可以帮助你解决 bug,回答问题,还可以成为贡献者的机器人。我会在等待人类维护者时帮助你。

The issue you're encountering seems to be related to how the HUGGINGFACE_PROXY_URL is being used to construct the API endpoint URL. The framework likely appends additional path segments to the proxy URL, which results in an incorrect endpoint.

To resolve this, you might need to adjust the HUGGINGFACE_PROXY_URL to ensure it ends with the appropriate path that matches the expected structure of the Hugging Face API endpoint. If the framework appends /v1/chat/completions, you should ensure that your proxy URL is set up to handle this correctly.

For example, if your proxy URL is https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface, and the framework appends /v1/chat/completions, the resulting URL would be https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface/v1/chat/completions. You may need to configure your proxy to correctly route requests to the intended Hugging Face model endpoint.

Additionally, check if there are any configuration options in the framework that allow you to customize the endpoint path or if you can modify the proxy setup to handle the appended paths correctly.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

chai-mi added a commit to chai-mi/lobe-chat that referenced this issue Dec 20, 2024
@arvinxx
Copy link
Contributor

arvinxx commented Dec 20, 2024

这个感觉不是 HF Proxy Url 的问题,是 CF 的规范和 HF 不一样。如果我另外一个 proxy_url 就单纯做 HF 的转发就可以的

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This feeling is not a problem with HF Proxy Url, but because the specifications of CF are different from HF. If I use another proxy_url, I can simply forward HF.

@chai-mi
Copy link
Contributor Author

chai-mi commented Dec 20, 2024

CF 也只是单纯的把
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface/*
转发到
https://api-inference.huggingface.co/models/*

我看 @huggingface/inference SDK 对 endpointUrl 的处理是这样的

let url = (() => {
if (endpointUrl && isUrl(model)) {
	throw new TypeError("Both model and endpointUrl cannot be URLs");
}
if (isUrl(model)) {
	console.warn("Using a model URL is deprecated, please use the `endpointUrl` parameter instead");
	return model;
}
if (endpointUrl) {
	return endpointUrl;
}
if (task) {
	return `${HF_INFERENCE_API_BASE_URL}/pipeline/${task}/${model}`;
}

return `${HF_INFERENCE_API_BASE_URL}/models/${model}`;
})();

if (chatCompletion && !url.endsWith("/chat/completions")) {
url += "/v1/chat/completions";
}

@chai-mi chai-mi closed this as completed Dec 21, 2024
@github-project-automation github-project-automation bot moved this from Roadmap - Chat 1.x to Done in Lobe Chat Routine Dec 21, 2024
@lobehubbot
Copy link
Member

@chai-mi

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working | 缺陷
Projects
Status: Done
Development

No branches or pull requests

3 participants