feat: add progressive Eino examples and unify weather provider

This commit is contained in:
loveuer committed 2026-11-18 16:29:00 +08:00
1 parent 73f6f0901e
commit 1373f0903f
18 files changed
+893 -380

No files matched your search

+24
View File
@@ -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
}
+23
View File
@@ -0,0 +1,23 @@
package internal
import (
"context"
"log"
"os"
"github.com/cloudwego/eino-ext/components/model/openai"
)
func MustNewChatModel(ctx context.Context) *openai.ChatModel {
chat, err := openai.NewChatModel(ctx, &openai.ChatModelConfig{
APIKey: os.Getenv("AI_KEY"),
BaseURL: "https://ai.loveuer.com/v1",
Model: "mini-chat",
ReasoningEffort: openai.ReasoningEffortLevelLow,
})
if err != nil {
log.Panicf("new openai chat model failed: %v", err)
}
return chat
}