-
Notifications
You must be signed in to change notification settings - Fork 602
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
Add Cohere provider #111
base: main
Are you sure you want to change the base?
Add Cohere provider #111
Conversation
@@ -0,0 +1,42 @@ | |||
# Cohere | |||
|
|||
To use Cohere with `aisuite`, you’ll need an [Cohere account](https://cohere.com/). After logging in, go to the [API Keys](https://dashboard.cohere.com/api-keyss) section in your account settings, agree to the terms of service, connect your card, and generate a new key. Once you have your key, add it to your environment as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use Cohere with `aisuite`, you’ll need an [Cohere account](https://cohere.com/). After logging in, go to the [API Keys](https://dashboard.cohere.com/api-keyss) section in your account settings, agree to the terms of service, connect your card, and generate a new key. Once you have your key, add it to your environment as follows: | |
To use Cohere with `aisuite`, you’ll need an [Cohere account](https://cohere.com/). After logging in, go to the [API Keys](https://dashboard.cohere.com/api-keys) section in your account settings, agree to the terms of service, connect your card, and generate a new key. Once you have your key, add it to your environment as follows: |
|
||
## Create a Chat Completion | ||
|
||
Install the `openai` Python client: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install the `openai` Python client: | |
Install the `cohere` Python client: |
import aisuite as ai | ||
client = ai.Client() | ||
|
||
model_id = "command-r-plus-08-2024" | ||
|
||
messages=[ | ||
{"role": "user", "content": "Hi, how are you?"} | ||
] | ||
|
||
response = client.chat( | ||
model=f"{model_id}", | ||
messages=messages, | ||
) | ||
|
||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import aisuite as ai | |
client = ai.Client() | |
model_id = "command-r-plus-08-2024" | |
messages=[ | |
{"role": "user", "content": "Hi, how are you?"} | |
] | |
response = client.chat( | |
model=f"{model_id}", | |
messages=messages, | |
) | |
print(response) | |
import aisuite as ai | |
client = ai.Client() | |
provider = "cohere" | |
model_id = "command-r-plus-08-2024" | |
messages = [ | |
{"role": "user", "content": "Hi, how are you?"} | |
] | |
response = client.chat.completions.create( | |
model=f"{provider}:{model_id}", | |
messages=messages, | |
) | |
print(response.choices[0].message.content) |
return self.client.chat( | ||
model=model, | ||
messages=messages, | ||
**kwargs # Pass any additional arguments to the Cohere API | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this return an compliant response, as in response.choices[0].message.content
would work?
Add Cohere Provider Support
Description
Added support for Cohere, to expand aisuite's provider options.
Changes Made
providers/cohere_provider.py
CohereProvider
Testing
Environment Variables Added
Related Documentation
Checklist