Commit e1fb0284 authored by Wade's avatar Wade

split flow

parent a0086259
{"level":"info","pid":7027,"time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/log.go:68","message":"This message appears when log level set to Debug or Info"}
{"level":"info","pid":7027,"method":"DeepSeek.Init","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:94","message":"Initializing DeepSeek plugin"}
{"level":"info","pid":7027,"method":"DeepSeek.DefineModel","model_name":"deepseek-chat","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:128","message":"Defining DeepSeek model"}
{"level":"info","pid":7027,"method":"Deep lantern","model_name":"deepseek-chat","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:158","message":"Model defined successfully"}
{"level":"info","pid":7027,"method":"DeepSeek.DefineModel","model_name":"deepseek-coder","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:128","message":"Defining DeepSeek model"}
{"level":"info","pid":7027,"method":"Deep lantern","model_name":"deepseek-coder","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:158","message":"Model defined successfully"}
{"level":"info","pid":7027,"method":"DeepSeek.DefineModel","model_name":"deepseek-reasoner","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:128","message":"Defining DeepSeek model"}
{"level":"info","pid":7027,"method":"Deep lantern","model_name":"deepseek-reasoner","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:158","message":"Model defined successfully"}
{"level":"info","pid":7027,"method":"DeepSeek.Init","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:119","message":"Initialization successful"}
{"level":"info","pid":7027,"method":"Milvus.Init","time":1749267392,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:75","message":"Initializing Milvus plugin"}
{"level":"info","pid":7027,"method":"Milvus.Init","time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:87","message":"Initialization successful"}
{"level":"info","pid":7027,"method":"GraphKnowledge.Init","time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:299","message":"Initializing GraphKnowledge plugin"}
{"level":"info","pid":7027,"method":"NewClient","ip":"54.92.111.204","port":5670,"time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:93","message":"Creating new GraphRAG client"}
{"level":"info","pid":7027,"method":"GraphKnowledge.Init","time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:311","message":"Initialization successful"}
{"level":"info","pid":7027,"method":"DefineIndexerAndRetriever","collection":"chatRag1","dimension":768,"time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:152","message":"Defining indexer and retriever"}
{"level":"info","pid":7027,"method":"Milvus.newDocStore","collection":"chatRag1","dimension":768,"time":1749267393,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:201","message":"Creating new doc store"}
{"level":"info","pid":7027,"method":"Milvus.newDocStore","collection":"chatRag1","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:302","message":"Doc store created successfully"}
{"level":"info","pid":7027,"method":"DefineIndexerAndRetriever","collection":"chatRag1","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:182","message":"Indexer and retriever defined successfully"}
{"level":"info","pid":7027,"method":"DefineIndexerAndRetriever","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:357","message":"Defining indexer and retriever"}
{"level":"info","pid":7027,"method":"GraphKnowledge.newDocStore","space_id":"","model_name":"Qwen/Qwen2.5-Coder-32B-Instruct","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:393","message":"Creating new doc store"}
{"level":"info","pid":7027,"method":"GraphKnowledge.newDocStore","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:399","message":"Doc store created successfully"}
{"level":"info","pid":7027,"method":"DefineIndexerAndRetriever","time":1749267394,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:376","message":"Indexer and retriever defined successfully"}
{"level":"info","pid":7027,"method":"NewKnowledgeClient","endpoint":"lkeap.tencentcloudapi.com","region":"ap-guangzhou","secret_id":"","token":"","time":1749267395,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:43","message":"Creating new KnowledgeClient"}
{"level":"info","pid":7027,"method":"KnowledgeClient.Init","time":1749267395,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:51","message":"Initializing KnowledgeClient"}
{"level":"info","pid":7027,"method":"KnowledgeClient.Init","time":1749267395,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:109","message":"Initialization successful"}
{"level":"info","pid":7027,"time":1749267395,"caller":"/Users/wade/project/wuban/agentchat/main.go:271","message":"KnowledgeClient initialized successfully"}
{"level":"info","pid":7027,"time":1749267425,"caller":"/Users/wade/project/wuban/agentchat/main.go:279","message":"input----ctxAsJson----{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{\"Context\":{}}}}}}}}}}}}}}}}}}}}}}}"}
{"level":"info","pid":7027,"time":1749267425,"caller":"/Users/wade/project/wuban/agentchat/main.go:290","message":"input--------{\"content\":\"What is the capital of UK?\",\"from\":\"Alice\",\"from_id\":\"user123\",\"to\":\"string\",\"to_id\":\"user456\",\"model\":\"gpt-3.5-turbo\",\"apiKey\":\"sk-1234567890abcdef\",\"milvus\":true}"}
{"level":"info","pid":7027,"time":1749267426,"caller":"/Users/wade/project/wuban/agentchat/main.go:318","message":"qaAsJson--------{\"ID\":56,\"CreatedAt\":\"2025-06-07T03:34:27.994203Z\",\"FromID\":\"user123\",\"From\":\"Alice\",\"Question\":\"What is the capital of UK?\",\"Answer\":\"The provided context does not include information about the capital of the UK. However, the capital of the UK is London. \\n\\nLet me know if you'd like further details! \\n\\n\\u003creferences title=\\\"References\\\" references=\\\"[]\\\" /\\u003e\",\"Summary\":\"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.\",\"To\":\"string\",\"ToID\":\"user456\",\"Milvus\":true,\"Graph\":false}"}
{"level":"info","pid":7027,"method":"docStore.Retrieve","collection":"chatRag1","time":1749267426,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:450","message":"Starting retrieve operation"}
{"level":"info","pid":7027,"method":"docStore.Retrieve","collection":"chatRag1","documents":2,"time":1749267429,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:640","message":"Retrieve operation completed successfully"}
{"level":"info","pid":7027,"time":1749267429,"caller":"/Users/wade/project/wuban/agentchat/main.go:344","message":"promptInput.Context: Paris is the capital of France?\nUSA is the largest importer of coffee?\n"}
{"level":"info","pid":7027,"method":"docStore.Retrieve","space_id":"","time":1749267429,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:755","message":"Starting retrieve operation"}
{"level":"info","pid":7027,"method":"docStore.Retrieve","space_id":"","documents":1,"time":1749267435,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:892","message":"Retrieve operation completed successfully"}
{"level":"info","pid":7027,"time":1749267435,"caller":"/Users/wade/project/wuban/agentchat/main.go:359","message":"promptInput.Graph : 知识库中提供的内容不足以回答此问题\n\n<references title=\"References\" references=\"[]\" />\n"}
{"level":"info","pid":7027,"method":"generator.generate","model_name":"deepseek-chat","messages":1,"time":1749267435,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:174","message":"Starting model generation"}
{"level":"info","pid":7027,"method":"generator.generate","model_name":"deepseek-chat","content_parts":1,"time":1749267441,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:252","message":"Model generation completed successfully"}
{"level":"info","pid":7027,"from":"Alice","from_id":"user123","to":"string","to_id":"user456","promptInput.Query":"What is the capital of UK?","resp.Text()":"The provided context does not include information about the capital of the UK. However, the capital of the UK is London. \n\nLet me know if you'd like further details! \n\n<references title=\"References\" references=\"[]\" />","promptInput.Summary":"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.","time":1749267441,"caller":"/Users/wade/project/wuban/agentchat/main.go:386","message":"QueryRewriteWithSummary"}
{"level":"info","pid":7027,"method":"KnowledgeClient.QueryRewriteWithSummary","user_question":"What is the capital of UK?","assistant_answer":"The provided context does not include information about the capital of the UK. However, the capital of the UK is London. \n\nLet me know if you'd like further details! \n\n<references title=\"References\" references=\"[]\" />","history_summary":"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.","time":1749267441,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:256","message":"Starting query rewrite with summary operation"}
{"level":"info","pid":7027,"method":"KnowledgeClient.QueryRewrite","message_count":3,"model":"lke-query-rewrite-base","time":1749267441,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:131","message":"Starting query rewrite operation"}
{"level":"info","pid":7027,"method":"KnowledgeClient.QueryRewrite","rewritten_query":"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.","request_id":"4efbb8d7-16fd-4de8-ad0c-e8b2befa4770","usage":{"InputTokens":131,"OutputTokens":45,"TotalTokens":176},"raw_response":"{\"Response\":{\"Content\":\"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.\",\"Usage\":{\"InputTokens\":131,\"OutputTokens\":45,\"TotalTokens\":176},\"RequestId\":\"4efbb8d7-16fd-4de8-ad0c-e8b2befa4770\"}}","time":1749267444,"caller":"/Users/wade/project/wuban/agentchat/plugins/knowledge/knowledge.go:237","message":"Query rewrite operation completed successfully"}
{"level":"info","pid":7027,"from":"Alice","from_id":"user123","to":"string","to_id":"user456","question":"What is the capital of UK?","context":"Paris is the capital of France?\nUSA is the largest importer of coffee?\n","graph":"知识库中提供的内容不足以回答此问题\n\n<references title=\"References\" references=\"[]\" />\n","last summary":"Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: Conversation summary: I am sorry, but the provided context does not contain the answer to your question about the capital of the UK.","answer":"The provided context does not include information about the capital of the UK. However, the capital of the UK is London. \n\nLet me know if you'd like further details! \n\n<references title=\"References\" references=\"[]\" />","time":1749267444,"caller":"/Users/wade/project/wuban/agentchat/main.go:412","message":"Question and answer pair recorded"}
......@@ -169,7 +169,7 @@ paths:
model:
type: string
description: The model to use for the chat response
example: "gpt-3.5-turbo"
example: "deepseek/deepseek-chat"
apiKey:
type: string
description: The API key for authentication
......
......@@ -243,18 +243,6 @@ func main() {
}, nil
})
simpleQaPrompt, err := genkit.DefinePrompt(g, "simpleQaPrompt",
// ai.WithModelName("googleai/gemini-2.0-flash"),
// deepseek
ai.WithModelName("deepseek/deepseek-chat"),
ai.WithPrompt(simpleQaPromptTemplate),
ai.WithInputType(simpleQaPromptInput{}),
ai.WithOutputFormat(ai.OutputFormatText),
)
if err != nil {
log.Fatal().Msg(err.Error())
}
qa, err := question.InitQAStore(*pgConnString)
if err != nil {
log.Fatal().Msgf("InitQAStore failed: %v", err)
......@@ -361,6 +349,15 @@ func main() {
fmt.Println("graph time", time.Since(begin).Seconds())
simpleQaPrompt,err := defineSimpleQaPrompt(g,input.Model)
if err != nil {
return Response{
Code: 500,
Msg: fmt.Sprintf("index document: %w", err),
}, nil
}
resp, err := simpleQaPrompt.Execute(ctx, ai.WithInput(promptInput))
if err != nil {
......@@ -448,3 +445,49 @@ type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
// defineSimpleQaPrompt 加载或定义指定名称的 Prompt
func defineSimpleQaPrompt(g *genkit.Genkit, promptName string) (*ai.Prompt, error) {
// 步骤 1:尝试查找现有的 Prompt
log.Info().
Str("method", "defineSimpleQaPrompt").
Str("prompt_name", promptName).
Msg("Attempting to lookup prompt")
prompt := genkit.LookupPrompt(g, promptName)
if prompt != nil {
log.Info().
Str("method", "defineSimpleQaPrompt").
Str("prompt_name", promptName).
Msg("Prompt found and loaded")
return prompt, nil
}
log.Info().
Str("method", "defineSimpleQaPrompt").
Str("prompt_name", promptName).
Msg("Prompt not found, defining new prompt")
// 步骤 2:如果未找到,定义新的 Prompt
simpleQaPrompt, err := genkit.DefinePrompt(g, promptName,
// ai.WithModelName("deepseek/deepseek-chat"),
ai.WithModelName(promptName),
ai.WithPrompt(simpleQaPromptTemplate),
ai.WithInputType(simpleQaPromptInput{}),
ai.WithOutputFormat(ai.OutputFormatText),
)
if err != nil {
log.Error().
Str("method", "defineSimpleQaPrompt").
Str("prompt_name", promptName).
Err(err).
Msg("Failed to define prompt")
return nil, err
}
log.Info().
Str("method", "defineSimpleQaPrompt").
Str("prompt_name", promptName).
Msg("Prompt defined successfully")
return simpleQaPrompt, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment