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

265: unifying roles, setting default as user #269

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

tom-fitz
Copy link
Contributor

Adding specific roles and setting the default to user when a new chat is started.

Closes #265

Copy link
Member

@roma-glushko roma-glushko left a comment

Choose a reason for hiding this comment

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

This is great @tom-fitz 👏

I have left one comment to double check if all providers are compatible with OpenAI roles. If some of them not, we should try to remap Glide roles to the roles they expect.

@@ -127,7 +127,7 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
"responseId": cohereCompletion.ResponseID,
},
Message: schemas.ChatMessage{
Role: "assistant",
Role: schemas.RoleAssistant,
Copy link
Member

Choose a reason for hiding this comment

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

Seems like Cohere decided to deviate from user/assistant/system values and they use CHATBOT, SYSTEM, or USER (uppercase) (ref: https://docs.cohere.com/reference/chat).

This makes me think we need a thin mapper here to smooth this discrepancy.

Also, needs to check if other providers stick to OpenAI's version of roles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes me think we need a thin mapper here to smooth this discrepancy.

@roma-glushko I pushed a mapper here that takes the providerName and the role that should be mapped from. I'd like to get feedback before researching/implementing this to every provider.

Additionally, I have not looked yet, but is there going to be a need to map roles from requests? In this caswe it does not look like the role is coming in from the request from Cohere, but is that situation we want to handle as well?

Copy link
Member

Choose a reason for hiding this comment

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

@tom-fitz

I'd like to get feedback before researching/implementing this to every provider.

Sure, let's sync on this not to do unneeded work 👍 And thank you for the example!

When you look at the current structure of the project, I was trying to consolidate all provider-specific stuff into providers/{provideName} modules. The reasoning behind this:

  • I did not want to spread that logic across the whole service. There are potentially very large number of providers to integrate with (some projects claim that they support 100+ providers). So these single components that know how to work with each provider can grow potentially super big. Instead, Glide has an abstraction that it uses all over the places and feed it into provider's clients and only provider clients know how to translate it into their specific requests.
  • Because the number of providers is huge at some point I think we will offload them into separate packages, create a registry for them and let users build their own instances of Glide with providers (and not only) they support.

That said, how do you feel about having role mappers in the providers/* modules where it's needed? It would be used on Glide -> Provider schema translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roma-glushko That makes a lot more sense. I was thinking to myself when making that example, a generic mapper will get out of hand pretty quickly. I'll move forward with provider specific mappers. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roma-glushko after researching the providers that are listed in the codebase, I found that everyone uses the openai role model with the exception of cohere. Additionally, I found that the azureopenai uses two additional roles tool & function. https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

Is this something you would like handled? If so, how?

Copy link
Member

Choose a reason for hiding this comment

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

@tom-fitz

I found that everyone uses the openai role model with the exception of cohere

Excellent, thank you for double checking!

Additionally, I found that the azureopenai uses two additional roles tool & function. https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

No, let's leave that out of the scope of this PR/task. Support for tools is a slightly bigger problem that I'm hopping us to tackle in scope of #246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💥 Map message roles to unified roles
2 participants