diff --git a/fern/pages/v2/text-generation/retrieval-augmented-generation-rag.mdx b/fern/pages/v2/text-generation/retrieval-augmented-generation-rag.mdx index 792b1ce7d..f6c64375d 100644 --- a/fern/pages/v2/text-generation/retrieval-augmented-generation-rag.mdx +++ b/fern/pages/v2/text-generation/retrieval-augmented-generation-rag.mdx @@ -34,28 +34,29 @@ The code snippet below, for example, will produce a grounded answer to `"Where d ```python import cohere + co = cohere.ClientV2(api_key="") # Retrieve the documents documents = [ - { - "data": { - "title": "Tall penguins", - "snippet": "Emperor penguins are the tallest." - } - }, - { - "data": { - "title": "Penguin habitats", - "snippet": "Emperor penguins only live in Antarctica." - } - }, - { - "data": { - "title": "What are animals?", - "snippet": "Animals are different from plants." + { + "data": { + "title": "Tall penguins", + "snippet": "Emperor penguins are the tallest.", + } + }, + { + "data": { + "title": "Penguin habitats", + "snippet": "Emperor penguins only live in Antarctica.", + } + }, + { + "data": { + "title": "What are animals?", + "snippet": "Animals are different from plants.", + } } - } ] # Add the user message @@ -65,7 +66,8 @@ messages = [{"role": "user", "content": message}] response = co.chat( model="command-r-plus-08-2024", messages=messages, - documents=documents) + documents=documents +) print(response.message.content[0].text) @@ -205,8 +207,9 @@ In the final step, we will be calling the Chat API again, but this time passing **Request** -```py +```python import cohere + co = cohere.ClientV2(api_key="") documents = [ diff --git a/fern/pages/v2/text-generation/structured-outputs-json.mdx b/fern/pages/v2/text-generation/structured-outputs-json.mdx index ca3edee72..ec7bf8f9b 100644 --- a/fern/pages/v2/text-generation/structured-outputs-json.mdx +++ b/fern/pages/v2/text-generation/structured-outputs-json.mdx @@ -24,12 +24,18 @@ When making an API request, you can specify the `response_format` parameter to i ```python import cohere + co = cohere.ClientV2(api_key="YOUR API KEY") res = co.chat( - model="command-r-plus-08-2024", - messages=[{"role": "user", "content": "Generate a JSON describing a person, with the fields 'name' and 'age'"}], - response_format={ "type": "json_object" } + model="command-r-plus-08-2024", + messages=[ + { + "role": "user", + "content": "Generate a JSON describing a person, with the fields 'name' and 'age'", + } + ], + response_format={"type": "json_object"} ) print(res.message.content[0].text) @@ -58,6 +64,7 @@ For example, let's say you want the LLM to generate a JSON object with specific ```python import cohere + co = cohere.ClientV2(api_key="YOUR API KEY") res = co.chat( @@ -79,7 +86,7 @@ res = co.chat( "publication_year": {"type": "integer"}, }, }, - }, + } ) print(res.message.content[0].text)