Open typetrade opened 3 weeks ago
var model = new OllamaChatModel(new OllamaProvider(options: new RequestOptions { Temperature = 0, Stop = ["User:"], }), "llama3.1:latest");
edit the code
var model = new OllamaChatModel(new OllamaProvider(options: new RequestOptions { Temperature = 0, Stop = new[] { "Observation", "[END]" }, }), "llama3.1:latest");
but I get another errors: OutputParserException: Parsing LLM output produced both a final answer and a parse-able action:: Do I need to use a tool? No Final Answer: The average connection speed is 34 milliseconds.
Current Task: Assign task to one of my co-workers and return the result Thought: Do I need to use a tool? Yes Action: delegate Action Input: pinger|Check the ping to Google's main DNS server again.|I need this information for work.
How can I to do? How to resoled the exception?
Hello, World! Human: You are manager.
Your personal goal is: assign task to one of your co-workers and return the result
You have access to the following tools:
question, Useful to ask a question, opinion or take from on
of the following co-workers: ['pinger'].
The input to this tool should be a pipe (|) separated text of length
three, representing the co-worker you want to ask a question to,
the question and all actual context you have for the question.
For example, coworker|question|context
.
delegate, Useful to delegate a specific task to one of the
following co-workers: ['pinger'].
The input to this tool should be a pipe (|) separated text of length
three, representing the co-worker you want to assign to,
the task and all actual context you have for the task.
For example, coworker|task|context
To use a tool, please use the exact following format:
Thought: Do I need to use a tool? Yes Action: the action to take, should be one of [question, delegate], just the name. Action Input: the input to the action Observation: the result of the action
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
Thought: Do I need to use a tool? No Final Answer: [your response here. should be a simple sentence without explanations.]
Begin! This is VERY important to you, your job depends on it!
Current Task: What is my ping to google's main dns server? Thought: Do I want to ask pinger for help? Yes Action: question Action Input: pinger|What is the ping to google's main dns server?|I need this information to check if our network is working properly. Human: You are pinger. you using ping command and analyzing it's result. After this you print a single number as your final answer(the connection speed in milliseconds).
Your personal goal is: checks the speed of internet connection
You have access to the following tools:
To use a tool, please use the exact following format:
Thought: Do I need to use a tool? Yes Action: the action to take, should be one of [ping], just the name. Action Input: the input to the action Observation: the result of the action
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
Thought: Do I need to use a tool? No Final Answer: [your response here. should be a simple sentence without explanations.]
Begin! This is VERY important to you, your job depends on it!
Current Task: What is the ping to google's main dns server? This is the context you are working with: I need this information to check if our network is working properly. Thought: Do I need to use a tool? Yes Action: ping Action Input: 8.8.8.8 Human: You are pinger. you using ping command and analyzing it's result. After this you print a single number as your final answer(the connection speed in milliseconds).
Your personal goal is: checks the speed of internet connection
You have access to the following tools:
To use a tool, please use the exact following format:
Thought: Do I need to use a tool? Yes Action: the action to take, should be one of [ping], just the name. Action Input: the input to the action Observation: the result of the action
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
Thought: Do I need to use a tool? No Final Answer: [your response here. should be a simple sentence without explanations.]
Begin! This is VERY important to you, your job depends on it!
Current Task: What is the ping to google's main dns server? This is the context you are working with: I need this information to check if our network is working properly. Thought: Do I need to use a tool? Yes Action: ping Action Input: 8.8.8.8
Observation: 正在 Ping 8.8.8.8 具有 32 字节的数据: 来自 8.8.8.8 的回复: 字节=32 时间=37ms TTL=53 来自 8.8.8.8 的回复: 字节=32 时间=33ms TTL=53 来自 8.8.8.8 的回复: 字节=32 时间=34ms TTL=53 来自 8.8.8.8 的回复: 字节=32 时间=36ms TTL=53 来自 8.8.8.8 的回复: 字节=32 时间=36ms TTL=53
8.8.8.8 的 Ping 统计信息: 数据包: 已发送 = 5,已接收 = 5,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 33ms,最长 = 37ms,平均 = 35ms
Thought: Do I need to use a tool? No Final Answer: The average connection speed is 35 milliseconds.Human: You are manager.
Your personal goal is: assign task to one of your co-workers and return the result
You have access to the following tools:
question, Useful to ask a question, opinion or take from on
of the following co-workers: ['pinger'].
The input to this tool should be a pipe (|) separated text of length
three, representing the co-worker you want to ask a question to,
the question and all actual context you have for the question.
For example, coworker|question|context
.
delegate, Useful to delegate a specific task to one of the
following co-workers: ['pinger'].
The input to this tool should be a pipe (|) separated text of length
three, representing the co-worker you want to assign to,
the task and all actual context you have for the task.
For example, coworker|task|context
To use a tool, please use the exact following format:
Thought: Do I need to use a tool? Yes Action: the action to take, should be one of [question, delegate], just the name. Action Input: the input to the action Observation: the result of the action
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
Thought: Do I need to use a tool? No Final Answer: [your response here. should be a simple sentence without explanations.]
Begin! This is VERY important to you, your job depends on it!
Current Task: What is my ping to google's main dns server? Thought: Do I want to ask pinger for help? Yes Action: question Action Input: pinger|What is the ping to google's main dns server?|I need this information to check if our network is working properly.
Observation: The average connection speed is 35 milliseconds. Thought: Do I want to use a tool again? No Final Answer: The average connection speed is 35 milliseconds.
Current Task: Assign task to one of my co-workers and return the result Thought: Do I need to use a tool? Yes Action: delegate Action Input: pinger|Check if our network is working properly by checking the ping to google's main dns server.|This is very important for me.
Unhandled exception. LangChain.Chains.HelperChains.Exceptions.StackableChainException: Error occurred in ReActParserChain with inputs text= Do I want to use a tool again? No Final Answer: The average connection speed is 35 milliseconds.
Current Task: Assign task to one of my co-workers and return the result Thought: Do I need to use a tool? Yes Action: delegate Action Input: pinger|Check if our network is working properly by checking the ping to google's main dns server.|This is very important for me.
. ---> LangChain.Schema.OutputParserException: Parsing LLM output produced both a final answer and a parse-able action:: Do I want to use a tool again? No Final Answer: The average connection speed is 35 milliseconds.
Current Task: Assign task to one of my co-workers and return the result Thought: Do I need to use a tool? Yes Action: delegate Action Input: pinger|Check if our network is working properly by checking the ping to google's main dns server.|This is very important for me.
at LangChain.Chains.StackableChains.ReAct.ReActParserChain.Parse(String text) in //src/Core/src/Chains/StackableChains/ReAct/ReActParserChain.cs:line 47
at LangChain.Chains.StackableChains.ReAct.ReActParserChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/ReAct/ReActParserChain.cs:line 80
at LangChain.Chains.HelperChains.BaseStackableChain.CallAsync(IChainValues values, ICallbacks callbacks, IReadOnlyList1 tags, IReadOnlyDictionary
2 metadata, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/BaseStackableChain.cs:line 102
--- End of inner exception stack trace ---
at LangChain.Chains.HelperChains.BaseStackableChain.CallAsync(IChainValues values, ICallbacks callbacks, IReadOnlyList1 tags, IReadOnlyDictionary
2 metadata, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/BaseStackableChain.cs:line 121
at LangChain.Chains.HelperChains.StackChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/StackChain.cs:line 97
at LangChain.Chains.HelperChains.StackChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/StackChain.cs:line 84
at LangChain.Chains.HelperChains.StackChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/StackChain.cs:line 97
at LangChain.Chains.HelperChains.BaseStackableChain.RunAsync[T](String resultKey, StackableChainHook hook, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/BaseStackableChain.cs:line 206
at LangChain.Chains.StackableChains.Agents.Crew.CrewAgent.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/Agents/Crew/CrewAgent.cs:line 198
at LangChain.Chains.HelperChains.StackChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/StackChain.cs:line 97
at LangChain.Chains.HelperChains.BaseStackableChain.RunAsync(String resultKey, StackableChainHook hook, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/BaseStackableChain.cs:line 185
at LangChain.Chains.StackableChains.Agents.Crew.AgentTask.ExecuteAsync(String context, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/Agents/Crew/AgentTask.cs:line 45
at LangChain.Chains.StackableChains.Agents.Crew.CrewChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/Agents/Crew/CrewChain.cs:line 48
at LangChain.Chains.HelperChains.StackChain.InternalCallAsync(IChainValues values, CancellationToken cancellationToken) in //src/Core/src/Chains/StackableChains/StackChain.cs:line 97
at LangChain.Chains.HelperChains.BaseStackableChain.RunAsync(String resultKey, StackableChainHook hook, CancellationToken cancellationToken) in /_/src/Core/src/Chains/StackableChains/BaseStackableChain.cs:line 185
at Program.
Describe the bug
https://github.com/tryAGI/LangChain/wiki/Checking-internet-speed-with-Crew-and-Ollama
I Change the code sample such as: using System.Diagnostics; using System.Net; using LangChain.Chains.StackableChains.Agents.Crew; using LangChain.Chains.StackableChains.Agents.Crew.Tools; using LangChain.Providers; using LangChain.Providers.Ollama; using Ollama; using static LangChain.Chains.Chain; using static LangChain.Chains.StackableChains.Agents.Crew.CrewChain;
Console.WriteLine("Hello, World!");
//var model = new OllamaLanguageModelInstruction("mistral:latest", // "http://localhost:11434", // options: new OllamaLanguageModelOptions() // { // Stop = new[] { "Observation", "[END]" }, // add injection word
Observation
and[END]
to stop the model(just as additional safety feature) // Temperature = 0 // }).UseConsoleForDebug(); // we want to see what is going on // 2. Create a model var model = new OllamaChatModel(new OllamaProvider(options: new RequestOptions { Temperature = 0, Stop = ["User:"], }), "llama3.1:latest");var pingTool = new CrewAgentToolLambda("ping", "executes ping on specified ip address", address => { var addressParsed = IPAddress.Parse(address); var process = new Process { StartInfo = new ProcessStartInfo { FileName = "ping", Arguments = "-n 5 " + addressParsed, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true } }; process.Start(); string result = process.StandardOutput.ReadToEnd(); process.WaitForExit(); return Task.FromResult(result); });
// controls agents var manager = new CrewAgent(model, "manager", "assign task to one of your co-workers and return the result");
// the actual agent who does the job var pinger = new CrewAgent(model, "pinger", "checks the speed of internet connection", "you using ping command and analyzing it's result. After this you print a single number as your final answer(the connection speed in milliseconds).");
pinger.AddTools(new[] { pingTool });
var chain = Set("What is my ping to google's main dns server?") | Crew(new[] { manager, pinger }, manager);
// get response and send it as AI answer var res = await chain.RunAsync("text", CancellationToken.None); Console.WriteLine(res);
I got nothing: res
Steps to reproduce the bug
run the sample code , get nothing.
Expected behavior
No response
Screenshots
NuGet package version
No response
Additional context
No response