Skip to content
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

Optimize Semantic Kernel LLamaSharpChatCompletion when running with StatefulExecutorBase models #671

Merged

Conversation

kidkych
Copy link
Contributor

@kidkych kidkych commented Apr 17, 2024

Updated LLamaSharpChatCompletion Semantic Kernel inference to send only the most recent user message in SK ChatHistory instance when using StatefulExecutor models.

The current implementation allows for any Executor mode to be used with the LLamaSharpChatCompletion class. However, as discussed in issue #614, the actual inference call will pass the entire ChatHistory to the model everytime. This makes sense when using the StatelessExecutor but not when using either of the StatefulExecutors.

This PR adds a check to see which executor is being run and format the prompt accordingly. The logic is based on the ChatSession class where the entire history (i.e. system prompt + first user message) is sent when the model is first run, but only the last message on subsequent interactions.

…y the most recent user message in SK ChatHistory instance when using StatefulExecutor models
@AsakusaRinne AsakusaRinne added the enhancement New feature or request label Apr 23, 2024
Copy link
Collaborator

@AsakusaRinne AsakusaRinne left a comment

Choose a reason for hiding this comment

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

Hi, sorry for the late reply. It seems that xbotter is busy with something else. The overall of this PR looks good to me. Thank you a lot for this contribution!

@AsakusaRinne AsakusaRinne merged commit 0c770a5 into SciSharp:master Apr 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants