From 205720aeb3833a5edf10cc26d9c0d26740d11372 Mon Sep 17 00:00:00 2001 From: woorui Date: Tue, 25 Jun 2024 22:34:51 +0800 Subject: [PATCH 1/4] feat: log when register function definition --- core/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/client.go b/core/client.go index 5f63781e4..2e086edd3 100644 --- a/core/client.go +++ b/core/client.go @@ -254,6 +254,7 @@ func (c *Client) handshakeWithDefinition(hf *frame.HandshakeFrame) error { if functionDefinition == nil { return nil } + c.Logger.Info("register function definition", "functionDefinition", string(functionDefinition)) hf.FunctionDefinition = functionDefinition return nil } From c087b42648831204d63bbdb797e8a7006bf86d5b Mon Sep 17 00:00:00 2001 From: wurui Date: Thu, 27 Jun 2024 15:10:08 +0800 Subject: [PATCH 2/4] Update core/client.go Co-authored-by: venjiang --- core/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/client.go b/core/client.go index 2e086edd3..6c380eed5 100644 --- a/core/client.go +++ b/core/client.go @@ -254,7 +254,7 @@ func (c *Client) handshakeWithDefinition(hf *frame.HandshakeFrame) error { if functionDefinition == nil { return nil } - c.Logger.Info("register function definition", "functionDefinition", string(functionDefinition)) + c.Logger.Info("register function definition", "function_definition", string(functionDefinition)) hf.FunctionDefinition = functionDefinition return nil } From bcaf84a03043ccf5154d8df2f35c84b4d3149667 Mon Sep 17 00:00:00 2001 From: "C.C" Date: Mon, 1 Jul 2024 10:31:45 +0800 Subject: [PATCH 3/4] improve output --- cli/build.go | 4 ++-- cli/dev.go | 8 ++++---- cli/run.go | 8 ++++---- core/client.go | 7 ++++++- pkg/log/log.go | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cli/build.go b/cli/build.go index c78d23082..4e2678f8e 100644 --- a/cli/build.go +++ b/cli/build.go @@ -47,13 +47,13 @@ var buildCmd = &cobra.Command{ } log.InfoStatusEvent(os.Stdout, "YoMo Stream Function parse done.") // build - log.PendingStatusEvent(os.Stdout, "YoMo Stream Function building...") + log.PendingStatusEvent(os.Stdout, "Building YoMo Stream Function instance...") if err := s.Build(true); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(127) // return } - log.SuccessStatusEvent(os.Stdout, "Success! YoMo Stream Function build.") + log.SuccessStatusEvent(os.Stdout, "YoMo Stream Function build successful!") }, } diff --git a/cli/dev.go b/cli/dev.go index b8a72e8af..7d72f5e35 100644 --- a/cli/dev.go +++ b/cli/dev.go @@ -40,7 +40,7 @@ var devCmd = &cobra.Command{ // Serverless log.InfoStatusEvent(os.Stdout, "YoMo Stream Function file: %v", opts.Filename) // resolve serverless - log.PendingStatusEvent(os.Stdout, "Create YoMo Stream Function instance...") + log.PendingStatusEvent(os.Stdout, "Creating YoMo Stream Function instance...") // Connect the serverless to YoMo dev-server, it will automatically emit the mock data. opts.Name = "yomo-app-demo" @@ -66,17 +66,17 @@ var devCmd = &cobra.Command{ } // build if it's go file if ext := filepath.Ext(opts.Filename); ext == ".go" { - log.PendingStatusEvent(os.Stdout, "YoMo Stream Function building...") + log.PendingStatusEvent(os.Stdout, "Bingding YoMo Stream Function instance...") if err := s.Build(true); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(127) } - log.SuccessStatusEvent(os.Stdout, "Success! YoMo Stream Function build.") + log.SuccessStatusEvent(os.Stdout, "YoMo Stream Function build successful!") } // run log.InfoStatusEvent( os.Stdout, - "Starting YoMo Stream Function instance with zipper: %v", + "Starting YoMo Stream Function instance, connecting to zipper: %v", opts.ZipperAddr, ) log.InfoStatusEvent(os.Stdout, "Stream Function is running...") diff --git a/cli/run.go b/cli/run.go index 98841fd69..f34ec4fb3 100644 --- a/cli/run.go +++ b/cli/run.go @@ -49,7 +49,7 @@ var runCmd = &cobra.Command{ return } // resolve serverless - log.PendingStatusEvent(os.Stdout, "Create YoMo Stream Function instance...") + log.PendingStatusEvent(os.Stdout, "Creating YoMo Stream Function instance...") if err := parseZipperAddr(&opts); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) return @@ -70,12 +70,12 @@ var runCmd = &cobra.Command{ } // build if it's go file if ext := filepath.Ext(opts.Filename); ext == ".go" { - log.PendingStatusEvent(os.Stdout, "YoMo Stream Function building...") + log.PendingStatusEvent(os.Stdout, "Bingding YoMo Stream Function instance...") if err := s.Build(true); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(127) } - log.SuccessStatusEvent(os.Stdout, "Success! YoMo Stream Function build.") + log.SuccessStatusEvent(os.Stdout, "YoMo Stream Function build successful!") } // run // wasi @@ -88,7 +88,7 @@ var runCmd = &cobra.Command{ } log.InfoStatusEvent( os.Stdout, - "Starting YoMo Stream Function instance with zipper: %v", + "Starting YoMo Stream Function instance, connecting to zipper: %v", opts.ZipperAddr, ) log.InfoStatusEvent(os.Stdout, "Stream Function is running...") diff --git a/core/client.go b/core/client.go index 6c380eed5..39e6ac7d3 100644 --- a/core/client.go +++ b/core/client.go @@ -19,6 +19,7 @@ import ( "github.com/yomorun/yomo/pkg/frame-codec/y3codec" "github.com/yomorun/yomo/pkg/id" yquic "github.com/yomorun/yomo/pkg/listener/quic" + "github.com/yomorun/yomo/pkg/log" ) // Client is the abstraction of a YoMo-Client. a YoMo-Client can be @@ -254,7 +255,11 @@ func (c *Client) handshakeWithDefinition(hf *frame.HandshakeFrame) error { if functionDefinition == nil { return nil } - c.Logger.Info("register function definition", "function_definition", string(functionDefinition)) + // c.Logger.Info("register function definition", "function_definition", string(functionDefinition)) + log.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Register LLM Function Calling: [%s]", c.name)) + // log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Name: %s", c.name)) + log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Description: %s", c.opts.aiFunctionDescription)) + log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Arguments Struct: %v", c.opts.aiFunctionInputModel)) hf.FunctionDefinition = functionDefinition return nil } diff --git a/pkg/log/log.go b/pkg/log/log.go index be6ae545c..0dd4f9d34 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -74,7 +74,7 @@ func WarningStatusEvent(w io.Writer, fmtstr string, a ...interface{}) { } else if runtime.GOOS == windowsOS { fmt.Fprintf(w, "%s\n", fmt.Sprintf(fmtstr, a...)) } else { - fmt.Fprintf(w, "⚠️⚠ %s\n", fmt.Sprintf(fmtstr, a...)) + fmt.Fprintf(w, "⚠️ %s\n", fmt.Sprintf(fmtstr, a...)) } } @@ -96,7 +96,7 @@ func InfoStatusEvent(w io.Writer, fmtstr string, a ...interface{}) { } else if runtime.GOOS == windowsOS { fmt.Fprintf(w, "%s\n", fmt.Sprintf(fmtstr, a...)) } else { - fmt.Fprintf(w, "ℹ️ %s\n", fmt.Sprintf(fmtstr, a...)) + fmt.Fprintf(w, "ℹ️ %s\n", fmt.Sprintf(fmtstr, a...)) } } From 73bfdbaec429ac1ff642782fbb5963da30fefd4a Mon Sep 17 00:00:00 2001 From: "C.C" Date: Tue, 2 Jul 2024 17:33:58 +0800 Subject: [PATCH 4/4] update output to jsonschema string --- cli/dev.go | 2 +- cli/run.go | 2 +- core/client.go | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cli/dev.go b/cli/dev.go index 7d72f5e35..6bbfaf2f4 100644 --- a/cli/dev.go +++ b/cli/dev.go @@ -66,7 +66,7 @@ var devCmd = &cobra.Command{ } // build if it's go file if ext := filepath.Ext(opts.Filename); ext == ".go" { - log.PendingStatusEvent(os.Stdout, "Bingding YoMo Stream Function instance...") + log.PendingStatusEvent(os.Stdout, "Building YoMo Stream Function instance...") if err := s.Build(true); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(127) diff --git a/cli/run.go b/cli/run.go index f34ec4fb3..032862787 100644 --- a/cli/run.go +++ b/cli/run.go @@ -70,7 +70,7 @@ var runCmd = &cobra.Command{ } // build if it's go file if ext := filepath.Ext(opts.Filename); ext == ".go" { - log.PendingStatusEvent(os.Stdout, "Bingding YoMo Stream Function instance...") + log.PendingStatusEvent(os.Stdout, "Building YoMo Stream Function instance...") if err := s.Build(true); err != nil { log.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(127) diff --git a/core/client.go b/core/client.go index 39e6ac7d3..e8f5cb5e0 100644 --- a/core/client.go +++ b/core/client.go @@ -255,11 +255,7 @@ func (c *Client) handshakeWithDefinition(hf *frame.HandshakeFrame) error { if functionDefinition == nil { return nil } - // c.Logger.Info("register function definition", "function_definition", string(functionDefinition)) - log.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Register LLM Function Calling: [%s]", c.name)) - // log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Name: %s", c.name)) - log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Description: %s", c.opts.aiFunctionDescription)) - log.InfoStatusEvent(os.Stdout, fmt.Sprintf("-> Arguments Struct: %v", c.opts.aiFunctionInputModel)) + log.InfoStatusEvent(os.Stdout, "Function Calling jsonschema: %s", string(functionDefinition)) hf.FunctionDefinition = functionDefinition return nil }