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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions fern/pages/deployment-options/cohere-works-everywhere.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ response = co.chat(

print(response)
```
```python PYTHON (ASYNC)
import cohere
import asyncio

co = cohere.AsyncClient()


async def main():
return await co.chat(
chat_history=[
{"role": "USER", "message": "Who discovered gravity?"},
{
"role": "CHATBOT",
"message": "The man who is widely credited with discovering gravity is Sir Isaac Newton",
},
],
message="What year was he born?",
# perform web search before answering the question. You can also use your own custom connector.
connectors=[{"id": "web-search"}],
)

asyncio.run(main())
```
```go GO
package main

Expand Down Expand Up @@ -410,6 +433,29 @@ response = co.chat(

print(response)
```
```python PYTHON (ASYNC)
import cohere
import asyncio

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?

)

async def main():
return await co.chat(
chat_history=[
{"role": "USER", "message": "Who discovered gravity?"},
{
"role": "CHATBOT",
"message": "The man who is widely credited with discovering gravity is Sir Isaac Newton",
},
],
message="What year was he born?"
)

asyncio.run(main())
```
```go GO
package main

Expand Down
45 changes: 45 additions & 0 deletions fern/pages/v2/deployment-options/cohere-works-everywhere.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ response = co.chat(

print(response)
```
```python PYTHON (ASYNC)
import cohere
import asyncio

co = cohere.AsyncClient()

async def main():
return await co.chat(
chat_history=[
{"role": "USER", "message": "Who discovered gravity?"},
{
"role": "CHATBOT",
"message": "The man who is widely credited with discovering gravity is Sir Isaac Newton",
},
],
message="What year was he born?",
# perform web search before answering the question. You can also use your own custom connector.
connectors=[{"id": "web-search"}],
)

asyncio.run(main())
```
```go GO
package main

Expand Down Expand Up @@ -415,6 +437,29 @@ response = co.chat(

print(response)
```
```python PYTHON (ASYNC)
import cohere
import asyncio

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

async def main():
return await co.chat(
chat_history=[
{"role": "USER", "message": "Who discovered gravity?"},
{
"role": "CHATBOT",
"message": "The man who is widely credited with discovering gravity is Sir Isaac Newton",
},
],
message="What year was he born?"
)

asyncio.run(main())
```
```go GO
package main

Expand Down
Loading