Skip to content

Commit

Permalink
fix: code block titles are consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Aug 8, 2024
1 parent 06eb27d commit d10aa31
Show file tree
Hide file tree
Showing 47 changed files with 769 additions and 707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ type: ""
createdAt: "Tue Jun 11 2024 15:45:40 GMT+0000 (Coordinated Universal Time)"
hidden: false
---

Users can now force `command-nightly`to generate outputs in JSON objects by setting the `response_format` parameter in the Chat API. Users can also specify a JSON schema for the output.

This feature is available across all of Cohere's SDKs (Python, Typescript, Java, Go).

Example request for forcing JSON response format:
Example request for forcing JSON response format:

```Text cURL
```http
POST https://api.cohere.ai/v1/chat
{
"message": "Generate a JSON that represents a person, with name and age",
Expand All @@ -24,9 +25,9 @@ POST https://api.cohere.ai/v1/chat

<br />

Example request for forcing JSON response format in user defined schema:
Example request for forcing JSON response format in user defined schema:

```Text cURL
```http
POST https://api.cohere.ai/v1/chat
{
"message": "Generate a JSON that represents a person, with name and age",
Expand All @@ -46,4 +47,4 @@ POST https://api.cohere.ai/v1/chat
```

Currently only compatible with \`command-nightly model.
Currently only compatible with \`command-nightly model.
6 changes: 3 additions & 3 deletions fern/pages/cohere-api/about.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ We support SDKs in 4 different languages. Please see the following installation
python -m pip install cohere --upgrade
```

```python
```python PYTHON
import cohere

co = cohere.Client("<<apiKey>>")
Expand All @@ -47,7 +47,7 @@ print(response)
npm i -s cohere-ai
```

```typescript
```typescript TYPESCRIPT
const { CohereClient } = require("cohere-ai");

const cohere = new CohereClient({
Expand Down Expand Up @@ -103,7 +103,7 @@ public class ChatPost {
go get github.com/cohere-ai/cohere-go/v2
```

```go
```go GO
package main

import (
Expand Down
10 changes: 7 additions & 3 deletions fern/pages/cohere-api/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ slug: "reference/errors"

hidden: false
description: "This document explains how Cohere uses HTTP response codes to indicate the success or failure of an API request, with codes in the 2xx range indicating success, 4xx range indicating errors due to provided information, and 5xx range indicating server errors. It also provides code examples for error handling in different programming languages."
image: "../../assets/images/72cf813-meta_docs_image_cohere.jpg"
image: "../../assets/images/72cf813-meta_docs_image_cohere.jpg"
keywords: "RAG, retrieval, augmented, generation, LLM, connectors, connector, langchain"

createdAt: "Tue Sep 06 2022 17:39:07 GMT+0000 (Coordinated Universal Time)"
updatedAt: "Fri Mar 15 2024 04:29:33 GMT+0000 (Coordinated Universal Time)"
---

Cohere uses conventional HTTP response codes to indicate the success or failure of an API request. In general:

- Codes in the **2xx** range indicate success.
Expand Down Expand Up @@ -37,20 +38,23 @@ Here are code examples for how error handling might look in our SDKs:
print(e.http_status)
print(e.headers)
```

```javascript JAVASCRIPT
(async () => {
const response = await cohere.generate({model: 'invalid-model'});
const response = await cohere.generate({ model: "invalid-model" });

if (response.statusCode !== 200) {
console.log(response.body.message);
console.log(response.body.message);
}
})();
```

```go GO
_, err := co.Generate(generateOptions)
if err != nil {
fmt.Println(err)
return
}
```

</CodeBlocks>
12 changes: 6 additions & 6 deletions fern/pages/cookbooks/agent-api-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ response_1 = agent_executor.invoke(
)
```

````txt title="Output"
````txt OUTPUT
> Entering new AgentExecutor chain...

I will use the regex_extractor tool to extract the codes from the user query.
Expand Down Expand Up @@ -202,7 +202,7 @@ The output of the tool is then used to generate the request.
convert_to_json(response_1['output'])
```

```python title="Output"
```python OUTPUT
[{'urn': ['urn:75f2b737-06dd-4399-9206-a6c11b65138e'],
'objref': ['GLCMS004AGTCAMIS', 'GLCHL000CGUCHALE'],
'nmgs': ['0000234GLCMS0100ANORAKCAA']}]
Expand All @@ -221,7 +221,7 @@ response_2 = agent_executor.invoke(
)
```

````txt title="Output"
````txt OUTPUT
> Entering new AgentExecutor chain...

I will use the regex_extractor tool to extract the relevant information from the user request.
Expand Down Expand Up @@ -256,7 +256,7 @@ The Agent runs the tool to check if any target string was in the query, then it
convert_to_json(response_2['output'])
```

```python title="Output"
```python OUTPUT
[{'taxonomies': ['SPORT']}]
```

Expand All @@ -273,7 +273,7 @@ response_3 = agent_executor.invoke(
)
```

````txt title="Output"
````txt OUTPUT
> Entering new AgentExecutor chain...

I will use the regex_extractor tool to extract the codes from the user query. Then, I will create a JSON for each of the key-value pairs in the dictionary.
Expand Down Expand Up @@ -310,7 +310,7 @@ Grounded answer: ```json JSON
convert_to_json(response_3['output'])
```

```python title="Output"
```python OUTPUT
[{'objref': ['GLBRL0000GACHALE'], 'nmgs': ['0000234GLCZD0000GUREDTOAA']},
{'taxonomies': ['CARS']}]
```
Expand Down
14 changes: 7 additions & 7 deletions fern/pages/cookbooks/agent-short-term-memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ a1=agent_executor.invoke({
})
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will use python to read the CSV file and extract the column names.
Expand Down Expand Up @@ -147,7 +147,7 @@ a2_no_mem = agent_executor.invoke({
})
```

````txt title="Output"
````txt OUTPUT
> Entering new AgentExecutor chain...
Plan: I will ask the user for clarification on what data they would like to visualise.
Action: ```json JSON
Expand Down Expand Up @@ -182,7 +182,7 @@ a2_mem_ai = agent_executor.invoke({
})
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will copy and paste the code from the previous conversation and add code to plot the revenue numbers.
Expand Down Expand Up @@ -214,7 +214,7 @@ a2_mem_ai_hum = agent_executor.invoke({
})
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will copy and paste the code from the previous conversation into this one, and then use it to plot the revenue numbers.
Expand Down Expand Up @@ -247,7 +247,7 @@ a3_mem_ai_hum = agent_executor.invoke({
})
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will copy and paste the previous code and make the changes requested by the user. Then I will execute the code to plot the graph with the changes applied.
Expand Down Expand Up @@ -312,7 +312,7 @@ Below, an example of the augmented memory object generated by the model. You can
print(augmented_mem_obj_a2)
```

```txt title="Output"
```txt OUTPUT
This is the sequence of tools you used in the previous turn:
START TOOL 0 NAME:
Expand Down Expand Up @@ -340,7 +340,7 @@ a3_mem_ai_hum_amo = agent_executor.invoke({

```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will copy and paste the previous code, and modify the y axis limits as requested.
Expand Down
12 changes: 6 additions & 6 deletions fern/pages/cookbooks/agentic-multi-stage-rag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ from sklearn.metrics.pairwise import cosine_similarity
print('cohere version:', cohere.__version__)
```

```txt title="Output"
```txt OUTPUT
cohere version: 5.5.1
```

Expand Down Expand Up @@ -339,7 +339,7 @@ output = simple_rag(question1, db)
print(output)
```

```txt title="Output"
```txt OUTPUT
top_matched_document 1 Title: Bicycle helmet requirement\nBody: Curre...
Name: combined, dtype: object
There is currently no state law requiring the use of helmets when riding a bicycle. However, some cities and counties do require helmet use.
Expand All @@ -356,7 +356,7 @@ Use the provided documents to answer questions about an employee's specific situ
output = cohere_agent(question1, preamble, tools, verbose=True)
```

```txt title="Output"
```txt OUTPUT
running 0th step.
I will search for 'state level law for wearing helmets' in the documents provided and write an answer based on what I find.
Expand Down Expand Up @@ -388,7 +388,7 @@ output = simple_rag(question2, db)
print(output)
```

```txt title="Output"
```txt OUTPUT
top_matched_document 1 Title: Bicycle helmet requirement\nBody: Curre...
Name: combined, dtype: object
In the state of Washington, there is no law requiring you to wear a helmet when riding a bike. However, some cities and counties do require helmet use, so it is worth checking your local laws.
Expand All @@ -407,7 +407,7 @@ Use the provided documents to answer questions about an employee's specific situ
output = cohere_agent(question2, preamble, tools, verbose=True)
```

```txt title="Output"
```txt OUTPUT
running 0th step.
I will search for 'helmet with a bike' and then write an answer.
Expand Down Expand Up @@ -505,7 +505,7 @@ Please follow these steps:
output = cohere_agent(question2, preamble2, tools, verbose=True)
```

```txt title="Output"
```txt OUTPUT
running 0th step.
I will search for 'Orting' and 'bike helmet' to find the relevant information.
Expand Down
14 changes: 7 additions & 7 deletions fern/pages/cookbooks/agentic-rag-mixed-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ text_elements = [e for e in categorized_elements if e.type == "text"]
print(len(text_elements))
```

```txt title="Output"
```txt OUTPUT
14
24
```
Expand Down Expand Up @@ -292,7 +292,7 @@ print(final_answer_docs)
chat_history=[{'role':"USER", 'message':query},{'role':"CHATBOT", 'message':f'The final answer is: {final_answer}.' + final_answer_docs}]
```

```txt title="Output"
```txt OUTPUT
The charges for services in 2022 were $5,266 million.
The final answer is from the documents below:
Expand Down Expand Up @@ -327,7 +327,7 @@ else:
print(response.text)
```

```txt title="Output"
```txt OUTPUT
RAG is not needed
Final answer:
The result of dividing the charges for services in 2022 by two is $2,633.
Expand Down Expand Up @@ -555,7 +555,7 @@ rag_object=RAG_pipeline(paths=["city_ny_popular_fin_report.pdf"])

This function will be deprecated in a future release and `unstructured` will simply use the DEFAULT_MODEL from `unstructured_inference.model.base` to set default model name

```txt title="Output"
```txt OUTPUT
PDFs parsed
14
24
Expand Down Expand Up @@ -663,7 +663,7 @@ agent_object=react_agent(rag_retriever=rag_object)
step1_response=agent_object.run_agent("what are the charges for services in 2022 and 2023")
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...

I will search for the charges for services in 2022 and 2023.
Expand Down Expand Up @@ -695,7 +695,7 @@ AIMessage(content=step1_response['output'])
agent_object.run_agent("what is the mean of the two values",history=chat_history)
```

```txt title="Output"
```txt OUTPUT
> Entering new AgentExecutor chain...
Expand All @@ -714,7 +714,7 @@ Grounded answer: The mean of the two values is <co: 0="">5518 million</co:>.
> Finished chain.
```

````python title="Output"
````python OUTPUT
{'input': 'what is the mean of the two values',
'preamble': "\n## Task &amp; Context\nYou help people answer their questions and other requests interactively. You will be asked a very wide array of requests on all kinds of topics. You will be equipped with a wide range of search engines or similar tools to help you, which you use to research your answer. You should focus on serving the user's needs as best you can, which will be wide-ranging.\n\n## Style Guide\nUnless the user asks for a different style of answer, you should answer in full sentences, using proper grammar and spelling.\n\n## Guidelines\nYou are an expert who answers the user's question. \nYou have access to a vectorsearch tool that will use your query to search through documents and find the relevant answer.\nYou also have access to a python interpreter tool which you can use to run code for mathematical operations.\n",
'chat_history': [HumanMessage(content='what are the charges for services in 2022 and 2023'),
Expand Down
Loading

0 comments on commit d10aa31

Please sign in to comment.