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

🔧 Refactor Semantic Kernel chat completion implementation #341

Merged
merged 2 commits into from
Dec 9, 2023

Conversation

xbotter
Copy link
Collaborator

@xbotter xbotter commented Dec 1, 2023

Breaking Changes

  • Refactored the chat completion implementation in LLamaSharpChatCompletion.cs to use StatelessExecutor instead of InteractiveExecutor.

Changes

  • Updated the chat history prompt in LLamaSharpChatCompletion.cs to include a conversation between the assistant and the user.
  • Modified the HistoryTransform class in HistoryTransform.cs to append the assistant role to the chat history prompt.
  • Updated the constructor of LLamaSharpChatCompletion to accept optional parameters for historyTransform and outputTransform.
  • Modified the GetChatCompletionsAsync and GetChatCompletions methods in LLamaSharpChatCompletion.cs to use the new StatelessExecutor and outputTransform.
  • Updated the ExtensionMethods.cs file to include the assistant and system roles in the list of anti-prompts.

Discussion

The current implementation refers to the handling method of History in LLamaSharp ChatSession, but the actual execution effect still needs to be combined with models and prompts.

xbotter and others added 2 commits December 1, 2023 21:39
- Refactored the chat completion implementation in `LLamaSharpChatCompletion.cs` to use `StatelessExecutor` instead of `InteractiveExecutor`.
- Updated the chat history prompt in `LLamaSharpChatCompletion.cs` to include a conversation between the assistant and the user.
- Modified the `HistoryTransform` class in `HistoryTransform.cs` to append the assistant role to the chat history prompt.
- Updated the constructor of `LLamaSharpChatCompletion` to accept optional parameters for `historyTransform` and `outputTransform`.
- Modified the `GetChatCompletionsAsync` and `GetChatCompletions` methods in `LLamaSharpChatCompletion.cs` to use the new `StatelessExecutor` and `outputTransform`.
- Updated the `ExtensionMethods.cs` file to include the assistant and system roles in the list of anti-prompts.
@AsakusaRinne
Copy link
Collaborator

Just for curiosity, will replacing InteractiveExecutor with StatelessExecutor improve the performance of SK chat?

@xbotter
Copy link
Collaborator Author

xbotter commented Dec 9, 2023

This will not bring any performance changes. It is just that using StatelessExecutor is more in line with the expectations of the current SK Chat interface.
The current SK ChatCompletion interface is more of a reference to OpenAI's API, providing the ability for stateless chat completion. Currently, there is indeed no suitable way to integrate stateful models.

@AsakusaRinne AsakusaRinne added enhancement New feature or request break change labels Dec 9, 2023
@AsakusaRinne AsakusaRinne merged commit 3019da9 into SciSharp:master Dec 9, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
break change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants