@@ -40,20 +40,30 @@ public async Task AgentWithOllama()
4040 [ Test ]
4141 public async Task AgentWithOllamaReact ( )
4242 {
43- var provider = new OllamaProvider (
44- options : new RequestOptions
45- {
46- Stop = new [ ] { "Observation" , "[END]" } , // add injection word `Observation` and `[END]` to stop the model(just as additional safety feature)
47- Temperature = 0
48- } ) ;
49- var model = new OllamaChatModel ( provider , id : "mistral:latest" ) . UseConsoleForDebug ( ) ;
50-
51- // create a google search tool
52- var searchTool = new GoogleCustomSearchTool ( key : "<your key>" , cx : "<your cx>" , resultsLimit : 1 ) ;
43+ // var provider = new OllamaProvider(
44+ // options: new RequestOptions
45+ // {
46+ // Stop = new[] { "Observation", "[END]" }, // add injection word `Observation` and `[END]` to stop the model(just as additional safety feature)
47+ // Temperature = 0
48+ // });
49+ //var llm = new OllamaChatModel(provider, id: "mistral:latest").UseConsoleForDebug();
50+ var apiKey =
51+ Environment . GetEnvironmentVariable ( "OPENAI_API_KEY" ) ??
52+ throw new InvalidOperationException ( "OpenAI API key is not set" ) ;
53+ var llm = new Gpt35TurboModel ( apiKey ) ;
54+
55+ // create a google search
56+ var searchApiKey =
57+ Environment . GetEnvironmentVariable ( "GOOGLE_SEARCH_API_KEY" ) ??
58+ throw new InvalidOperationException ( "GOOGLE_SEARCH_API_KEY is not set" ) ;
59+ var cx =
60+ Environment . GetEnvironmentVariable ( "GOOGLE_SEARCH_CX" ) ??
61+ throw new InvalidOperationException ( "GOOGLE_SEARCH_CX is not set" ) ;
62+ var searchTool = new GoogleCustomSearchTool ( key : searchApiKey , cx : cx , resultsLimit : 1 ) ;
5363
5464 var chain =
5565 Set ( "What is tryAGI/LangChain?" )
56- | ReActAgentExecutor ( model ) // does the magic
66+ | ReActAgentExecutor ( llm ) // does the magic
5767 . UseTool ( searchTool ) ; // add the google search tool
5868
5969 await chain . RunAsync ( ) ;
0 commit comments