Skip to content

Commit

Permalink
265: creating mapper for interal role to provider role
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-fitz committed Jun 13, 2024
1 parent c6b4650 commit a491e62
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pkg/api/schemas/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ type ChatMessage struct {
// The content of the message.
Content string `json:"content" validate:"required"`
}

func MapToProviderRole(provider string, role Role) Role {
switch provider {
case "cohere":
switch role {
case RoleAssistant:
return "CHATBOT"
case RoleSystem:
return "SYSTEM"
case RoleUser:
return "USER"
}
case "openai":
return role
}
return role
}
2 changes: 1 addition & 1 deletion pkg/providers/cohere/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
"responseId": cohereCompletion.ResponseID,
},
Message: schemas.ChatMessage{
Role: schemas.RoleAssistant,
Role: schemas.MapToProviderRole(providerName, schemas.RoleAssistant),
Content: cohereCompletion.Text,
},
TokenUsage: schemas.TokenUsage{
Expand Down

0 comments on commit a491e62

Please sign in to comment.