-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: 添加对Xinference模型的支持 #528
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,8 @@ | |
"google": "Google", | ||
"alibaba": "Alibaba", | ||
"moonshot": "MoonShot", | ||
"unbound": "Unbound AI" | ||
"unbound": "Unbound AI", | ||
"xinference": "XInference", | ||
} | ||
|
||
|
||
|
@@ -183,6 +184,27 @@ def get_llm_model(provider: str, **kwargs): | |
model_name=kwargs.get("model_name", "Qwen/QwQ-32B"), | ||
temperature=kwargs.get("temperature", 0.0), | ||
) | ||
elif provider == "xinference": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing entry for "xinference" in PROVIDER_DISPLAY_NAMES dictionary |
||
if not kwargs.get("base_url", ""): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API key retrieval uses a different environment variable pattern than what's defined in .env.example |
||
base_url = os.getenv("XINFERENCE_OPENAI_ENDPOINT", "https://api.xinference.com/v1") | ||
else: | ||
base_url = kwargs.get("base_url") | ||
|
||
if not kwargs.get("api_key", ""): | ||
api_key = os.getenv("XINFERENCE_API_KEY", "") | ||
else: | ||
api_key = kwargs.get("api_key") | ||
|
||
if not kwargs.get("model_name", ""): | ||
model_name = os.getenv("XINFERENCE_MODEL", "qwen2.5-instruct") | ||
else: | ||
model_name = kwargs.get("model_name") | ||
return ChatOpenAI( | ||
model=model_name, | ||
temperature=kwargs.get("temperature", 0.0), | ||
base_url=base_url, | ||
api_key=api_key, | ||
) | ||
else: | ||
raise ValueError(f"Unsupported provider: {provider}") | ||
|
||
|
@@ -234,6 +256,10 @@ def get_llm_model(provider: str, **kwargs): | |
"Pro/THUDM/chatglm3-6b", | ||
"Pro/THUDM/glm-4-9b-chat", | ||
], | ||
"xinference": ["qwen2.5-instruct", "qwen2.5", "qwen2.5-coder", "qwen2.5-coder-instruct", "qwen2.5-instruct-1m", | ||
"qwen2.5-vl-instruct", "deepseek", "deepseek-chat", "deepseek-coder", "deepseek-coder-instruct", | ||
"deepseek-r1", "deepseek-v2", "deepseek-v2-chat", "deepseek-v2-chat-0628", "deepseek-v2.5", | ||
"deepseek-v3", "deepseek-vl-chat", "deepseek-vl2"] | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for expected values for XINFERENCE_MODEL environment variable