Merge pull request #872 from trheyi/main
Rename Context to GinContext in GlobalVariables struct
This commit is contained in:
commit
f18c4c94cc
1 changed files with 7 additions and 7 deletions
|
|
@ -23,7 +23,7 @@ import (
|
||||||
type GlobalVariables struct {
|
type GlobalVariables struct {
|
||||||
Assistant *Assistant
|
Assistant *Assistant
|
||||||
Contents *chatMessage.Contents
|
Contents *chatMessage.Contents
|
||||||
Context *gin.Context
|
GinContext *gin.Context
|
||||||
ChatContext chatctx.Context
|
ChatContext chatctx.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ func (ast *Assistant) InitObject(v8ctx *v8.Context, c *gin.Context, context chat
|
||||||
v8ctx.WithGlobal("__yao_agent_global", &GlobalVariables{
|
v8ctx.WithGlobal("__yao_agent_global", &GlobalVariables{
|
||||||
Assistant: ast,
|
Assistant: ast,
|
||||||
Contents: contents,
|
Contents: contents,
|
||||||
Context: c,
|
GinContext: c,
|
||||||
ChatContext: context,
|
ChatContext: context,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ func jsSend(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
||||||
if saveHistory {
|
if saveHistory {
|
||||||
msg.AppendTo(global.Contents)
|
msg.AppendTo(global.Contents)
|
||||||
}
|
}
|
||||||
msg.Write(global.Context.Writer)
|
msg.Write(global.GinContext.Writer)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
|
|
@ -97,7 +97,7 @@ func jsSend(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
||||||
if saveHistory {
|
if saveHistory {
|
||||||
msg.AppendTo(global.Contents)
|
msg.AppendTo(global.Contents)
|
||||||
}
|
}
|
||||||
msg.Write(global.Context.Writer)
|
msg.Write(global.GinContext.Writer)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -180,7 +180,7 @@ func jsCall(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
||||||
}
|
}
|
||||||
defer ctx.Close()
|
defer ctx.Close()
|
||||||
|
|
||||||
global.Assistant.InitObject(ctx, global.Context, chatContext, global.Contents)
|
global.Assistant.InitObject(ctx, global.GinContext, chatContext, global.Contents)
|
||||||
_, err = ctx.CallAnonymousWith(context.Background(), source, cbArgs...)
|
_, err = ctx.CallAnonymousWith(context.Background(), source, cbArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to call the method: %s", err.Error())
|
log.Error("Failed to call the method: %s", err.Error())
|
||||||
|
|
@ -223,7 +223,7 @@ func jsCall(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
||||||
}
|
}
|
||||||
defer ctx.Close()
|
defer ctx.Close()
|
||||||
|
|
||||||
global.Assistant.InitObject(ctx, global.Context, global.ChatContext, global.Contents)
|
global.Assistant.InitObject(ctx, global.GinContext, global.ChatContext, global.Contents)
|
||||||
_, err = ctx.CallWith(context.Background(), name, cbArgs...)
|
_, err = ctx.CallWith(context.Background(), name, cbArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to call the method: %s", err.Error())
|
log.Error("Failed to call the method: %s", err.Error())
|
||||||
|
|
@ -259,7 +259,7 @@ func jsCall(info *v8go.FunctionCallbackInfo) *v8go.Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = newAst.Execute(global.Context, chatContext, input, options, cb) // Execute the assistant
|
err = newAst.Execute(global.GinContext, chatContext, input, options, cb) // Execute the assistant
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bridge.JsException(info.Context(), err.Error())
|
return bridge.JsException(info.Context(), err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue