Skip to content

Commit

Permalink
Reformat deployment-options pages (#346)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Shkutnyk <max@lightsonsoftware.com>
  • Loading branch information
invader89 and Max Shkutnyk authored Jan 13, 2025
1 parent 9d24784 commit 47a9cf2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 46 deletions.
40 changes: 23 additions & 17 deletions fern/pages/v2/deployment-options/cohere-on-aws/amazon-bedrock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,29 @@ co = cohere.BedrockClient(
)

# Input parameters for embed. In this example we are embedding hacker news post titles.
texts = ["Interesting (Non software) books?",
"Non-tech books that have helped you grow professionally?",
"I sold my company last month for $5m. What do I do with the money?",
"How are you getting through (and back from) burning out?",
"I made $24k over the last month. Now what?",
"What kind of personal financial investment do you do?",
"Should I quit the field of software development?"]
texts = [
"Interesting (Non software) books?",
"Non-tech books that have helped you grow professionally?",
"I sold my company last month for $5m. What do I do with the money?",
"How are you getting through (and back from) burning out?",
"I made $24k over the last month. Now what?",
"What kind of personal financial investment do you do?",
"Should I quit the field of software development?",
]
input_type = "clustering"
truncate = "NONE" # optional
model_id = "cohere.embed-english-v3" # or "cohere.embed-multilingual-v3"
truncate = "NONE" # optional
model_id = (
"cohere.embed-english-v3" # or "cohere.embed-multilingual-v3"
)


# Invoke the model and print the response
result = co.embed(
model=model_id,
input_type=input_type,
texts=texts,
truncate=truncate) # aws_client.invoke_model(**params)
model=model_id,
input_type=input_type,
texts=texts,
truncate=truncate,
) # aws_client.invoke_model(**params)

print(result)
```
Expand All @@ -83,9 +88,10 @@ co = cohere.BedrockClient(
aws_session_token="...",
)

result = co.chat(message="Write a LinkedIn post about starting a career in tech:",
model='cohere.command-r-plus-v1:0' # or 'cohere.command-r-v1:0'
)
result = co.chat(
message="Write a LinkedIn post about starting a career in tech:",
model="cohere.command-r-plus-v1:0", # or 'cohere.command-r-v1:0'
)

print(result)
```
Expand All @@ -98,7 +104,7 @@ You can use this code to invoke our latest Rerank models on Bedrock
import cohere

co = cohere.BedrockClientV2(
aws_region="us-west-2", # pick a region where the model is available
aws_region="us-west-2", # pick a region where the model is available
aws_access_key="...",
aws_secret_key="...",
aws_session_token="...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,27 @@ co = cohere.SageMakerClient(
)

# Input parameters for embed. In this example we are embedding hacker news post titles.
texts = ["Interesting (Non software) books?",
"Non-tech books that have helped you grow professionally?",
"I sold my company last month for $5m. What do I do with the money?",
"How are you getting through (and back from) burning out?",
"I made $24k over the last month. Now what?",
"What kind of personal financial investment do you do?",
"Should I quit the field of software development?"]
texts = [
"Interesting (Non software) books?",
"Non-tech books that have helped you grow professionally?",
"I sold my company last month for $5m. What do I do with the money?",
"How are you getting through (and back from) burning out?",
"I made $24k over the last month. Now what?",
"What kind of personal financial investment do you do?",
"Should I quit the field of software development?",
]
input_type = "clustering"
truncate = "NONE" # optional
model_id = "<YOUR ENDPOINT NAME>" # On SageMaker, you create a model name that you'll pass here.
truncate = "NONE" # optional
model_id = "<YOUR ENDPOINT NAME>" # On SageMaker, you create a model name that you'll pass here.


# Invoke the model and print the response
result = co.embed(
model=model_id,
input_type=input_type,
texts=texts,
truncate=truncate)
model=model_id,
input_type=input_type,
texts=texts,
truncate=truncate,
)

print(result)
```
Expand Down
31 changes: 20 additions & 11 deletions fern/pages/v2/deployment-options/cohere-on-microsoft-azure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ data = {
body = str.encode(json.dumps(data))

# Replace the url with your API endpoint
url = "https://your-endpoint.inference.ai.azure.com/v1/chat/completions"
url = (
"https://your-endpoint.inference.ai.azure.com/v1/chat/completions"
)

# Replace this with the key for the endpoint
api_key = "your-auth-key"
if not api_key:
raise Exception("API Key is missing")

headers = {"Content-Type": "application/json", "Authorization": (api_key)}
headers = {
"Content-Type": "application/json",
"Authorization": (api_key),
}

req = urllib.request.Request(url, body, headers)

Expand Down Expand Up @@ -114,9 +119,7 @@ import urllib.request
import json

# Configure payload data sending to API endpoint
data = {
"input": ["hi"]
}
data = {"input": ["hi"]}

body = str.encode(json.dumps(data))

Expand All @@ -128,7 +131,10 @@ api_key = "your-auth-key"
if not api_key:
raise Exception("API Key is missing")

headers = {"Content-Type": "application/json", "Authorization": (api_key)}
headers = {
"Content-Type": "application/json",
"Authorization": (api_key),
}

req = urllib.request.Request(url, body, headers)

Expand All @@ -152,7 +158,7 @@ import cohere

co = cohere.Client(
base_url="https://<endpoint>.<region>.inference.ai.azure.com/v1",
api_key="<key>"
api_key="<key>",
)

documents = [
Expand Down Expand Up @@ -217,19 +223,19 @@ import cohere
# For Command models
co_chat = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - https://Cohere-command-r-plus-08-2024-xyz.eastus.models.ai.azure.com/
base_url="AZURE_MODEL_ENDPOINT", # Example - https://Cohere-command-r-plus-08-2024-xyz.eastus.models.ai.azure.com/
)

# For Embed models
co_embed = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - https://cohere-embed-v3-multilingual-xyz.eastus.models.ai.azure.com/
base_url="AZURE_MODEL_ENDPOINT", # Example - https://cohere-embed-v3-multilingual-xyz.eastus.models.ai.azure.com/
)

# For Rerank models
co_rerank = cohere.Client(
api_key="AZURE_INFERENCE_CREDENTIAL",
base_url="AZURE_MODEL_ENDPOINT", # Example - https://cohere-rerank-v3-multilingual-xyz.eastus.models.ai.azure.com/
base_url="AZURE_MODEL_ENDPOINT", # Example - https://cohere-rerank-v3-multilingual-xyz.eastus.models.ai.azure.com/
)
```

Expand Down Expand Up @@ -289,7 +295,10 @@ faqs_short = [
query = "Are there fitness-related perks?"

results = co_rerank.rerank(
query=query, documents=faqs_short, top_n=2, model="rerank-english-v3.0"
query=query,
documents=faqs_short,
top_n=2,
model="rerank-english-v3.0",
)
```

Expand Down
9 changes: 4 additions & 5 deletions fern/pages/v2/deployment-options/cohere-works-everywhere.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ const cohere = new CohereClientV2({
```python PYTHON
import cohere

co = cohere.ClientV2(api_key="",
base_url="<YOUR_DEPLOYMENT_URL>")
co = cohere.ClientV2(api_key="", base_url="<YOUR_DEPLOYMENT_URL>")

response = co.chat(
chat_history=[
Expand Down Expand Up @@ -328,7 +327,7 @@ co = cohere.BedrockClient(
)

response = co.chat(
model="cohere.command-r-plus-v1:0",
model="cohere.command-r-plus-v1:0",
chat_history=[
{"role": "USER", "message": "Who discovered gravity?"},
{
Expand Down Expand Up @@ -521,8 +520,8 @@ const cohere = new CohereClient({
import cohere

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

response = co.chat(
Expand Down

0 comments on commit 47a9cf2

Please sign in to comment.