package llm import ( "context" "fmt" "time" "eino-project/internal/conf" "github.com/cloudwego/eino-ext/components/model/ollama" "github.com/cloudwego/eino/components/model" ) // newOllamaChatModel Ollama聊天模型实例 func newOllamaChatModel(c *conf.Bootstrap) (model.ToolCallingChatModel, error) { if c == nil || c.Ai == nil || c.Ai.Ollama == nil { return nil, fmt.Errorf("AI configuration is missing") } timeout := 60 * time.Second if c.Ai.Ollama.Timeout != nil { timeout = c.Ai.Ollama.Timeout.AsDuration() } modelName := "deepseek-v3.1:671b-cloud" if len(c.Ai.Ollama.Models) > 0 && c.Ai.Ollama.Models[0] != "" { modelName = c.Ai.Ollama.Models[0] } model, err := ollama.NewChatModel(context.Background(), &ollama.ChatModelConfig{ BaseURL: c.Ai.Ollama.Endpoint, Timeout: timeout, Model: modelName, }) if err != nil { return nil, fmt.Errorf("failed to create chat model: %w", err) } return model, nil }