We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func main() { llm, err := ollama.New( ollama.WithModel("qwen2.5:14b"), ollama.WithFormat("json"), ollama.WithHTTPClient(httpClient), ) if err != nil { panic(err) } content := []llms.MessageContent{ llms.TextParts(llms.ChatMessageTypeHuman, "What is the weather like in Chicago?"), } generateContent, err := llm.GenerateContent(context.Background(), content, llms.WithTools(llmTools)) if err != nil { panic(err) } println(generateContent.Choices[0].Content) AgentsTest(llm) } func AgentsTest(llm llms.Model) { agent := agents.NewOneShotAgent(llm, agentTools, agents.WithMaxIterations(1)) executor := agents.NewExecutor(agent) input := "这段话的中文意思是什么:hello world" answer, err := chains.Run(context.Background(), executor, input) if err != nil { panic(err) } fmt.Println(answer) } var agentTools = []tools.Tool{ &TranslateTools{}, } var llmTools = []llms.Tool{ { Type: "function", Function: &llms.FunctionDefinition{ Name: "getCurrentWeather", Description: "Get the current weather in a given location", Parameters: map[string]any{ "type": "object", "properties": map[string]any{ "location": map[string]any{ "type": "string", "description": "The city and state, e.g. San Francisco, CA", }, }, "required": []string{"location"}, }, }, }, } var _ tools.Tool = (*TranslateTools)(nil) type TranslateTools struct { } func (t TranslateTools) Name() string { return "translation_content" } func (t TranslateTools) Description() string { return "翻译用户输入的content从source_language到target_language" } func (t TranslateTools) Call(ctx context.Context, input string) (string, error) { fmt.Println("input:", input) return input, nil }
{ panic: unable to parse agent output: goroutine 1 [running]: main.AgentsTest({0xee41a8?, 0xc0000fec00?}) D:/code/golang/langchaingo_demo/main.go:60 +0x11f main.main() D:/code/golang/langchaingo_demo/main.go:51 +0x3a5 exit status 2
The text was updated successfully, but these errors were encountered:
Can anyone tell me why?
Sorry, something went wrong.
No branches or pull requests
response error
The text was updated successfully, but these errors were encountered: