Skip to content

Failed to run Checking-internet-speed-with-Crew-and-Ollama #440

Open
@typetrade

Description

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

image

NuGet package version

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions