Skip to content

Add C# sample projects using MEAI and Semantic Kernel for chat completions with foundry local #153

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elbruno
Copy link

@elbruno elbruno commented Jun 7, 2025

This pull request introduces two new C# sample projects demonstrating chat completion functionality using Foundry Local with different SDKs, updates the solution file to include these projects, and provides documentation for running the samples. Below are the most important changes grouped by theme:

New Sample Projects

  • Added FoundryLocal-01-MEAI-Chat project to demonstrate chat completion using Foundry Local and the MEAI SDK. Includes project file FoundryLocal-01-MEAI-Chat/FoundryLocal-02-MEAI-Chat.csproj and implementation in Program.cs. [1] [2]
  • Added FoundryLocal-01-SK-Chat project to demonstrate chat completion using Foundry Local and Semantic Kernel. Includes project file FoundryLocal-01-SK-Chat/FoundryLocal-01-SK-Chat.csproj and implementation in Program.cs. [1] [2]

Solution File Updates

  • Updated csharp_samples.sln to include the new sample projects, enabling them to be built and run as part of the solution.

Documentation Updates

  • Added a readme.md file in the samples/cs/ directory to provide an overview of the sample projects, prerequisites, and instructions for running them.

var model = "Phi-3.5-mini-instruct-cuda-gpu";
var baseUrl = "http://localhost:5273/v1";
var apiKey = "unused";

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to use the Foundry Local C# SDK to get the baseUrl and apiKey - in a future release, the Port and Key will be dynamically set by foundry on start up.

Example of SDK:

var alias = "phi-3.5-mini";

var manager = await FoundryManager.StartModelAsync(aliasOrModelId: alias);

var model = await manager.GetModelInfoAsync(aliasOrModelId: alias);
ApiKeyCredential key = new ApiKeyCredential(manager.ApiKey);
OpenAIClient client = new OpenAIClient(key, new OpenAIClientOptions
{
    Endpoint = manager.Endpoint
});

The official NuGet should be release this week. In the meantime, you could build from source to test.

var model = "Phi-3.5-mini-instruct-cuda-gpu";
var baseUrl = "http://localhost:5273/v1";
var apiKey = "unused";

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to use the SDEK to get the baseUrl and apiKey in future releases these will be dynamically set.

@samuel100
Copy link
Contributor

@elbruno - thank you so much for the contribution 🙏!!! Would it be possible to use the SDK to get the URL and Key? The official NuGet will be coming this week (all going well). In the meantime you can build from source.

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.

2 participants