mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-12 17:42:48 +00:00
Supports online search for the Qwen series models.
This commit is contained in:
parent
367e4caef0
commit
79787e8246
|
@ -19,3 +19,7 @@ OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxx
|
||||||
# 第三方 TTS(可选,用于调用第三方 TTS 服务)
|
# 第三方 TTS(可选,用于调用第三方 TTS 服务)
|
||||||
# TTS_BASE_URL=http://[你的局域网或公网地址]:[端口号]/[SECRET_PATH]/api
|
# TTS_BASE_URL=http://[你的局域网或公网地址]:[端口号]/[SECRET_PATH]/api
|
||||||
# 比如:http://192.168.31.205:4321/xxxx/api(注意:不要使用 localhost 或 127.0.0.1)
|
# 比如:http://192.168.31.205:4321/xxxx/api(注意:不要使用 localhost 或 127.0.0.1)
|
||||||
|
|
||||||
|
# 通义千问模型在生成文本时是否使用互联网搜索结果进行参考
|
||||||
|
# qwen-vl系列、qwen开源系列与qwen-long模型暂时不支持配置该参数
|
||||||
|
# QWEN_ENABLE_SEARCH=true
|
|
@ -19,6 +19,7 @@ export interface ChatOptions {
|
||||||
jsonMode?: boolean;
|
jsonMode?: boolean;
|
||||||
requestId?: string;
|
requestId?: string;
|
||||||
trace?: boolean;
|
trace?: boolean;
|
||||||
|
enableSearch?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OpenAIClient {
|
class OpenAIClient {
|
||||||
|
@ -115,6 +116,7 @@ class OpenAIClient {
|
||||||
onStream,
|
onStream,
|
||||||
trace = false,
|
trace = false,
|
||||||
model = this.deployment ?? kEnvs.OPENAI_MODEL ?? "gpt-4o",
|
model = this.deployment ?? kEnvs.OPENAI_MODEL ?? "gpt-4o",
|
||||||
|
enableSearch = kEnvs.QWEN_ENABLE_SEARCH,
|
||||||
} = options;
|
} = options;
|
||||||
if (trace && this.traceInput) {
|
if (trace && this.traceInput) {
|
||||||
this._logger.log(
|
this._logger.log(
|
||||||
|
@ -130,6 +132,7 @@ class OpenAIClient {
|
||||||
stream: true,
|
stream: true,
|
||||||
messages: [...systemMsg, { role: "user", content: user }],
|
messages: [...systemMsg, { role: "user", content: user }],
|
||||||
response_format: jsonMode ? { type: "json_object" } : undefined,
|
response_format: jsonMode ? { type: "json_object" } : undefined,
|
||||||
|
...(enableSearch && { enable_search: true })
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
this._logger.error("LLM 响应异常", e);
|
this._logger.error("LLM 响应异常", e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,4 +6,8 @@ export const kEnvs: Partial<{
|
||||||
OPENAI_API_KEY: string;
|
OPENAI_API_KEY: string;
|
||||||
AZURE_OPENAI_API_KEY: string;
|
AZURE_OPENAI_API_KEY: string;
|
||||||
AZURE_OPENAI_DEPLOYMENT: string;
|
AZURE_OPENAI_DEPLOYMENT: string;
|
||||||
}> = process.env as any;
|
QWEN_ENABLE_SEARCH: boolean;
|
||||||
|
}> = {
|
||||||
|
...process.env,
|
||||||
|
QWEN_ENABLE_SEARCH: process.env.QWEN_ENABLE_SEARCH === 'true'
|
||||||
|
} as any;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user