Using groq as a chat completion service in semantic kernel #9623
-
What would be the recommended way in semantic kernel to consume groq api for chatCompletion ? but i also discovered Microsoft.Extensions.AI that recommends using an IChatClient : What would be the recommended way in SK. @RogerBarreto |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@giannik Keep in mind that we don't have an official connector for groq, and normally for API's that follows the OpenAI Chat Completion Standard, for simple tasks using the OpenAI connector may work as expected. Important Semantic Kernel is very extensible and there's not a definitive answer, you can use below approaches OpenAI Custom EndpointIn the first example you don't necessarily need a We also have some UnitTest's ensuring this, see: Using a custom endpoint: var chatCompletion = new OpenAIChatCompletionService(
modelId: "any",
apiKey: "api-key",
endpoint: new Uri("https://api.groq.com/openai/v1")) AI AbstractionsUsing the example provided in the blog you can convert the using Microsoft.SemanticKernel;
// <ProviderChatClient> here can be any, OllamaChatClient, OpenAIChatClient, etc... for groq, OpenAI may work best.
var service = new <ProviderChatClient>(...)
.AsChatCompletionService();
// your SK code Http HandlerFollow the approach mentioned in the link HttpClient with a custom delegate handler |
Beta Was this translation helpful? Give feedback.
@giannik Keep in mind that we don't have an official connector for groq, and normally for API's that follows the OpenAI Chat Completion Standard, for simple tasks using the OpenAI connector may work as expected.
Important
Semantic Kernel is very extensible and there's not a definitive answer, you can use below approaches
OpenAI Custom Endpoint
In the first example you don't necessarily need a
httphandler
, as the OpenAI SDK allows custom endpoints to be passed.We also have some UnitTest's ensuring this, see:
semantic-kernel/dotnet/src/Connectors/Connectors.OpenAI.UnitTests/Services/OpenAIChatCompletionServiceTests.cs
Line 87 in ffac88a