feat(group-agent): 修改自然语言理解模型为自有模型
This commit is contained in:
parent
66229c8546
commit
4e08d68af8
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -19,6 +19,7 @@
|
|||||||
"langchain",
|
"langchain",
|
||||||
"langfuse",
|
"langfuse",
|
||||||
"metas",
|
"metas",
|
||||||
|
"MIAI",
|
||||||
"michat",
|
"michat",
|
||||||
"mina",
|
"mina",
|
||||||
"mindnote",
|
"mindnote",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { parseJsonString } from "@egg/hooks"
|
import { parseJsonString } from "@egg/hooks"
|
||||||
import { LarkEvent } from "@egg/lark-msg-tool"
|
import { LarkEvent } from "@egg/lark-msg-tool"
|
||||||
import logger from "@egg/logger"
|
|
||||||
|
|
||||||
import { Context, LarkServer } from "../../../types"
|
import { Context, LarkServer } from "../../../types"
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ const extractTextFromJson = (data: any): string => {
|
|||||||
* @returns 聊天消息数组
|
* @returns 聊天消息数组
|
||||||
*/
|
*/
|
||||||
const getChatHistory = async (
|
const getChatHistory = async (
|
||||||
{ larkService }: Context.Data,
|
{ larkService, logger }: Context.Data,
|
||||||
{
|
{
|
||||||
chatId,
|
chatId,
|
||||||
timeScope,
|
timeScope,
|
||||||
|
@ -18,6 +18,6 @@ const functionInfo = JSON.stringify([
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
const userInput = "方糖说了什么"
|
const userInput = "你好"
|
||||||
|
|
||||||
llm.parseGroupAgentQuery(userInput, groupInfo, functionInfo).then(console.log)
|
llm.parseGroupAgentQuery(userInput, groupInfo, functionInfo).then(console.log)
|
||||||
|
20
utils/llm.ts
20
utils/llm.ts
@ -81,7 +81,8 @@ const parseGroupAgentQuery = async (
|
|||||||
groupInfo: string,
|
groupInfo: string,
|
||||||
functionInfo: string
|
functionInfo: string
|
||||||
) => {
|
) => {
|
||||||
const model = await getModel("gpt-4o")
|
const { langfuseHandler } = await getLangfuse()
|
||||||
|
const model = await getModel("qwen-72b-instruct-int4/v1")
|
||||||
const structuredLlm = model.withStructuredOutput(groupAgentConfig, {
|
const structuredLlm = model.withStructuredOutput(groupAgentConfig, {
|
||||||
name: "groupAgent",
|
name: "groupAgent",
|
||||||
})
|
})
|
||||||
@ -91,13 +92,28 @@ const parseGroupAgentQuery = async (
|
|||||||
所有可用群组信息:${groupInfo}
|
所有可用群组信息:${groupInfo}
|
||||||
所有支持功能信息:${functionInfo}
|
所有支持功能信息:${functionInfo}
|
||||||
你是一个专业的语义解析工程师,给定以下用户输入,帮我解析出群聊ID、群聊名称、功能ID、功能名称、开始时间和结束时间。
|
你是一个专业的语义解析工程师,给定以下用户输入,帮我解析出群聊ID、群聊名称、功能ID、功能名称、开始时间和结束时间。
|
||||||
|
默认功能为总结消息,时间如果用户没有输入则留空
|
||||||
|
返回格式定义为:
|
||||||
|
\`\`\`
|
||||||
|
{
|
||||||
|
"chatId": "oc_ef98c2a9229657f99d4ef573a30fe91c",
|
||||||
|
"chatName": "MIAI-FE 人工智能部-前端组",
|
||||||
|
"functionId": "summary-qwen-72b-instruct-int4",
|
||||||
|
"functionName": "总结消息",
|
||||||
|
"startTime": "2022-01-01 00:00:00",
|
||||||
|
"endTime": "2022-01-01 23:59:59"
|
||||||
|
}
|
||||||
|
\`\`\`
|
||||||
如果不包含对应内容,请返回空值。
|
如果不包含对应内容,请返回空值。
|
||||||
|
|
||||||
用户输入:
|
用户输入:
|
||||||
\`\`\`
|
\`\`\`
|
||||||
${userInput.replaceAll("`", " ")}
|
${userInput.replaceAll("`", " ")}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`
|
`,
|
||||||
|
{
|
||||||
|
callbacks: [langfuseHandler],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user