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:
zhaoyupeng.elqbandTRAE CLI committed 2026-11-19 11:08:03 +08:00
commit 81deca8c8e
75 files changed
+7048

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package agent
import (
"context"
"strings"
"testing"
"time"
"github.com/cloudwego/eino/adk"
"github.com/cloudwego/eino/schema"
)
func TestTimedInstruction(t *testing.T) {
// 同一进程跨越北京时间午夜后,日期与星期都必须更新。
before := time.Date(2026, 11, 18, 15, 59, 0, 0, time.UTC)
after := before.Add(time.Minute)
for _, tt := range []struct {
now time.Time
date string
day string
}{
{before, "2026-11-18", "星期三"},
{after, "2026-11-19", "星期四"},
} {
prompt := timedInstruction("原有指令", tt.now)
for _, expected := range []string{"原有指令", tt.date, tt.day, "Asia/Shanghai", "YYYY-MM-DD", "先询问", `"start_date":"2026-11-21","end_date":"2026-11-22"`} {
if !strings.Contains(prompt, expected) {
t.Errorf("系统消息缺少 %q", expected)
}
}
}
}
func TestGenModelInput(t *testing.T) {
user := schema.UserMessage("明天北京的天气")
input := &adk.AgentInput{Messages: []adk.Message{user}}
messages, err := genModelInput(context.Background(), "原有指令", input)
if err != nil || len(messages) != 2 || messages[0].Role != schema.System || messages[1] != user || len(input.Messages) != 1 {
t.Fatalf("模型输入 = %+v,错误 = %v", messages, err)
}
date := time.Now().In(time.FixedZone("Asia/Shanghai", 8*60*60)).Format(time.DateOnly)
if !strings.Contains(messages[0].Content, date) {
t.Fatal("系统消息缺少当前日期")
}
}