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

Add python async to cohere-works-everywhere #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

billytrend-cohere
Copy link
Collaborator

@billytrend-cohere billytrend-cohere commented Oct 31, 2024

This pull request adds Python code to the existing Go code in the files fern/pages/deployment-options/cohere-works-everywhere.mdx and fern/pages/v2/deployment-options/cohere-works-everywhere.mdx. The Python code imports the cohere and asyncio libraries, creates an instance of cohere.AsyncClient, and defines an async function main that sends a chat request to the Cohere API.

The main function takes a chat_history list containing a user message and a chatbot response, and a message 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 the chat_history and message as context. The function also specifies a custom connector with the ID web-search to perform a web search before answering the question.

The asyncio.run(main()) line runs the main function asynchronously, allowing the code to make the API request and receive the response.

Changes:

  • Added Python code to fern/pages/deployment-options/cohere-works-everywhere.mdx and fern/pages/v2/deployment-options/cohere-works-everywhere.mdx.
  • Imported the cohere and asyncio libraries.
  • Created an instance of cohere.AsyncClient.
  • Defined an async function main to send a chat request to the Cohere API.
  • Specified a custom connector with the ID web-search to perform a web search before answering the question.
  • Used asyncio.run(main()) to run the main function asynchronously.

@billytrend-cohere billytrend-cohere requested a review from a team as a code owner October 31, 2024 14:45
Signed-off-by: billytrend-cohere <[email protected]>
Copy link

Copy link


co = cohere.AsyncClient(
api_key="<azure token>",
base_url="https://Cohere-command-r-plus-phulf-serverless.eastus2.inference.ai.azure.com/v1",

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?

Copy link
Collaborator Author

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?

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.

2 participants