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>
34 lines
870 B
Go
34 lines
870 B
Go
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()
|
||
}
|