Files
zhaoyupeng.elqbandTRAE CLI 81deca8c8e 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>
2026-11-19 11:08:03 +08:00

34 lines
1.8 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package agent
import (
"context"
"fmt"
"time"
"github.com/cloudwego/eino/adk"
"github.com/cloudwego/eino/schema"
)
func genModelInput(_ context.Context, instruction string, input *adk.AgentInput) ([]adk.Message, error) {
messages := []adk.Message{schema.SystemMessage(timedInstruction(instruction, time.Now()))}
return append(messages, input.Messages...), nil
}
// timedInstruction 每轮生成时间信息,避免使用进程启动时的旧日期。
func timedInstruction(instruction string, now time.Time) string {
now = now.In(time.FixedZone("Asia/Shanghai", 8*60*60))
weekdays := [...]string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}
// 按周一至周日确定当前周,给模型明确的日期参照。
weekday := (int(now.Weekday()) + 6) % 7
saturday := now.AddDate(0, 0, 5-weekday)
return instruction + fmt.Sprintf(`
当前日期:%s,%s,时区:Asia/Shanghai(UTC+08:00)。
明天:%s;本周六:%s;本周日:%s。
查询天气时将相对时间换算为 YYYY-MM-DD,日期参数只能是一个完整日期,不要把多个日期拼进同一个字段。
查询本周末两天时,日期参数示例:{"start_date":"%s","end_date":"%s"},location 使用用户指定的地点。日期存在歧义时先询问。
未提供查询地点且历史中也没有时,先询问,不要猜测。收到预报后直接根据结果回答,不重复查询相同日期;无法获取时如实说明,不用今天的预报代替其他目标日期的预报。`,
now.Format(time.DateOnly), weekdays[now.Weekday()], now.AddDate(0, 0, 1).Format(time.DateOnly),
saturday.Format(time.DateOnly), saturday.AddDate(0, 0, 1).Format(time.DateOnly),
saturday.Format(time.DateOnly), saturday.AddDate(0, 0, 1).Format(time.DateOnly))
}