Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(llm-sfn): log function calling jsonschema when sfn start #847

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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 @@
if functionDefinition == nil {
return nil
}
log.InfoStatusEvent(os.Stdout, "Function Calling jsonschema: %s", string(functionDefinition))

Check warning on line 258 in core/client.go

View check run for this annotation

Codecov / codecov/patch

core/client.go#L258

Added line #L258 was not covered by tests
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