-
Notifications
You must be signed in to change notification settings - Fork 3k
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
.Net: HuggingFace implement also IChatCompletionService
?
#5403
Comments
IChatCompletionService
?IChatCompletionService
?
I suggest you implementing your own IChatCompletionService for specific model. You can use existing HuggingFaceTextGenerationService but with special prompt. HuggingFace interference api doesn't have common syntax for chatting, so a chat payload can vary on model you use. |
Can you provide a quick sample on how to implement a very basic one ? I was also thinking the same |
Look at this sample https://github.com/microsoft/semantic-kernel/blob/main/dotnet%2Fsamples%2FKernelSyntaxExamples%2FExample16_CustomLLM.cs chat completion service is similar but takes ChatHistory param instead of string prompt. You have to create prompt something like that from chat history
But keep in mind this pattern can not work with each model. |
@jkone27 if you do want to make a contribution to the Semantic Kernel then @RogerBarreto can help by setting up a feature branch and getting your changes reviewed. |
My oversight, I see now that huggingFace support chatting via interference api https://huggingface.co/docs/api-inference/detailed_parameters?code=python#conversational-task |
I was looking for this functionality as well. Is it possible to implement it in the connector seeing as it has been implemented in Huggingface's API recently? https://huggingface.co/docs/text-generation-inference/messages_api#hugging-face-inference-endpoints |
@jkone27 hi, unfortunately I don't have time for implementing that now. But why don't you want to contribute and create PR fot that? Implementing this should be quite simple. |
@RogerBarreto This in turn can be translated to a cUrl request. A requirement for this to work with a specific model is that it has to have the Making a cUrl request to this model on the public API works in openAI chat style:
This yields the following result:
Streaming is also supported when stream:true is present in the request body. |
![]() probably all models supported in huggingchat should support this also? just a thought |
### Motivation and Context Closes #5403 1. Adding support to Chat Completion for TGI (Text Generation Inference) Deployment. 3. Adding Missing UnitTests for Streaming and Non Streaming scenarios (Text/Chat Completion) 4. Update Metadata + Usage Details for hugging face clients. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
thank you @RogerBarreto |
is there an example for this somewhere in tests or doc with any huggingface chat api? |
There is an example here. However these changes have not been released in a new version. (last release 2 weeks ago) |
i am testing the hugging face preview package for .NET, but i cannot make use of
IChatCompletionService
it fails to resolve that, not using openai, only huggingface apis..
The text was updated successfully, but these errors were encountered: