-
Notifications
You must be signed in to change notification settings - Fork 13
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 python async to cohere-works-everywhere #233
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com>
🌿 Preview your docs: https://cohere-preview-fd82d3ca-031b-402b-b1e8-7942d8451f68.docs.buildwithfern.com |
🌿 Preview your docs: https://cohere-preview-0d4f2044-fb6a-466c-be83-12973cf93e9c.docs.buildwithfern.com |
|
||
co = cohere.AsyncClient( | ||
api_key="<azure token>", | ||
base_url="https://Cohere-command-r-plus-phulf-serverless.eastus2.inference.ai.azure.com/v1", |
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.
Can you remove the actual URL?
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.
I think it's useful to have an eg?
This pull request adds Python code to the existing Go code in the files
fern/pages/deployment-options/cohere-works-everywhere.mdx
andfern/pages/v2/deployment-options/cohere-works-everywhere.mdx
. The Python code imports thecohere
andasyncio
libraries, creates an instance ofcohere.AsyncClient
, and defines anasync
functionmain
that sends a chat request to the Cohere API.The
main
function takes achat_history
list containing a user message and a chatbot response, and amessage
string containing the next user message. It then sends a request to the Cohere API to get a response to the user's message, using thechat_history
andmessage
as context. The function also specifies a custom connector with the IDweb-search
to perform a web search before answering the question.The
asyncio.run(main())
line runs themain
function asynchronously, allowing the code to make the API request and receive the response.Changes:
fern/pages/deployment-options/cohere-works-everywhere.mdx
andfern/pages/v2/deployment-options/cohere-works-everywhere.mdx
.cohere
andasyncio
libraries.cohere.AsyncClient
.async
functionmain
to send a chat request to the Cohere API.web-search
to perform a web search before answering the question.asyncio.run(main())
to run themain
function asynchronously.