diff --git a/fern/pages/text-generation/connectors/connector-authentication.mdx b/fern/pages/text-generation/connectors/connector-authentication.mdx index f69d54fb..5b18fe11 100644 --- a/fern/pages/text-generation/connectors/connector-authentication.mdx +++ b/fern/pages/text-generation/connectors/connector-authentication.mdx @@ -38,7 +38,8 @@ First, start by generating a secure token. Here’s a snippet of what generating ```python PYTHON # Generate a token -import secrets +import secrets + secrets.token_urlsafe(32) ``` @@ -55,7 +56,11 @@ curl --request POST ``` ```python PYTHON import requests -r = requests.post('{base_connector_url}/search', {'query': 'How do I expense a meal?'}) + +r = requests.post( + "{base_connector_url}/search", + {"query": "How do I expense a meal?"}, +) ``` ```typescript TYPESCRIPT const response = await fetch('{base_connector_url}/search'{ @@ -82,9 +87,12 @@ curl --request POST ``` ```python PYTHON import requests -r = requests.post('{base_connector_url}/search', - data={'query': 'How do I expense a meal?'}, - headers={"Authorization":"Bearer {Connector API key}"}) + +r = requests.post( + "{base_connector_url}/search", + data={"query": "How do I expense a meal?"}, + headers={"Authorization": "Bearer {Connector API key}"}, +) ``` ```typescript TYPESCRIPT const response = await fetch('{base_connector_url}/search'{ @@ -116,16 +124,17 @@ curl --request POST }' ``` ```python PYTHON -import cohere -co = cohere.Client('Your API key') +import cohere + +co = cohere.Client("Your API key") created_connector = co.create_connector( - name="test-connector", - url="http://connector-example.com/search", - service_auth={ - "type": "bearer", - "token": "{Connector API Key}", - }, - ) + name="test-connector", + url="http://connector-example.com/search", + service_auth={ + "type": "bearer", + "token": "{Connector API Key}", + }, +) ``` ```typescript TYPESCRIPT const { CohereClient } = require("cohere-ai"); @@ -164,12 +173,16 @@ curl --request PATCH ``` ```python PYTHON import cohere + # initialize the Cohere Client with an API Key -co = cohere.Client('YOUR_API_KEY') -connectors = co.update_connector(connector_id, service_auth={ - "type": "bearer", - "token": "{Connector API Key}", - }) +co = cohere.Client("YOUR_API_KEY") +connectors = co.update_connector( + connector_id, + service_auth={ + "type": "bearer", + "token": "{Connector API Key}", + }, +) ``` ```typescript TYPESCRIPT const { CohereClient } = require("cohere-ai"); @@ -215,9 +228,12 @@ curl --request POST ``` ```python PYTHON import requests -r = requests.post('http://connector-example.com/search', - data={'query': 'How do I expense a meal?'}, - headers={"Authorization":"Bearer {Personal/Service API key}"}) + +r = requests.post( + "http://connector-example.com/search", + data={"query": "How do I expense a meal?"}, + headers={"Authorization": "Bearer {Personal/Service API key}"}, +) ``` ```typescript TYPESCRIPT const response = await fetch('http://connector-example.com/search'{ @@ -265,19 +281,20 @@ curl --request POST }' ``` ```python PYTHON -import cohere -co = cohere.Client('Your API key') +import cohere + +co = cohere.Client("Your API key") created_connector = co.create_connector( - name="test-connector", - url="http://connector-example.com/search", - oauth={ - "client_id": "xxx-yyy.apps.googleusercontent.com", - "client_secret": "zzz-vvv", - "authorize_url": "https://accounts.google.com/o/oauth2/auth", - "token_url": "https://oauth2.googleapis.com/token", - "scope": "https://www.googleapis.com/auth/drive.readonly" - }, - ) + name="test-connector", + url="http://connector-example.com/search", + oauth={ + "client_id": "xxx-yyy.apps.googleusercontent.com", + "client_secret": "zzz-vvv", + "authorize_url": "https://accounts.google.com/o/oauth2/auth", + "token_url": "https://oauth2.googleapis.com/token", + "scope": "https://www.googleapis.com/auth/drive.readonly", + }, +) ``` ```typescript TYPESCRIPT const { CohereClient } = require("cohere-ai"); @@ -322,15 +339,19 @@ curl --request PATCH ``` ```python PYTHON import cohere + # initialize the Cohere Client with an API Key -co = cohere.Client('YOUR_API_KEY') -connectors = co.update_connector(connector_id, oauth={ - "client_id": "xxx-yyy.apps.googleusercontent.com", - "client_secret": "zzz-vvv", - "authorize_url": "https://accounts.google.com/o/oauth2/auth", - "token_url": "https://oauth2.googleapis.com/token", - "scope": "https://www.googleapis.com/auth/drive.readonly" - }) +co = cohere.Client("YOUR_API_KEY") +connectors = co.update_connector( + connector_id, + oauth={ + "client_id": "xxx-yyy.apps.googleusercontent.com", + "client_secret": "zzz-vvv", + "authorize_url": "https://accounts.google.com/o/oauth2/auth", + "token_url": "https://oauth2.googleapis.com/token", + "scope": "https://www.googleapis.com/auth/drive.readonly", + }, +) ``` ```typescript TYPESCRIPT const { CohereClient } = require("cohere-ai"); @@ -365,11 +386,17 @@ To use pass through authentication/authorization specify the access token in the ```python PYTHON -import cohere -co = cohere.Client('Your API key') -response = co.chat( - message="What is the chemical formula for glucose?", - connectors=[{"id": "web-search", "user_access_token": "{Personal/Service API key}" }] +import cohere + +co = cohere.Client("Your API key") +response = co.chat( + message="What is the chemical formula for glucose?", + connectors=[ + { + "id": "web-search", + "user_access_token": "{Personal/Service API key}", + } + ], ) ``` ```curl CURL diff --git a/fern/pages/text-generation/connectors/creating-and-deploying-a-connector.mdx b/fern/pages/text-generation/connectors/creating-and-deploying-a-connector.mdx index 7a2b46d2..6d700442 100644 --- a/fern/pages/text-generation/connectors/creating-and-deploying-a-connector.mdx +++ b/fern/pages/text-generation/connectors/creating-and-deploying-a-connector.mdx @@ -54,7 +54,11 @@ curl --request POST ``` ```python PYTHON import requests -r = requests.post('{base_connector_url}/search', {'query': 'How do I expense a meal?'}) + +r = requests.post( + "{base_connector_url}/search", + {"query": "How do I expense a meal?"}, +) ``` ```typescript TYPESCRIPT const response = await fetch('{base_connector_url}/search'{ @@ -117,12 +121,12 @@ After you’ve deployed the connector and verified it can respond to requests, i import cohere # initialize the Cohere Client with an API Key -co = cohere.Client('YOUR_API_KEY') +co = cohere.Client("YOUR_API_KEY") created_connector = co.create_connector( - name="Example connector", - url="https://connector-example.com/search", - ) + name="Example connector", + url="https://connector-example.com/search", +) ``` ```curl CURL curl --request POST @@ -179,7 +183,11 @@ curl --request POST ``` ```python PYTHON import requests -r = requests.post('{base_connector_url}/search', {'query': 'How do I expense a meal?'}) + +r = requests.post( + "{base_connector_url}/search", + {"query": "How do I expense a meal?"}, +) ``` ```typescript TYPESCRIPT const response = await fetch('https://connector.example.com/search'{ @@ -198,11 +206,14 @@ In order to produce grounded generations, include your connector id in the `conn ```python PYTHON -import cohere -co = cohere.Client('Your API key') -response = co.chat( - message="What is the chemical formula for glucose?", - connectors=[{"id": "example_connector_id"}] # this is from the create step +import cohere + +co = cohere.Client("Your API key") +response = co.chat( + message="What is the chemical formula for glucose?", + connectors=[ + {"id": "example_connector_id"} + ], # this is from the create step ) ``` ```curl CURL diff --git a/fern/pages/text-generation/connectors/managing-your-connector.mdx b/fern/pages/text-generation/connectors/managing-your-connector.mdx index 4d81f151..747b5acb 100644 --- a/fern/pages/text-generation/connectors/managing-your-connector.mdx +++ b/fern/pages/text-generation/connectors/managing-your-connector.mdx @@ -34,8 +34,9 @@ const cohere = new CohereClient({ ``` ```python PYTHON import cohere + # initialize the Cohere Client with an API Key -co = cohere.Client('YOUR_API_KEY') +co = cohere.Client("YOUR_API_KEY") connectors = co.list_connectors() ``` @@ -88,9 +89,12 @@ curl --request PATCH ``` ```python PYTHON import cohere + # initialize the Cohere Client with an API Key -co = cohere.Client('YOUR_API_KEY') -connectors = co.update_connector(connector_id, name="new name", url="new_url") +co = cohere.Client("YOUR_API_KEY") +connectors = co.update_connector( + connector_id, name="new name", url="new_url" +) ``` ```typescript TYPESCRIPT const { CohereClient } = require("cohere-ai"); @@ -115,12 +119,15 @@ Step 1: Make a streaming request to the connector using the Chat API and check t ```python PYTHON -import cohere -co = cohere.Client('Your API key') -response = co.chat( - message="What is the chemical formula for glucose?", - stream: True, - connectors=[{"id": "example_connector_id"}] # this is from the create step +import cohere + +co = cohere.Client("Your API key") +response = co.chat( + message="What is the chemical formula for glucose?", + stream=True, + connectors=[ + {"id": "example_connector_id"} + ], # this is from the create step ) ``` ```curl CURL diff --git a/fern/pages/text-generation/connectors/overview-1.mdx b/fern/pages/text-generation/connectors/overview-1.mdx index 06e17243..1d9028c3 100644 --- a/fern/pages/text-generation/connectors/overview-1.mdx +++ b/fern/pages/text-generation/connectors/overview-1.mdx @@ -26,13 +26,14 @@ Connectors are specified when calling the Chat endpoint, which you can read more ```python PYTHON -import cohere -co = cohere.Client(api_key='Your API key') +import cohere + +co = cohere.Client(api_key="Your API key") response = co.chat( - model="command-r-plus-08-2024", - message="What is the chemical formula for glucose?", - connectors=[{"id": "web-search"}] + model="command-r-plus-08-2024", + message="What is the chemical formula for glucose?", + connectors=[{"id": "web-search"}], ) ``` ```curl CURL @@ -76,7 +77,7 @@ response, err := client.Chat( If you or an administrator at your organization has created a new connector, you can add this connector id to the list. Here’s an example: ```python PYTHON -connectors=[{"id": "web-search"}, {"id": "customer-connector-id"}]. +connectors = [{"id": "web-search"}, {"id": "customer-connector-id"}] ``` The response will then contain the generated text with citation elements that link to the documents returned from the connector. For example, the formula `C6H12O6` below has a citation element that links to three websites.