Fix assistant context switching and ID handling
- Prevent switching to an empty assistant ID - Update context assistant ID during execution - Ensure proper assistant context management in chat flow
This commit is contained in:
parent
ccb1c54927
commit
dc6967805e
1 changed files with 3 additions and 1 deletions
|
|
@ -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":
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue