@@ -312,7 +312,7 @@ func (ast *Assistant) call(ctx context.Context, method string, c *gin.Context, c
312312
313313 // Add sendMessage function to the script context
314314 scriptCtx .WithFunction ("SendMessage" , sendMessage (c , contents ))
315- scriptCtx .WithFunction ("Run" , ast .run (c , context ))
315+ scriptCtx .WithFunction ("Run" , ast .run (c , context , contents ))
316316
317317 // Check if the method exists
318318 if ! scriptCtx .Global ().Has (method ) {
@@ -328,7 +328,7 @@ func (ast *Assistant) call(ctx context.Context, method string, c *gin.Context, c
328328}
329329
330330// Execute the assistant
331- func (ast * Assistant ) run (c * gin.Context , context chatctx.Context ) func (info * v8go.FunctionCallbackInfo ) * v8go.Value {
331+ func (ast * Assistant ) run (c * gin.Context , context chatctx.Context , contents * chatMessage. Contents ) func (info * v8go.FunctionCallbackInfo ) * v8go.Value {
332332 return func (info * v8go.FunctionCallbackInfo ) * v8go.Value {
333333
334334 // Get the args
@@ -401,6 +401,7 @@ func (ast *Assistant) run(c *gin.Context, context chatctx.Context) func(info *v8
401401 return
402402 }
403403 defer ctx .Close ()
404+ ctx .WithFunction ("SendMessage" , sendMessage (c , contents ))
404405 _ , err = ctx .CallWith (context , name , cbArgs ... )
405406 if err != nil {
406407 log .Error ("Failed to call the method: %s" , err .Error ())
0 commit comments