-
Notifications
You must be signed in to change notification settings - Fork 687
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
feat: Integrate cohere models #932
base: master
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Thanks @NeilJohnson0930 , left some comments
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.
Thanks @NeilJohnson0930 ! Left some comments below
0bc66de
to
3ac127b
Compare
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.
Thanks @NeilJohnson0930 ! Left some comments
camel/configs/cohere_config.py
Outdated
temperature (Optional[float], optional): | ||
Controls randomness in the model. | ||
Values closer to 0 make the model more deterministic, while | ||
values closer to 1 make it more random. (default: :obj:`None`) | ||
p (Optional[float], optional): Sets a p% nucleus sampling threshold. | ||
(default: :obj:`None`) | ||
k (Optional[int], optional): | ||
Limits the number of tokens to sample from on | ||
each step. (default: :obj:`None`) | ||
max_tokens (Optional[int], optional): | ||
The maximum number of tokens to generate. | ||
(default: :obj:`None`) | ||
prompt_truncation (Optional[str], optional): | ||
How to truncate the prompt if it | ||
exceeds the model's context length. Can be 'START', 'END', or | ||
'AUTO'. (default: :obj:`None`) |
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.
from https://docs.cohere.com/reference/chat seems not all parameters are included in config, like seed
camel/models/cohere_model.py
Outdated
usage={ | ||
"prompt_tokens": safe_get( | ||
response, 'meta', 'billed_tokens', 'prompt_tokens' | ||
) | ||
or 0, | ||
"completion_tokens": safe_get( | ||
response, 'meta', 'billed_tokens', 'completion_tokens' | ||
) | ||
or 0, | ||
"total_tokens": ( | ||
( | ||
safe_get( | ||
response, 'meta', 'billed_tokens', 'prompt_tokens' | ||
) | ||
or 0 | ||
) | ||
+ ( | ||
safe_get( | ||
response, | ||
'meta', | ||
'billed_tokens', | ||
'completion_tokens', | ||
) | ||
or 0 | ||
) | ||
), | ||
}, |
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.
the path we get usage data seems not correct, it should from response.meta.tokens.input_tokens
and response.meta.tokens.output_tokens
camel/models/cohere_model.py
Outdated
def _to_openai_response( | ||
self, response: 'NonStreamedChatResponse' | ||
) -> ChatCompletion: |
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.
cohere model also support tool calling, we need to add tool_calls data to ChatCompletion
ecb1925
to
03cd8c9
Compare
Description
Integrate cohere models
contributed by @NeilJohnson0930
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax `close #896'
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Implemented Tasks
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!