You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Starting form 0.3.0, ollama supports tool call in both its api and openai server mode
Adding a document on how to use tool with ollama
model: llama3.1 (needs to be a model that support tool call)
code
// Copyright (c) Microsoft Corporation. All rights reserved.// Tool_Call_With_Ollama_And_LiteLLM.csusingAutoGen.Core;usingAutoGen.OpenAI.Extension;usingAzure.AI.OpenAI;usingAzure.Core.Pipeline;namespaceAutoGen.OpenAI.Sample;
#region Function
publicpartialclassFunction{[Function]publicasyncTask<string>GetWeatherAsync(stringcity){returnawaitTask.FromResult("The weather in "+city+" is 72 degrees and sunny.");}}
#endregion Function
publicclassTool_Call_With_Ollama_And_LiteLLM{publicstaticasyncTaskRunAsync(){// Before running this code, make sure you have// - Ollama:// - Version > 0.3.0// - Ollama running on http://localhost:11434
# region Create_tools
varfunctions=newFunction();varfunctionMiddleware=newFunctionCallMiddleware(functions:[functions.GetWeatherAsyncFunctionContract],functionMap:newDictionary<string,Func<string,Task<string>>>{{functions.GetWeatherAsyncFunctionContract.Name!,functions.GetWeatherAsyncWrapper},});
#endregion Create_tools
#region Create_Agent
varliteLLMUrl="https://56lbqqkh-11434.asse.devtunnels.ms";usingvarhttpClient=newHttpClient(newCustomHttpClientHandler(liteLLMUrl));varoption=newOpenAIClientOptions(OpenAIClientOptions.ServiceVersion.V2024_04_01_Preview){Transport=newHttpClientTransport(httpClient),};// api-key is not required for local server// so you can use any string herevaropenAIClient=newOpenAIClient("api-key",option);varagent=newOpenAIChatAgent(openAIClient:openAIClient,name:"assistant",modelName:"llama3.1",systemMessage:"You are a helpful AI assistant").RegisterMessageConnector().RegisterMiddleware(functionMiddleware).RegisterPrintMessage();varreply=awaitagent.SendAsync("what's the weather in new york");
#endregion Create_Agent
}}
Describe the solution you'd like
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Starting form 0.3.0, ollama supports tool call in both its api and openai server mode
Adding a document on how to use tool with ollama
code
Describe the solution you'd like
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: