feat: initialize Eino examples and ADK applications
Include chat, weather, image, travel, streaming ASR and text examples, shared model initialization, documentation, and existing tests. Co-authored-by: TRAE CLI <traecli@bytedance.com>
This commit is contained in:
commit
81deca8c8e
75 files changed
+7048
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"example.com/ueino/pkg/model"
|
||||
"github.com/cloudwego/eino/adk"
|
||||
)
|
||||
|
||||
// travelProgress 是流程中的用户可见正文,不是内部日志。
|
||||
type travelProgress string
|
||||
|
||||
func emitTravelText(ctx context.Context, text string) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
return adk.SendEvent(ctx, &adk.AgentEvent{
|
||||
Output: &adk.AgentOutput{CustomizedOutput: travelProgress(text)},
|
||||
})
|
||||
}
|
||||
|
||||
func travelWeatherText(weather model.WeatherForecast) string {
|
||||
var text strings.Builder
|
||||
fmt.Fprintf(&text, "查到%s的天气:\n", weather.Location)
|
||||
for _, day := range weather.Days {
|
||||
fmt.Fprintf(&text, "%s:%s,%g~%g°C,最高降雨概率%g%%。\n",
|
||||
day.Date, day.Condition, day.MinTemperatureC, day.MaxTemperatureC, day.PrecipitationChancePct)
|
||||
}
|
||||
text.WriteString("\n")
|
||||
return text.String()
|
||||
}
|
||||
Reference in new issue
Block a user