diff --git a/examples/sentiment/go.mod b/examples/sentiment/go.mod index 5f1fbb1..8e28665 100644 --- a/examples/sentiment/go.mod +++ b/examples/sentiment/go.mod @@ -4,6 +4,4 @@ go 1.20 require github.com/maiqingqiang/typechat-go v1.0.0 -require golang.org/x/text v0.12.0 // indirect - replace github.com/maiqingqiang/typechat-go => ../../ diff --git a/examples/sentiment/go.sum b/examples/sentiment/go.sum index 09c64a2..e69de29 100644 --- a/examples/sentiment/go.sum +++ b/examples/sentiment/go.sum @@ -1,2 +0,0 @@ -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/examples/sentiment/run.png b/examples/sentiment/run.png index e829e80..5022a34 100644 Binary files a/examples/sentiment/run.png and b/examples/sentiment/run.png differ diff --git a/examples/sentiment/sentiment_schema.go b/examples/sentiment/sentiment_schema.go index bdbea86..8f2723a 100644 --- a/examples/sentiment/sentiment_schema.go +++ b/examples/sentiment/sentiment_schema.go @@ -1,15 +1,20 @@ +// The following is a schema definition for determining the sentiment of a some user input. + package main import "fmt" +// Sentiment Define the enum type, this value is int type Sentiment int +// Define the enum constants for Sentiment const ( Negative Sentiment = iota Neutral Positive ) +// Use switch statement to handle the enum type for Sentiment func (s Sentiment) String() string { switch s { case Negative: @@ -24,7 +29,7 @@ func (s Sentiment) String() string { } type SentimentResponse struct { - Sentiment int `json:"sentiment"` + Sentiment Sentiment `json:"sentiment"` // The sentiment of the Sentiment enum type } func (s SentimentResponse) String() string {