Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
agentchat
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟@五瓣科技
agentchat
Commits
e1fb0284
Commit
e1fb0284
authored
Jun 07, 2025
by
Wade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split flow
parent
a0086259
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
13 deletions
+98
-13
agent_chat.log
agent_chat.log
+42
-0
swagger.yaml
docs/swagger.yaml
+1
-1
main.go
main.go
+55
-12
No files found.
agent_chat.log
0 → 100644
View file @
e1fb0284
This diff is collapsed.
Click to expand it.
docs/swagger.yaml
View file @
e1fb0284
...
@@ -169,7 +169,7 @@ paths:
...
@@ -169,7 +169,7 @@ paths:
model
:
model
:
type
:
string
type
:
string
description
:
The model to use for the chat response
description
:
The model to use for the chat response
example
:
"
gpt-3.5-turbo
"
example
:
"
deepseek/deepseek-chat
"
apiKey
:
apiKey
:
type
:
string
type
:
string
description
:
The API key for authentication
description
:
The API key for authentication
...
...
main.go
View file @
e1fb0284
...
@@ -243,18 +243,6 @@ func main() {
...
@@ -243,18 +243,6 @@ func main() {
},
nil
},
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
)
qa
,
err
:=
question
.
InitQAStore
(
*
pgConnString
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
()
.
Msgf
(
"InitQAStore failed: %v"
,
err
)
log
.
Fatal
()
.
Msgf
(
"InitQAStore failed: %v"
,
err
)
...
@@ -361,6 +349,15 @@ func main() {
...
@@ -361,6 +349,15 @@ func main() {
fmt
.
Println
(
"graph time"
,
time
.
Since
(
begin
)
.
Seconds
())
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
))
resp
,
err
:=
simpleQaPrompt
.
Execute
(
ctx
,
ai
.
WithInput
(
promptInput
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -448,3 +445,49 @@ type Response struct {
...
@@ -448,3 +445,49 @@ type Response struct {
Code
int
`json:"code"`
Code
int
`json:"code"`
Msg
string
`json:"msg"`
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment