Skip to content

Commit 283279f

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents a23f55f + 6e760ef commit 283279f

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

backend/apps/ai_model/model_factory.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from common.core.db import engine
1313
from common.utils.utils import prepare_model_arg
1414
from langchain_community.llms import VLLMOpenAI
15-
15+
from langchain_openai import AzureChatOpenAI
1616
# from langchain_community.llms import Tongyi, VLLM
1717

1818
class LLMConfig(BaseModel):
@@ -69,6 +69,24 @@ def _init_llm(self) -> VLLMOpenAI:
6969
streaming=True,
7070
**self.config.additional_params,
7171
)
72+
73+
class OpenAIAzureLLM(BaseLLM):
74+
def _init_llm(self) -> AzureChatOpenAI:
75+
api_version = self.config.additional_params.get("api_version")
76+
deployment_name = self.config.additional_params.get("deployment_name")
77+
if api_version:
78+
self.config.additional_params.pop("api_version")
79+
if deployment_name:
80+
self.config.additional_params.pop("deployment_name")
81+
return AzureChatOpenAI(
82+
azure_endpoint=self.config.api_base_url,
83+
api_key=self.config.api_key or 'Empty',
84+
model_name=self.config.model_name,
85+
api_version=api_version,
86+
deployment_name=deployment_name,
87+
streaming=True,
88+
**self.config.additional_params,
89+
)
7290
class OpenAILLM(BaseLLM):
7391
def _init_llm(self) -> BaseChatModel:
7492
return BaseChatOpenAI(
@@ -89,7 +107,8 @@ class LLMFactory:
89107
_llm_types: Dict[str, Type[BaseLLM]] = {
90108
"openai": OpenAILLM,
91109
"tongyi": OpenAILLM,
92-
"vllm": OpenAIvLLM
110+
"vllm": OpenAIvLLM,
111+
"azure": OpenAIAzureLLM,
93112
}
94113

95114
@classmethod
10.5 KB
Loading

frontend/src/entity/supplier.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import icon_openai_colorful from '@/assets/model/icon_openai_colorful.png'
88
import icon_kimi_colorful from '@/assets/model/icon_kimi_colorful.png'
99
import icon_txhy_colorful from '@/assets/model/icon_txhy_colorful.png'
1010
import icon_hsyq_colorful from '@/assets/model/icon_hsyq_colorful.png'
11-
import icon_vllm_colorful from '@/assets/model/icon_vllm_colorful.png'
11+
// import icon_vllm_colorful from '@/assets/model/icon_vllm_colorful.png'
12+
import icon_common_openai from '@/assets/model/icon_common_openai.png'
13+
import icon_azure_openAI_colorful from '@/assets/model/icon_Azure_OpenAI_colorful.png'
1214

1315
type ModelArg = { key: string; val?: string | number; type: string; range?: string }
1416
type ModelOption = { name: string; api_domain?: string; args?: ModelArg[] }
@@ -266,7 +268,7 @@ export const supplierList: Array<{
266268
},
267269
},
268270
},
269-
{
271+
/* {
270272
id: 11,
271273
name: 'vLLM',
272274
icon: icon_vllm_colorful,
@@ -279,6 +281,64 @@ export const supplierList: Array<{
279281
model_options: [],
280282
},
281283
},
284+
}, */
285+
{
286+
id: 12,
287+
name: 'Azure OpenAI',
288+
icon: icon_azure_openAI_colorful,
289+
type: 'azure',
290+
is_private: true,
291+
model_config: {
292+
0: {
293+
api_domain: 'https://{your resource name}.openai.azure.cn/',
294+
common_args: [{ key: 'temperature', val: 0.6, type: 'number', range: '[0, 1]' }],
295+
model_options: [
296+
{
297+
name: 'Azure OpenAI',
298+
args: [
299+
{ key: 'api_version', val: '2024-02-15-preview', type: 'string' },
300+
{ key: 'deployment_name', val: '', type: 'string' },
301+
],
302+
},
303+
{
304+
name: 'gpt-4',
305+
args: [
306+
{ key: 'api_version', val: '2024-02-15-preview', type: 'string' },
307+
{ key: 'deployment_name', val: '', type: 'string' },
308+
],
309+
},
310+
],
311+
},
312+
},
313+
},
314+
{
315+
id: 15,
316+
name: '通用OpenAI',
317+
icon: icon_common_openai,
318+
is_private: true,
319+
model_config: {
320+
0: {
321+
api_domain: 'http://127.0.0.1:8000/v1',
322+
common_args: [{ key: 'temperature', val: 0.6, type: 'number', range: '[0, 1]' }],
323+
model_options: [
324+
{ name: 'gpt-4.1' },
325+
{ name: 'gpt-4.1-mini' },
326+
{ name: 'gpt-4.1-nano' },
327+
{ name: 'gpt-4o' },
328+
{ name: 'gpt-4o-mini' },
329+
{ name: 'chatgpt-4o' },
330+
{ name: 'o4-mini' },
331+
{ name: 'o4-mini-deep-research' },
332+
{ name: 'o3' },
333+
{ name: 'o3-pro' },
334+
{ name: 'o3-mini' },
335+
{ name: 'o3-deep-research' },
336+
{ name: 'o1' },
337+
{ name: 'o1-pro' },
338+
{ name: 'o1-mini' },
339+
],
340+
},
341+
},
282342
},
283343
]
284344

0 commit comments

Comments
 (0)