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

Update ToLLamaSharpChatHistory extension method to be public and support semantic-kernel author roles #274

Merged
merged 2 commits into from
Nov 11, 2023

Conversation

kidkych
Copy link
Contributor

@kidkych kidkych commented Nov 11, 2023

Currently when semantic-kernel ChatHistory is converted to LLamaSharp ChatHistory through the ToLLamaSharpChatHistory extension method in https:/SciSharp/LLamaSharp/blob/master/LLama.SemanticKernel/ExtensionMethods.cs the AuthorRole in the resulting LLamaSharp ChatHistory is set to AuthorRoles.Unknown as semantic-kernel uses lowercase author names while LLamaSharp capitalizes the first character. This PR tells the Enum.TryParse method to ignore letter case when matching.

Further, it exposes the ToLLamaSharpChatHistory extension method publicly since it would be useful for debugging in downstream applications.

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.

LGTM except one detail, thank you for this contribution!

{
internal static global::LLama.Common.ChatHistory ToLLamaSharpChatHistory(this ChatHistory chatHistory)
public static global::LLama.Common.ChatHistory ToLLamaSharpChatHistory(this ChatHistory chatHistory)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think adding a parameter bool ignoreCase = true to allow control on it will be better.

Copy link
Contributor Author

@kidkych kidkych Nov 11, 2023

Choose a reason for hiding this comment

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

Makes sense to me, just added the parameter.

Thank you for the awesome library! This is actually my first contribution to an open source project 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

You're always welcome! I'm happy that our work makes sense to you. If you're interested in developing this library, there's a TODO list in LLamaSharp project. 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'd love to help! It looks like the project board is set to private though, I'm getting a 404 error

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for that, I've now changed it to public. :)

@AsakusaRinne AsakusaRinne added the enhancement New feature or request label Nov 11, 2023
@AsakusaRinne AsakusaRinne merged commit c2be012 into SciSharp:master Nov 11, 2023
4 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