Skip to content

Commit

Permalink
feat(llm-sfn): log function calling jsonschema when sfn start (#847)
Browse files Browse the repository at this point in the history
Co-authored-by: venjiang <[email protected]>
Co-authored-by: C.C <[email protected]>
  • Loading branch information
3 people committed Jul 2, 2024
1 parent 408ba70 commit 292a148
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
},
}

Expand Down
8 changes: 4 additions & 4 deletions cli/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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, "Building 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...")
Expand Down
8 changes: 4 additions & 4 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, "Building 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
Expand All @@ -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...")
Expand Down
2 changes: 2 additions & 0 deletions core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -254,6 +255,7 @@ func (c *Client) handshakeWithDefinition(hf *frame.HandshakeFrame) error {
if functionDefinition == nil {
return nil
}
log.InfoStatusEvent(os.Stdout, "Function Calling jsonschema: %s", string(functionDefinition))
hf.FunctionDefinition = functionDefinition
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...))
}
}

Expand All @@ -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...))
}
}

Expand Down

0 comments on commit 292a148

Please sign in to comment.