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,24 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cloudwego/eino/adk"
|
||||
)
|
||||
|
||||
type DateHandler struct {
|
||||
adk.BaseChatModelAgentMiddleware
|
||||
}
|
||||
|
||||
func (h *DateHandler) BeforeAgent(ctx context.Context, runCtx *adk.ChatModelAgentContext) (context.Context, *adk.ChatModelAgentContext, error) {
|
||||
// 每轮更新日期,避免程序跨天后仍使用启动时的日期。
|
||||
now := time.Now().In(time.FixedZone("Asia/Shanghai", 8*60*60))
|
||||
datePrompt := fmt.Sprintf("当前时区:Asia/Shanghai(UTC+08:00)\n当前时间:%s", now.Format("2006-01-02 15:04:05"))
|
||||
sp := fmt.Sprintf(`%s
|
||||
---
|
||||
%s`, runCtx.Instruction, datePrompt)
|
||||
runCtx.Instruction = sp
|
||||
return ctx, runCtx, nil
|
||||
}
|
||||
Reference in new issue
Block a user