-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathprovider.py
More file actions
193 lines (186 loc) · 9.01 KB
/
provider.py
File metadata and controls
193 lines (186 loc) · 9.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import enum
from typing import List
from pydantic import BaseModel
class LLMProvider(str, enum.Enum):
OPENAI = "openai"
GEMINI = "gemini"
VERTEX_AI = "vertex_ai"
ANTHROPIC_VERTEX = "anthropic_vertex" # Deprecated, use VERTEX_AI instead
OPENAI_LIKE = "openai_like"
BEDROCK = "bedrock"
OLLAMA = "ollama"
GITEEAI = "giteeai"
AZURE_OPENAI = "azure_openai"
MINIMAX = "minimax"
class LLMProviderOption(BaseModel):
provider: LLMProvider
provider_display_name: str | None = None
provider_description: str | None = None
provider_url: str | None = None
default_llm_model: str
llm_model_description: str
default_config: dict = {}
config_description: str = ""
default_credentials: str | dict = ""
credentials_display_name: str
credentials_description: str
credentials_type: str = "str"
llm_provider_options: List[LLMProviderOption] = [
LLMProviderOption(
provider=LLMProvider.OPENAI,
provider_display_name="OpenAI",
provider_description="The OpenAI API provides a simple interface for developers to create an intelligence layer in their applications, powered by OpenAI's state of the art models.",
provider_url="https://platform.openai.com",
default_llm_model="gpt-4o",
llm_model_description="",
credentials_display_name="OpenAI API Key",
credentials_description="The API key of OpenAI, you can find it in https://platform.openai.com/api-keys",
credentials_type="str",
default_credentials="sk-****",
),
LLMProviderOption(
provider=LLMProvider.OPENAI_LIKE,
provider_display_name="OpenAI Like",
default_llm_model="",
llm_model_description="",
default_config={
"api_base": "https://openrouter.ai/api/v1/",
"is_chat_model": True,
},
config_description=(
"`api_base` is the API base URL of the third-party OpenAI-like service, such as OpenRouter; "
"`is_chat_model` indicates whether the model is chat model; "
"`context_window` is the maximum number of input tokens and output tokens; "
),
credentials_display_name="API Key",
credentials_description="The API key of the third-party OpenAI-like service, such as OpenRouter, you can find it in their official website",
credentials_type="str",
default_credentials="sk-****",
),
LLMProviderOption(
provider=LLMProvider.GEMINI,
provider_display_name="Gemini",
provider_description="The Gemini API and Google AI Studio help you start working with Google's latest models. Access the whole Gemini model family and turn your ideas into real applications that scale.",
provider_url="https://ai.google.dev/gemini-api",
default_llm_model="models/gemini-2.0-flash",
llm_model_description="Find the model code at https://ai.google.dev/gemini-api/docs/models/gemini",
credentials_display_name="Google API Key",
credentials_description="The API key of Google AI Studio, you can find it in https://aistudio.google.com/app/apikey",
credentials_type="str",
default_credentials="AIza****",
),
LLMProviderOption(
provider=LLMProvider.VERTEX_AI,
provider_display_name="Vertex AI",
provider_description="Vertex AI is a fully-managed, unified AI development platform for building and using generative AI.",
provider_url="https://cloud.google.com/vertex-ai",
default_llm_model="gemini-2.5-flash",
llm_model_description="Find more in https://cloud.google.com/model-garden",
credentials_display_name="Google Credentials JSON",
credentials_description="The JSON Object of Google Credentials, refer to https://cloud.google.com/docs/authentication/provide-credentials-adc#on-prem",
credentials_type="dict",
default_credentials={
"type": "service_account",
"project_id": "****",
"private_key_id": "****",
},
),
LLMProviderOption(
provider=LLMProvider.OLLAMA,
provider_display_name="Ollama",
provider_description="Ollama is a lightweight framework for building and running large language models.",
provider_url="https://ollama.com",
default_llm_model="llama3.2",
llm_model_description="Find more in https://ollama.com/library",
default_config={
"base_url": "http://localhost:11434",
"context_window": 8192,
"request_timeout": 60 * 10,
},
config_description=(
"`base_url` is the base URL of the Ollama server, ensure it can be accessed from this server; "
"`context_window` is the maximum number of input tokens and output tokens; "
"`request_timeout` is the maximum time to wait for a generate response."
),
credentials_display_name="Ollama API Key",
credentials_description="Ollama doesn't require an API key, set a dummy string here is ok",
credentials_type="str",
default_credentials="dummy",
),
LLMProviderOption(
provider=LLMProvider.GITEEAI,
provider_display_name="Gitee AI",
provider_description="Gitee AI is a third-party model provider that offers ready-to-use cutting-edge model APIs for AI developers.",
provider_url="https://ai.gitee.com",
default_llm_model="Qwen2.5-72B-Instruct",
default_config={
"is_chat_model": True,
"context_window": 131072,
},
config_description=(
"`is_chat_model` indicates whether the model is chat model; "
"`context_window` is the maximum number of input tokens and output tokens; "
),
llm_model_description="Find more in https://ai.gitee.com/serverless-api",
credentials_display_name="Gitee AI API Key",
credentials_description="The API key of Gitee AI, you can find it in https://ai.gitee.com/dashboard/settings/tokens",
credentials_type="str",
default_credentials="****",
),
LLMProviderOption(
provider=LLMProvider.BEDROCK,
provider_display_name="Bedrock",
provider_description="Amazon Bedrock is a fully managed foundation models service.",
provider_url="https://docs.aws.amazon.com/bedrock/",
default_llm_model="anthropic.claude-3-7-sonnet-20250219-v1:0",
llm_model_description="",
credentials_display_name="AWS Bedrock Credentials JSON",
credentials_description="The JSON Object of AWS Credentials, refer to https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-global",
credentials_type="dict",
default_credentials={
"aws_access_key_id": "****",
"aws_secret_access_key": "****",
"aws_region_name": "us-west-2",
},
),
LLMProviderOption(
provider=LLMProvider.AZURE_OPENAI,
provider_display_name="Azure OpenAI",
provider_description="Azure OpenAI is a cloud-based AI service that provides access to OpenAI's advanced language models.",
provider_url="https://azure.microsoft.com/en-us/products/ai-services/openai-service",
default_llm_model="gpt-4o",
llm_model_description="",
config_description="Refer to this document https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart to have more information about the Azure OpenAI API.",
default_config={
"azure_endpoint": "https://<your-resource-name>.openai.azure.com/",
"api_version": "<your-api-version>",
"engine": "<your-deployment-name>",
},
credentials_display_name="Azure OpenAI API Key",
credentials_description="The API key of Azure OpenAI",
credentials_type="str",
default_credentials="****",
),
LLMProviderOption(
provider=LLMProvider.MINIMAX,
provider_display_name="MiniMax",
provider_description="MiniMax is a leading AI technology company offering powerful large language models with OpenAI-compatible APIs, featuring MiniMax-M2.7 for complex reasoning tasks.",
provider_url="https://platform.minimax.io",
default_llm_model="MiniMax-M2.7",
llm_model_description="Available models: MiniMax-M2.7 (peak performance), MiniMax-M2.7-highspeed (faster). See https://platform.minimax.io/docs/guides/pricing-paygo",
default_config={
"api_base": "https://api.minimax.io/v1",
"is_chat_model": True,
"context_window": 204800,
},
config_description=(
"`api_base` is the API base URL of MiniMax, default is `https://api.minimax.io/v1`; "
"`is_chat_model` indicates whether the model is chat model; "
"`context_window` is the maximum number of input tokens and output tokens; "
),
credentials_display_name="MiniMax API Key",
credentials_description="The API key of MiniMax, you can get it from https://platform.minimax.io",
credentials_type="str",
default_credentials="eyJ****",
),
]