Skip to content

Add Function Calling sample using Ollama #46

New issue

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

elbruno
Copy link
Collaborator

@elbruno elbruno commented Feb 17, 2025

DETAILS

Updated Program.cs to implement AI chat client using Microsoft.Extensions.AI. Introduced OllamaChatClient with function invocation for weather information. Added example questions and responses. Created new project file MEAIFunctionsOllama.csproj with necessary SDK and package references.

DETAILS

Updated `Program.cs` to implement AI chat client using
`Microsoft.Extensions.AI`. Introduced `OllamaChatClient`
with function invocation for weather information. Added
example questions and responses. Created new project file
`MEAIFunctionsOllama.csproj` with necessary SDK and
package references.
@elbruno elbruno requested a review from Copilot February 17, 2025 21:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • 03-CoreGenerativeAITechniques/src/CoreGenerativeAITechniques.sln: Language not supported
  • 03-CoreGenerativeAITechniques/src/MEAIFunctionsOllama/MEAIFunctionsOllama.csproj: Language not supported

Comment on lines +16 to +18
Tools = [
AIFunctionFactory.Create(GetTheWeather)
]
Copy link
Preview

Copilot AI Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid syntax for initializing the Tools property. Use an array or collection initializer.

Suggested change
Tools = [
AIFunctionFactory.Create(GetTheWeather)
]
Tools = new List<IAIFunction>
{
AIFunctionFactory.Create(GetTheWeather)
}

Copilot uses AI. Check for mistakes.

Console.WriteLine("\tGetTheWeather function invoked.");

var temperature = Random.Shared.Next(5, 20);
var conditions = Random.Shared.Next(0, 1) == 0 ? "sunny" : "rainy";
Copy link
Preview

Copilot AI Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random.Shared.Next(0, 1) will always return 0. The upper bound should be 2 to include both 0 and 1.

Suggested change
var conditions = Random.Shared.Next(0, 1) == 0 ? "sunny" : "rainy";
var conditions = Random.Shared.Next(0, 2) == 0 ? "sunny" : "rainy";

Copilot uses AI. Check for mistakes.

@elbruno elbruno merged commit 1eec77c into main Feb 17, 2025
1 check passed
@elbruno elbruno deleted the bruno-add-ollama-functioncalling-sample branch February 17, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy