mirror of
https://github.com/katanemo/plano.git
synced 2026-04-25 00:36:34 +02:00
adding support for Qwen models and fixed issue with passing PATH vari… (#583)
* adding support for Qwen models and fixed issue with passing PATH variable * don't need to have qwen in the model alias routing example * fixed base_url for qwen --------- Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-288.local>
This commit is contained in:
parent
dbeaa51aa7
commit
226139e907
6 changed files with 49 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ SUPPORTED_PROVIDERS = [
|
|||
"ollama",
|
||||
"moonshotai",
|
||||
"zhipu",
|
||||
"qwen",
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -128,9 +129,9 @@ def validate_and_render_schema():
|
|||
)
|
||||
provider = model_name_tokens[0]
|
||||
# Validate azure_openai and ollama provider requires base_url
|
||||
if (provider == "azure_openai" or provider == "ollama") and llm_provider.get(
|
||||
"base_url"
|
||||
) is None:
|
||||
if (
|
||||
provider == "azure_openai" or provider == "ollama" or provider == "qwen"
|
||||
) and llm_provider.get("base_url") is None:
|
||||
raise Exception(
|
||||
f"Provider '{provider}' requires 'base_url' to be set for model {model_name}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -205,6 +205,8 @@ def up(file, path, service, foreground):
|
|||
"MODEL_SERVER_PORT": os.getenv("MODEL_SERVER_PORT", "51000"),
|
||||
}
|
||||
env = os.environ.copy()
|
||||
# Remove PATH variable if present
|
||||
env.pop("PATH", None)
|
||||
# check if access_keys are preesnt in the config file
|
||||
access_keys = get_llm_provider_access_keys(arch_config_file=arch_config_file)
|
||||
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ pub enum LlmProviderType {
|
|||
Moonshotai,
|
||||
#[serde(rename = "zhipu")]
|
||||
Zhipu,
|
||||
#[serde(rename = "qwen")]
|
||||
Qwen,
|
||||
}
|
||||
|
||||
impl Display for LlmProviderType {
|
||||
|
|
@ -197,6 +199,7 @@ impl Display for LlmProviderType {
|
|||
LlmProviderType::Ollama => write!(f, "ollama"),
|
||||
LlmProviderType::Moonshotai => write!(f, "moonshotai"),
|
||||
LlmProviderType::Zhipu => write!(f, "zhipu"),
|
||||
LlmProviderType::Qwen => write!(f, "qwen"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,13 @@ impl SupportedAPIs {
|
|||
default_endpoint
|
||||
}
|
||||
}
|
||||
ProviderId::Qwen => {
|
||||
if request_path.starts_with("/v1/") {
|
||||
"/compatible-mode/v1/chat/completions".to_string()
|
||||
} else {
|
||||
default_endpoint
|
||||
}
|
||||
}
|
||||
ProviderId::AzureOpenAI => {
|
||||
if request_path.starts_with("/v1/") {
|
||||
format!("/openai/deployments/{}/chat/completions?api-version=2025-01-01-preview", model_id)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pub enum ProviderId {
|
|||
Ollama,
|
||||
Moonshotai,
|
||||
Zhipu,
|
||||
Qwen, // alias for Qwen
|
||||
}
|
||||
|
||||
impl From<&str> for ProviderId {
|
||||
|
|
@ -38,6 +39,7 @@ impl From<&str> for ProviderId {
|
|||
"ollama" => ProviderId::Ollama,
|
||||
"moonshotai" => ProviderId::Moonshotai,
|
||||
"zhipu" => ProviderId::Zhipu,
|
||||
"qwen" => ProviderId::Qwen, // alias for Zhipu
|
||||
_ => panic!("Unknown provider: {}", value),
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +66,8 @@ impl ProviderId {
|
|||
| ProviderId::TogetherAI
|
||||
| ProviderId::Ollama
|
||||
| ProviderId::Moonshotai
|
||||
| ProviderId::Zhipu,
|
||||
| ProviderId::Zhipu
|
||||
| ProviderId::Qwen,
|
||||
SupportedAPIs::AnthropicMessagesAPI(_)) => SupportedAPIs::OpenAIChatCompletions(OpenAIApi::ChatCompletions),
|
||||
|
||||
(ProviderId::OpenAI
|
||||
|
|
@ -79,7 +82,8 @@ impl ProviderId {
|
|||
| ProviderId::TogetherAI
|
||||
| ProviderId::Ollama
|
||||
| ProviderId::Moonshotai
|
||||
| ProviderId::Zhipu,
|
||||
| ProviderId::Zhipu
|
||||
| ProviderId::Qwen,
|
||||
SupportedAPIs::OpenAIChatCompletions(_)) => SupportedAPIs::OpenAIChatCompletions(OpenAIApi::ChatCompletions),
|
||||
}
|
||||
}
|
||||
|
|
@ -102,6 +106,7 @@ impl Display for ProviderId {
|
|||
ProviderId::Ollama => write!(f, "ollama"),
|
||||
ProviderId::Moonshotai => write!(f, "moonshotai"),
|
||||
ProviderId::Zhipu => write!(f, "zhipu"),
|
||||
ProviderId::Qwen => write!(f, "qwen"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,6 +517,32 @@ Azure OpenAI
|
|||
access_key: $AZURE_OPENAI_API_KEY
|
||||
base_url: https://your-resource.openai.azure.com
|
||||
|
||||
|
||||
Azure OpenAI
|
||||
~~~~~~~~~~~~
|
||||
|
||||
**Provider Prefix:** ``qwen/``
|
||||
|
||||
**API Endpoint:** ``/v1/chat/completions``
|
||||
|
||||
**Authentication:** API Key + Base URL - Get your Qwen API key from `Qwen Portal <https://modelstudio.console.alibabacloud.com/>`_ → Your Qwen Resource → Keys and Endpoint.
|
||||
|
||||
**Supported Chat Models:** All Qwen chat models including Qwen3, Qwen3-Coder and all future releases.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
llm_providers:
|
||||
# Single deployment
|
||||
- model: qwen/qwen3
|
||||
access_key: $DASHSCOPE_API_KEY
|
||||
base_url: https://dashscope.aliyuncs.com
|
||||
|
||||
# Multiple deployments
|
||||
- model: qwen/qwen3-coder
|
||||
access_key: $DASHSCOPE_API_KEY
|
||||
base_url: "https://dashscope-intl.aliyuncs.com",
|
||||
|
||||
|
||||
Ollama
|
||||
~~~~~~
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue