Skip to content

Commit

Permalink
content updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chdeskur committed Jul 29, 2024
1 parent d9e74c2 commit 0e4271e
Show file tree
Hide file tree
Showing 192 changed files with 2,414 additions and 1,740 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 26 additions & 29 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,36 @@ navigation:
- page: Rerank
path: pages/models/rerank-2.mdx
- section: Text Generation
skip-slug: true
contents:
- page: Using the Chat API
path: pages/text-generation/chat-api.mdx
- page: Streaming Responses
path: pages/text-generation/streaming.mdx
- page: Structured Generations (JSON)
path: pages/text-generation/structured-outputs-json.mdx
- page: Predictable Outputs
path: pages/text-generation/predictable-outputs.mdx
- page: Advanced Generation Parameters
path: pages/text-generation/advanced-generation-hyperparameters.mdx
- page: Retrieval Augmented Generation (RAG)
path: pages/text-generation/retrieval-augmented-generation-rag.mdx
- section: RAG Connectors
contents:
- page: Overview of RAG Connectors
path: pages/text-generation/connectors/overview-1.mdx
- page: Creating and Deploying a Connector
path: pages/text-generation/connectors/creating-and-deploying-a-connector.mdx
- page: Managing your Connector
path: pages/text-generation/connectors/managing-your-connector.mdx
- page: Connector Authentication
path: pages/text-generation/connectors/connector-authentication.mdx
- page: Connector FAQs
path: pages/text-generation/connectors/connector-faqs.mdx
- section: Tool Use
path: pages/text-generation/tools.mdx
skip-slug: true
contents:
- section: Multi-step Tool Use (Agents)
path: pages/text-generation/tools/multi-step-tool-use.mdx
skip-slug: true
contents:
- page: Implementing a Multi-Step Agent with Langchain
path: pages/text-generation/tools/multi-step-tool-use/implementing-a-multi-step-agent-with-langchain.mdx
Expand Down Expand Up @@ -179,23 +190,11 @@ navigation:
path: pages/text-generation/prompt-engineering/prompt-library/faster-web-search.mdx
- page: Multilingual interpreter
path: pages/text-generation/prompt-engineering/prompt-library/multilingual-interpreter.mdx
- section: RAG Connectors
contents:
- page: Overview
path: pages/text-generation/connectors/overview-1.mdx
- page: Creating and Deploying a Connector
path: pages/text-generation/connectors/creating-and-deploying-a-connector.mdx
- page: Managing your Connector
path: pages/text-generation/connectors/managing-your-connector.mdx
- page: Connector Authentication
path: pages/text-generation/connectors/connector-authentication.mdx
- page: Connector FAQs
path: pages/text-generation/connectors/connector-faqs.mdx
- page: Migrating from the Generate API to the Chat API
path: pages/text-generation/migrating-from-cogenerate-to-cochat.mdx
- section: Text Embeddings (Vectors, Search, Retrieval)
contents:
- page: Embeddings
- page: Introduction to Embeddings at Cohere
path: pages/text-embeddings/embeddings.mdx
- page: Batch Embedding Jobs
path: pages/text-embeddings/embed-jobs-api.mdx
Expand All @@ -205,6 +204,8 @@ navigation:
path: pages/text-embeddings/reranking/overview.mdx
- page: Rerank Best Practices
path: pages/text-embeddings/reranking/reranking-best-practices.mdx
- page: Text Classification
path: pages/text-embeddings/text-classification-1.mdx
- section: Fine-Tuning
contents:
- page: Introduction
Expand All @@ -229,7 +230,7 @@ navigation:
contents:
- page: Preparing the Classify Fine-tuning data
path: pages/fine-tuning/classify-fine-tuning/classify-preparing-the-data.mdx
- page: Starting the Classify Fine-Tuning
- page: Trains and deploys a fine-tuned model
path: pages/fine-tuning/classify-fine-tuning/classify-starting-the-training.mdx
- page: Understanding the Classify Fine-tuning Results
path: pages/fine-tuning/classify-fine-tuning/classify-understanding-the-results.mdx
Expand Down Expand Up @@ -269,22 +270,22 @@ navigation:
path: pages/integrations/integrations/redis-and-cohere.mdx
- page: Haystack and Cohere
path: pages/integrations/integrations/haystack-and-cohere.mdx
- page: Pinecone and Cohere
path: pages/integrations/integrations/pinecone-and-cohere.mdx
- page: Weaviate and Cohere
path: pages/integrations/integrations/weaviate-and-cohere.mdx
- page: Open Search and Cohere
path: pages/integrations/integrations/opensearch-and-cohere.mdx
- page: Vespa and Cohere
path: pages/integrations/integrations/vespa-and-cohere.mdx
- page: Chroma and Cohere
path: pages/integrations/integrations/chroma-and-cohere.mdx
- page: Qdrant and Cohere
path: pages/integrations/integrations/qdrant-and-cohere.mdx
- page: Weaviate and Cohere
path: pages/integrations/integrations/weaviate-and-cohere.mdx
- page: Pinecone and Cohere
path: pages/integrations/integrations/pinecone-and-cohere.mdx
- page: Milvus and Cohere
path: pages/integrations/integrations/milvus-and-cohere.mdx
- page: Zilliz and Cohere
path: pages/integrations/integrations/zilliz-and-cohere.mdx
- page: Chroma and Cohere
path: pages/integrations/integrations/chroma-and-cohere.mdx
- section: LangChain
path: pages/integrations/cohere-and-langchain.mdx
contents:
Expand Down Expand Up @@ -334,9 +335,8 @@ navigation:
path: pages/responsible-use/responsible-use/generation-benchmarks.mdx
- page: Representation Benchmarks
path: pages/responsible-use/responsible-use/representation-benchmarks.mdx
- page: Security
# LINK ELSEWHERE
path: pages/responsible-use/security.mdx
- link: Security
href: https://cohere.ai/security
- page: Environmental Impact
path: pages/responsible-use/environmental-impact.mdx
- section: Cohere for AI
Expand Down Expand Up @@ -587,9 +587,6 @@ navigation:
- page: Sending Feedback
hidden: true
path: pages/text-generation/feedback.mdx
- page: Structured Generations (JSON)
hidden: true
path: pages/text-generation/structured-outputs-json.mdx
- page: Book an appointment
hidden: true
path: pages/text-generation/prompt-engineering/prompt-library/book-an-appointment.mdx
Expand Down
2 changes: 1 addition & 1 deletion fern/openapi/cohere.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9251,7 +9251,7 @@ components:
description: |
[BETA] A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](/docs/structured-outputs-json#schema-constraints) for more information.
Example (required name and age object):
```json
```json JSON
{
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion fern/pages/-ARCHIVE-/old-tutorials/semantic-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You can find the code in the <a target="_blank" href="https://github.com/cohere-

### 1. Download the Dependencies

```python
```python PYTHON
# Install Cohere for embeddings, Umap to reduce embeddings to 2 dimensions,
# Altair for visualization, Annoy for approximate nearest neighbor search
pip install cohere umap-learn altair annoy datasets tqdm
Expand Down
4 changes: 2 additions & 2 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
import cohere

co = cohere.Client("<<apiKey>>")
Expand Down Expand Up @@ -103,7 +103,7 @@ public class ChatPost {
go get github.com/cohere-ai/cohere-go/v2
```

```go
```go
package main

import (
Expand Down
29 changes: 29 additions & 0 deletions fern/pages/cohere-api/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,32 @@ With a non-2xx response code, the response will be an error object in the follow
```

Here are code examples for how error handling might look in our SDKs:

<CodeBlocks>
```python PYTHON
try:
response = co.generate(
model='invalid-model',
prompt='sample prompt')
except cohere.CohereError as e:
print(e.message)
print(e.http_status)
print(e.headers)
```
```javascript JAVASCRIPT
(async () => {
const response = await cohere.generate({model: 'invalid-model'});

if (response.statusCode !== 200) {
console.log(response.body.message);
}
})();
```
```go GO
_, err := co.Generate(generateOptions)
if err != nil {
fmt.Println(err)
return
}
```
</CodeBlocks>
38 changes: 19 additions & 19 deletions fern/pages/cookbooks/agent-api-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ With this approach, we bring together the best of two worlds: the ability of LLM

# Step 1: Setup [#sec_step1]

```python
```python PYTHON
# Uncomment if you need to install the following packages
# !pip install cohere
# !pip install python-dotenv
# !pip install pandas
```

```python
```python PYTHON
import os
import json
import re
Expand All @@ -60,7 +60,7 @@ from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import tool
```

```python
```python PYTHON
# load the cohere api key
os.environ["COHERE_API_KEY"] = getpass.getpass()
```
Expand All @@ -70,7 +70,7 @@ os.environ["COHERE_API_KEY"] = getpass.getpass()
Here we create a tool which implements the deterministic function to extract alphanumeric strings
from the user's query and match them to the right parameter.

```python
```python PYTHON
@tool
def regex_extractor(user_query: str) -> dict:
"""Function which, given the query from the user, returns a dictionary parameter:value."""
Expand All @@ -94,7 +94,7 @@ regex_extractor.args_schema = extract_code_v1productssearch
tools=[regex_extractor]
```

```python
```python PYTHON
# Let's define the preamble for the Agent.
# The preamble includes info about:
# - the tool the Agent has access to
Expand Down Expand Up @@ -122,7 +122,7 @@ Search products sport | Search products dress and jumpsuit | [{'taxonomies': ['S
"""
```

```python
```python PYTHON
# Define the prompt
prompt = ChatPromptTemplate.from_template("{input}")
# Define the agent
Expand All @@ -140,7 +140,7 @@ agent_executor = AgentExecutor(agent=agent,
)
```

```python
```python PYTHON
# finally, let's write a function to convert the Agents output to a json
def convert_to_json(string: str) -> json:
return json.loads(
Expand All @@ -155,7 +155,7 @@ def convert_to_json(string: str) -> json:

Let's now test the Agent we just defined!

```python
```python PYTHON
query_1 = "Look for urn:75f2b737-06dd-4399-9206-a6c11b65138e, GLCMS004AGTCAMIS; 0000234GLCMS0100ANORAKCAA, GLCHL000CGUCHALE"
response_1 = agent_executor.invoke(
{
Expand All @@ -172,7 +172,7 @@ I will use the regex_extractor tool to extract the codes from the user query.
{'tool_name': 'regex_extractor', 'parameters': {'user_query': 'Look for urn:75f2b737-06dd-4399-9206-a6c11b65138e, GLCMS004AGTCAMIS; 0000234GLCMS0100ANORAKCAA, GLCHL000CGUCHALE'}}
{'nmgs': ['0000234GLCMS0100ANORAKCAA'], 'objref': ['GLCMS004AGTCAMIS', 'GLCHL000CGUCHALE'], 'urn': ['urn:75f2b737-06dd-4399-9206-a6c11b65138e']}Relevant Documents: 0
Cited Documents: 0
Answer: ```json
Answer: ```json JSON
[
    {
        "urn": ["urn:75f2b737-06dd-4399-9206-a6c11b65138e"],
Expand All @@ -181,7 +181,7 @@ Answer: ```json
    }
]
```
Grounded answer: ```json
Grounded answer: ```json JSON
[
    {
        "urn": [<co: 0>"urn:75f2b737-06dd-4399-9206-a6c11b65138e</co: 0>"],
Expand All @@ -197,7 +197,7 @@ Grounded answer: ```json
In the reasoning chain above, we can see that the Agent uses the tool we provided it to extract the strings in the query.
The output of the tool is then used to generate the request.

```python
```python PYTHON
# let's have a look at the final output
convert_to_json(response_1['output'])
```
Expand All @@ -210,7 +210,7 @@ convert_to_json(response_1['output'])

As mentioned above, the Agent can use the tool when specific alphanumeric patterns have to be extracted from the query; however, it can also generate the output based on its semantic understanding of the query. For example:

```python
```python PYTHON
query_2 = "I need tennis products"

response_2 = agent_executor.invoke(
Expand All @@ -228,7 +228,7 @@ I will use the regex_extractor tool to extract the relevant information from the
{'tool_name': 'regex_extractor', 'parameters': {'user_query': 'I need tennis products'}}
{}Relevant Documents: None
Cited Documents: None
Answer: ```json
Answer: ```json JSON
[
{
"taxonomies": [
Expand All @@ -237,7 +237,7 @@ Answer: ```json
}
]
```
Grounded answer: ```json
Grounded answer: ```json JSON
[
{
"taxonomies": [
Expand All @@ -252,7 +252,7 @@ Grounded answer: ```json

The Agent runs the tool to check if any target string was in the query, then it generated the request body based on its understanding.

```python
```python PYTHON
convert_to_json(response_2['output'])
```

Expand All @@ -262,7 +262,7 @@ convert_to_json(response_2['output'])

Finally, the two paths to generation - deterministic and semantic - can be applied in parallel by the Agent, as shown below:

```python
```python PYTHON
query_3 = "Look for GLBRL0000GACHALE, nmg 0000234GLCZD0000GUREDTOAA and car products"

response_3 = agent_executor.invoke(
Expand All @@ -280,7 +280,7 @@ I will use the regex_extractor tool to extract the codes from the user query. Th
{'tool_name': 'regex_extractor', 'parameters': {'user_query': 'Look for GLBRL0000GACHALE, nmg 0000234GLCZD0000GUREDTOAA and car products'}}
{'nmgs': ['0000234GLCZD0000GUREDTOAA'], 'objref': ['GLBRL0000GACHALE']}Relevant Documents: 0
Cited Documents: 0
Answer: ```json
Answer: ```json JSON
[
    {
        "objref": ["GLBRL0000GACHALE"],
Expand All @@ -291,7 +291,7 @@ Answer: ```json
    }
]
```
Grounded answer: ```json
Grounded answer: ```json JSON
[
    {
        "objref": [<co: 0>"GLBRL0000GACHALE</co: 0>"],
Expand All @@ -306,7 +306,7 @@ Grounded answer: ```json
> Finished chain.
````

```python
```python PYTHON
convert_to_json(response_3['output'])
```

Expand Down
Loading

0 comments on commit 0e4271e

Please sign in to comment.