Merge pull request #861 from trheyi/main

Fix assistant context switching and ID handling
This commit is contained in:
Max 2025-02-09 18:35:32 +08:00 committed by GitHub
commit 12e15e6bc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -95,7 +95,7 @@ func (ast *Assistant) execute(c *gin.Context, ctx chatctx.Context, input []chatM
// } // }
// Switch to the new assistant if necessary // Switch to the new assistant if necessary
if res != nil && res.AssistantID != ctx.AssistantID { if res != nil && res.AssistantID != "" && res.AssistantID != ctx.AssistantID {
newAst, err := Get(res.AssistantID) newAst, err := Get(res.AssistantID)
if err != nil { if err != nil {
chatMessage.New(). chatMessage.New().
@ -244,6 +244,8 @@ func (next *NextAction) Execute(c *gin.Context, ctx chatctx.Context, contents *c
msg.Write(c.Writer) msg.Write(c.Writer)
newContents := chatMessage.NewContents() newContents := chatMessage.NewContents()
// Update the context id
ctx.AssistantID = assistant.ID
return assistant.execute(c, ctx, messages, options, newContents) return assistant.execute(c, ctx, messages, options, newContents)
case "exit": case "exit":

View file

@ -568,8 +568,7 @@ func processXgen(process *process.Process) interface{} {
// The default assistant // The default assistant
agent := map[string]interface{}{} agent := map[string]interface{}{}
if neo.Neo != nil { if neo.Neo != nil {
ast := neo.Neo.Assistant.(*assistant.Assistant) if ast, ok := neo.Neo.Assistant.(*assistant.Assistant); ok {
if ast != nil {
agent["default"] = map[string]interface{}{ agent["default"] = map[string]interface{}{
"assistant_id": ast.ID, "assistant_id": ast.ID,
"assistant_name": ast.Name, "assistant_name": ast.Name,