Commit 8604b187 authored by Wade's avatar Wade

plugins use new log lib

parent 16d5d242
{"level":"info","pid":11627,"time":1749036605,"caller":"/Users/wade/project/wuban/agentchat/log.go:69","message":"This message appears when log level set to Debug or Info"}
{"level":"info","pid":11627,"time":1749036651,"caller":"/Users/wade/project/wuban/agentchat/main.go:229","message":"input--------{\"content\":\"What is the capital of UK?\",\"model\":\"gpt-3.5-turbo\",\"apiKey\":\"sk-1234567890abcdef\",\"from\":\"Alice\",\"from_id\":\"user123\",\"to\":\"Bob\",\"to_id\":\"user456\"}"}
{"level":"info","pid":11627,"time":1749036651,"caller":"/Users/wade/project/wuban/agentchat/main.go:255","message":"qaAsJson--------{\"ID\":16,\"CreatedAt\":\"2025-06-04T09:50:02.837091Z\",\"FromID\":\"user123\",\"From\":\"Alice\",\"Question\":\"What is the capital of UK?\",\"Answer\":null,\"Summary\":null,\"To\":\"Bob\",\"ToID\":\"user4567\"}"}
{"level":"info","pid":11627,"time":1749036656,"caller":"/Users/wade/project/wuban/agentchat/main.go:281","message":"promptInput.Context: Paris is the capital of France?\nUSA is the largest importer of coffee?\n"}
{"level":"info","pid":11627,"time":1749036665,"caller":"/Users/wade/project/wuban/agentchat/main.go:294","message":"promptInput.Graph : 知识库中提供的内容不足以回答此问题\n\n<references title=\"References\" references=\"[]\" />\n"}
{"level":"info","pid":12824,"time":1749036924,"caller":"/Users/wade/project/wuban/agentchat/log.go:69","message":"This message appears when log level set to Debug or Info"}
{"level":"info","pid":12824,"time":1749036930,"caller":"/Users/wade/project/wuban/agentchat/main.go:255","message":"input--------{\"content\":\"What is the capital of UK?\",\"model\":\"gpt-3.5-turbo\",\"apiKey\":\"sk-1234567890abcdef\",\"from\":\"Alice\",\"from_id\":\"user123\",\"to\":\"Bob\",\"to_id\":\"user456\"}"}
{"level":"info","pid":12824,"time":1749036931,"caller":"/Users/wade/project/wuban/agentchat/main.go:281","message":"qaAsJson--------{\"ID\":27,\"CreatedAt\":\"2025-06-04T11:30:53.508295Z\",\"FromID\":\"user123\",\"From\":\"Alice\",\"Question\":\"What is the capital of UK?\",\"Answer\":\"Well now, if Paris is the heart of France, and the US loves its coffee, then you're probably wondering about the UK. The capital of the UK is London, a truly grand city!\\n\",\"Summary\":\"\",\"To\":\"Bob\",\"ToID\":\"user456\"}"}
{"level":"info","pid":12824,"time":1749036933,"caller":"/Users/wade/project/wuban/agentchat/main.go:307","message":"promptInput.Context: Paris is the capital of France?\nUSA is the largest importer of coffee?\n"}
{"level":"info","pid":12824,"time":1749036937,"caller":"/Users/wade/project/wuban/agentchat/main.go:320","message":"promptInput.Graph : 知识库中提供的内容不足以回答此问题\n\n<references title=\"References\" references=\"[]\" />\n"}
{"level":"info","pid":18861,"time":1749038762,"caller":"/Users/wade/project/wuban/agentchat/log.go:69","message":"This message appears when log level set to Debug or Info"}
{"level":"info","pid":18861,"method":"DeepSeek.Init","time":1749038762,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:91","message":"Initializing DeepSeek plugin"}
{"level":"info","pid":18861,"method":"DeepSeek.Init","time":1749038762,"caller":"/Users/wade/project/wuban/agentchat/plugins/deepseek/deepseek.go:104","message":"Initialization successful"}
{"level":"info","pid":18861,"method":"Milvus.Init","time":1749038762,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:75","message":"Initializing Milvus plugin"}
{"level":"info","pid":18861,"method":"Milvus.Init","time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:87","message":"Initialization successful"}
{"level":"info","pid":18861,"method":"GraphKnowledge.Init","time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:299","message":"Initializing GraphKnowledge plugin"}
{"level":"info","pid":18861,"method":"NewClient","ip":"54.92.111.204","port":5670,"time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:93","message":"Creating new GraphRAG client"}
{"level":"info","pid":18861,"method":"GraphKnowledge.Init","time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:311","message":"Initialization successful"}
{"level":"info","pid":18861,"method":"DefineIndexerAndRetriever","collection":"chatRag1","dimension":768,"time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:152","message":"Defining indexer and retriever"}
{"level":"info","pid":18861,"method":"Milvus.newDocStore","collection":"chatRag1","dimension":768,"time":1749038764,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:201","message":"Creating new doc store"}
{"level":"info","pid":18861,"method":"Milvus.newDocStore","collection":"chatRag1","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:302","message":"Doc store created successfully"}
{"level":"info","pid":18861,"method":"DefineIndexerAndRetriever","collection":"chatRag1","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:182","message":"Indexer and retriever defined successfully"}
{"level":"info","pid":18861,"method":"DefineIndexerAndRetriever","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:357","message":"Defining indexer and retriever"}
{"level":"info","pid":18861,"method":"GraphKnowledge.newDocStore","space_id":"","model_name":"Qwen/Qwen2.5-Coder-32B-Instruct","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:393","message":"Creating new doc store"}
{"level":"info","pid":18861,"method":"GraphKnowledge.newDocStore","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:399","message":"Doc store created successfully"}
{"level":"info","pid":18861,"method":"DefineIndexerAndRetriever","time":1749038765,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:376","message":"Indexer and retriever defined successfully"}
{"level":"info","pid":18861,"time":1749038774,"caller":"/Users/wade/project/wuban/agentchat/main.go:255","message":"input--------{\"content\":\"What is the capital of UK?\",\"model\":\"gpt-3.5-turbo\",\"apiKey\":\"sk-1234567890abcdef\",\"from\":\"Alice\",\"from_id\":\"user123\",\"to\":\"Bob\",\"to_id\":\"user456\"}"}
{"level":"info","pid":18861,"time":1749038774,"caller":"/Users/wade/project/wuban/agentchat/main.go:281","message":"qaAsJson--------{\"ID\":28,\"CreatedAt\":\"2025-06-04T11:35:33.142254Z\",\"FromID\":\"user123\",\"From\":\"Alice\",\"Question\":\"What is the capital of UK?\",\"Answer\":\"I'm sorry, but the provided context doesn't contain information about the capital of the UK.\\n\",\"Summary\":\"\",\"To\":\"Bob\",\"ToID\":\"user456\"}"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","collection":"chatRag1","time":1749038774,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:450","message":"Starting retrieve operation"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","collection":"chatRag1","documents":2,"time":1749038778,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:640","message":"Retrieve operation completed successfully"}
{"level":"info","pid":18861,"time":1749038778,"caller":"/Users/wade/project/wuban/agentchat/main.go:307","message":"promptInput.Context: Paris is the capital of France?\nUSA is the largest importer of coffee?\n"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","space_id":"","time":1749038778,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:755","message":"Starting retrieve operation"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","space_id":"","documents":1,"time":1749038786,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:892","message":"Retrieve operation completed successfully"}
{"level":"info","pid":18861,"time":1749038786,"caller":"/Users/wade/project/wuban/agentchat/main.go:320","message":"promptInput.Graph : 知识库中提供的内容不足以回答此问题\n\n<references title=\"References\" references=\"[]\" />\n"}
{"level":"info","pid":18861,"time":1749038813,"caller":"/Users/wade/project/wuban/agentchat/main.go:255","message":"input--------{\"content\":\"What is the capital of UK?\",\"model\":\"gpt-3.5-turbo\",\"apiKey\":\"sk-1234567890abcdef\",\"from\":\"Alice\",\"from_id\":\"user123\",\"to\":\"Bob\",\"to_id\":\"user456\"}"}
{"level":"info","pid":18861,"time":1749038814,"caller":"/Users/wade/project/wuban/agentchat/main.go:281","message":"qaAsJson--------{\"ID\":29,\"CreatedAt\":\"2025-06-04T12:06:16.535774Z\",\"FromID\":\"user123\",\"From\":\"Alice\",\"Question\":\"What is the capital of UK?\",\"Answer\":\"I'm sorry, but the provided information does not contain the answer to your question about the capital of the UK.\\n\",\"Summary\":\"\",\"To\":\"Bob\",\"ToID\":\"user456\"}"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","collection":"chatRag1","time":1749038814,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:450","message":"Starting retrieve operation"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","collection":"chatRag1","documents":2,"time":1749038815,"caller":"/Users/wade/project/wuban/agentchat/plugins/milvus/milvus.go:640","message":"Retrieve operation completed successfully"}
{"level":"info","pid":18861,"time":1749038815,"caller":"/Users/wade/project/wuban/agentchat/main.go:307","message":"promptInput.Context: Paris is the capital of France?\nUSA is the largest importer of coffee?\n"}
{"level":"info","pid":18861,"method":"docStore.Retrieve","space_id":"","time":1749038815,"caller":"/Users/wade/project/wuban/agentchat/plugins/graphrag/graph.go:755","message":"Starting retrieve operation"}
{"level":"fatal","pid":18861,"time":1749038816,"caller":"/Users/wade/project/wuban/agentchat/main.go:362","message":"Server failed: failed to shutdown server: context canceled"}
openapi: 3.0.4
info:
title: Genkit Chat API
description: API for interacting with a chat endpoint powered by Genkit.
description: API for interacting with chat and indexing endpoints powered by Genkit.
version: 0.1.0
paths:
/index/document:
......@@ -44,12 +44,13 @@ paths:
content:
application/json:
schema:
type: object
properties:
id:
type: integer
description: The ID of the stored record
example: 1
$ref: '#/components/schemas/Response'
examples:
success:
value:
data: '{"id": 1}'
code: 200
msg: "Milvus index data stored successfully"
/index/graph:
post:
summary: Store GraphRAG index data
......@@ -90,12 +91,13 @@ paths:
content:
application/json:
schema:
type: object
properties:
id:
type: integer
description: The ID of the stored record
example: 1
$ref: '#/components/schemas/Response'
examples:
success:
value:
data: '{"id": 1}'
code: 200
msg: "GraphRAG index data stored successfully"
/chat:
post:
summary: Send a chat message
......@@ -145,11 +147,31 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
examples:
success:
value:
data: "The capital of the UK is London."
code: 200
msg: "Chat response generated successfully"
components:
schemas:
Response:
type: object
properties:
response:
data:
type: string
description: The response from the chat workflow
example: "The capital of the UK is London."
components:
schemas: {}
description: The response data, typically a JSON string or message
example: '{"id": 1}'
code:
type: integer
description: The response code (200 for success, 400 for invalid input, etc.)
example: 200
msg:
type: string
description: A message describing the result
example: "Milvus index data stored successfully"
required:
- data
- code
- msg
\ No newline at end of file
......@@ -36,8 +36,8 @@ func loggingInit() {
// // Configure log rotation with lumberjack
lumberjackLogger := &lumberjack.Logger{
Filename: "/var/log/agent_chat.log",
//Filename: "./tweet.log",
//Filename: "/var/log/agent_chat.log",
Filename: "agent_chat.log",
MaxSize: 1, // Max size in megabytes before log is rotated
MaxBackups: 3, // Max number of old log files to retain
MaxAge: 28, // Max number of days to retain old log files
......
......@@ -52,8 +52,32 @@ type GraphInput struct {
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type simpleQaPromptInput struct {
Query string `json:"query"`
Context string `json:"context"`
Graph string `json:"graph"`
Summary string `json:"summary"`
}
// const simpleQaPromptTemplate = `
// You're a helpful agent that answers the user's questions with a tone and style shaped by the specified personality.
// Here is the user's query: {{query}}
// Here is the context you should use: {{context}} from Milvus
// Graph context: {{graph}}
// Previous conversation summary: {{summary}}
// Personality to adopt: {{personality}}
// Please provide a response that aligns with the given personality while leveraging the provided context, graph, and conversation summary.
// `
const simpleQaPromptTemplate = `
You're a helpful agent that answers the user's questions with a tone and style shaped by the specified personality.
You're a helpful agent that answers the user's questions based on the provided context.
Here is the user's query: {{query}}
......@@ -63,11 +87,13 @@ Graph context: {{graph}}
Previous conversation summary: {{summary}}
Personality to adopt: {{personality}}
Please provide a response that aligns with the given personality while leveraging the provided context, graph, and conversation summary.
Instructions:
- If the query is related to a character's personality, adopt the tone and style specified in the Personality context, and generate a response using the Milvus and Graph contexts to inform the personality-driven content.
- For all other queries, provide a clear and accurate response using the Milvus and Graph contexts, without emphasizing the Personality context.
- Ensure responses leverage the Previous conversation summary when relevant.
`
func main() {
debug := flag.Bool("debug", false, "sets log level to debug")
......@@ -220,7 +246,10 @@ func main() {
inputAsJson, err := json.Marshal(input)
if err != nil {
return "", err
return Response{
Code: 500,
Msg: fmt.Sprintf("json.Marshal: %w", err),
}, nil
}
log.Info().Msgf("input--------%s", string(inputAsJson))
......@@ -234,13 +263,19 @@ func main() {
})
if err != nil {
return "", err
return Response{
Code: 500,
Msg: fmt.Sprintf("WriteAndGetLatestQA: %w", err),
}, nil
}
qaAsJson, err := json.Marshal(lastQa)
if err != nil {
return "", err
return Response{
Code: 500,
Msg: fmt.Sprintf("json.Marshal(lastQa): %w", err),
}, nil
}
log.Info().Msgf("qaAsJson--------%s", string(qaAsJson))
......@@ -299,7 +334,6 @@ func main() {
return Response{
Data: resp.Text(),
Code: 200,
Msg: fmt.Sprintf("Document indexed successfully, docname %s", resDocName),
}, nil
})
......@@ -329,12 +363,6 @@ func main() {
}
}
type simpleQaPromptInput struct {
Query string `json:"query"`
Context string `json:"context"`
Graph string `json:"graph"`
Summary string `json:"summary"`
}
type Response struct {
Data string `json:"data"`
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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