Skip to content

Commit

Permalink
Refresh get started section (#329)
Browse files Browse the repository at this point in the history
* add quickstarts - v1 and placeholder v2

* add quickstarts v2 API

* misc changes

* update quickstarts - pre snippets

* update quickstarts and other docs

* update quickstart descriptions

* update quickstart snippets

* update installation page

* remove unneeded pages

* update yml

* update description

* update some text

---------

Co-authored-by: billytrend-cohere <144115527+billytrend-cohere@users.noreply.github.com>
  • Loading branch information
mrmer1 and billytrend-cohere authored Feb 12, 2025
1 parent ced2d64 commit 540ebad
Show file tree
Hide file tree
Showing 16 changed files with 3,033 additions and 36 deletions.
72 changes: 72 additions & 0 deletions fern/pages/get-started/installation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Installation
slug: /docs/get-started-installation

description: "A guide for installing the Cohere SDK, supported in 4 different languages – Python, TypeScript, Java, and Go."
image: "../../assets/images/f1cc130-cohere_meta_image.jpg"
keywords: "Cohere, Cohere SDK, API v1"
---

## Platform options

To be able to use Cohere’s models, first choose the platform where you want to access the model from. Cohere's models are available on the following platforms:

| Platform | Description | Setup Guide |
|-----------------|-----------------------------------------------------------------------------|----------------------------------------------------------------------------|
| Cohere Platform | The fastest way to start using Cohere’s models. Hosted on Cohere infrastructure and available on our public SaaS platform. | [Sign up](https://dashboard.cohere.com/welcome/register) and get an [API key](https://dashboard.cohere.com/api-keys) (trial key available) |
| Private Deployments | For enterprises looking to deploy the Cohere stack privately on the cloud or on-prem. | [Setup guide](https://docs.cohere.com/docs/single-container-on-private-clouds) |
| Cloud deployments | Managed services from cloud providers that enable access to Cohere's models. |[Amazon Bedrock](https://docs.cohere.com/docs/amazon-bedrock#prerequisites)<br/>• [Amazon SageMaker](https://docs.cohere.com/docs/amazon-sagemaker-setup-guide#prerequisites)<br/>• [Azure AI Foundry](https://docs.cohere.com/docs/cohere-on-microsoft-azure#prerequisites)<br/>• [Oracle OCI](https://docs.cohere.com/docs/oracle-cloud-infrastructure-oci) |
## Model usage

You can then use the models via these options:

- [SDK](https://docs.cohere.com/v1/reference/about#sdks). We support the following SDKs:
- [Python](https://github.com/cohere-ai/cohere-python)
- [TypeScript](https://github.com/cohere-ai/cohere-typescript)
- [Java](https://github.com/cohere-ai/cohere-java)
- [Go](https://github.com/cohere-ai/cohere-go)
- [CLI tool](https://docs.cohere.com/v1/reference/command)
- [Playground](https://docs.cohere.com/v1/docs/playground-overview)


## Installation

To install the Cohere SDK, choose from the following 4 languages:

<Tabs>
<Tab title="Python">

```bash
pip install -U cohere
```
[Source](https://github.com/cohere-ai/cohere-python)
</Tab>

<Tab title="TypeScript">

```bash
npm i -s cohere-ai
```
[Source](https://github.com/cohere-ai/cohere-typescript)

</Tab>

<Tab title="Java">

```gradle
implementation 'com.cohere:cohere-java:1.x.x'
```
[Source](https://github.com/cohere-ai/cohere-java)

</Tab>

<Tab title="Go">

```bash
go get github.com/cohere-ai/cohere-go/v2
```

[Source](https://github.com/cohere-ai/cohere-go)

</Tab>
</Tabs>
12 changes: 4 additions & 8 deletions fern/pages/get-started/playground-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@ updatedAt: 'Wed May 29 2024 18:55:51 GMT+0000 (Coordinated Universal Time)'
---
## What is the Playground?

The [Developer Playground](https://dashboard.cohere.com/playground) is a visual interface for users to try out our APIs and iterate on prompts without writing a single line of code. Use the Playground to test your use cases and when you're ready to start building, simply click `View Code` to add Cohere's functionality to your application.
The [Cohere Playground](https://dashboard.cohere.com/playground) is a visual interface for users to try out our APIs and iterate on prompts without writing a single line of code. Use the Playground to test your use cases and when you're ready to start building, simply click `CODE` to get the code version that you can add to your application.

## Using the Playground

### Chat

The Chat API provides a natural language response to a prompt.  You can use the Chat Playground to generate text, answer a question or create content.  There is a default preamble, which you can change in the playground. The preamble and the messages are sent to the model to generate a response.
The [Chat endpoint](/reference/chat) provides a natural language response to a prompt.  You can use the Chat Playground to generate text, answer a question or create content.  There is a default preamble, which you can change in the playground. The preamble and the messages are sent to the model to generate a response.

- To write inputs that produce the best results for your use case, read our [Prompt Engineering](/docs/prompt-engineering) guide.
- Try tinkering with different [temperature](/docs/temperature)  to get different outputs.
- You can also toggle raw prompting on the playground.  If raw prompting is turned off, the user's input will be sent to the playground without any preprocessing.

<img src='../../assets/images/67f4530-Playground_-_Chat.png' />




### Embed

Using [Embed](/reference/embed) in the Playground enables users to assign numerical representations to strings and visualize comparative meaning on a 2-dimensional plane. Phrases similar in meaning should ideally be closer together on this visualization. Add a couple of your own phrases and see if the Playground visualization feels accurate to you.
The [Embed endpoint](/reference/embed) enables users to assign numerical representations to strings and visualize comparative meaning on a 2-dimensional plane. Phrases similar in meaning should ideally be closer together on this visualization. Add a couple of your own phrases and see if the Playground visualization feels accurate to you.

<img src='../../assets/images/4e876d8-Playground_-_Embed.png' />

Expand All @@ -39,7 +35,7 @@ Cohere [embeddings](/docs/embeddings) can be used to train a semantic classifier

### Classify

The Cohere [Classify](/reference/classify) endpoint enables users to create a classifier from a few labeled examples.
The [Classify endpoint](/reference/classify) enables users to create a classifier from a few labeled examples.

<img src='../../assets/images/8af00ab-Playground_-_Classify.png' />

Expand Down
209 changes: 209 additions & 0 deletions fern/pages/get-started/quickstart/rag-quickstart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
---
title: Retrieval Augmented Generation (RAG)
slug: /docs/rag-quickstart

description: "A quickstart guide for performing retrieval augmented generation (RAG) with Cohere's Command models (v1 API)."
image: "../../../assets/images/f1cc130-cohere_meta_image.jpg"
keywords: "Cohere, RAG, retrieval augmented generation, chatbot, command models"
---

Retrieval Augmented Generation (RAG) enables an LLM to ground its responses on external documents, thus improving the accuracy of its responses and minimizing hallucinations.

The Chat endpoint comes with built-in RAG capabilities such as document grounding and citation generation.

This quickstart guide shows you how to perform RAG with the Chat endpoint.

<Steps>
### Setup
First, install the Cohere Python SDK with the following command.

```bash
pip install -U cohere
```

Next, import the library and create a client.

<Tabs>
<Tab title="Cohere Platform">

```python PYTHON
import cohere

co = cohere.Client("COHERE_API_KEY") # Get your free API key here: https://dashboard.cohere.com/api-keys
```

</Tab>
<Tab title="Private Deployment">

```python PYTHON
import cohere

co = cohere.Client(
api_key="", # Leave this blank
base_url="<YOUR_DEPLOYMENT_URL>"
)
```

</Tab>

<Tab title="Bedrock">

```python PYTHON
import cohere

co = cohere.BedrockClient(
aws_region="AWS_REGION",
aws_access_key="AWS_ACCESS_KEY_ID",
aws_secret_key="AWS_SECRET_ACCESS_KEY",
aws_session_token="AWS_SESSION_TOKEN",
)

# Get the model name: https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
```
</Tab>

<Tab title="SageMaker">

```python PYTHON
import cohere

co = cohere.SagemakerClient(
aws_region="AWS_REGION",
aws_access_key="AWS_ACCESS_KEY_ID",
aws_secret_key="AWS_SECRET_ACCESS_KEY",
aws_session_token="AWS_SESSION_TOKEN",
)
```
</Tab>

<Tab title="Azure AI">

```python PYTHON
import cohere

co = cohere.Client(
api_key="AZURE_API_KEY",
base_url="AZURE_ENDPOINT",
)
```
</Tab>

</Tabs>

### Documents

First, define the documents that will passed as the context for RAG. These documents are typically retrieved from sources such as vector databases via semantic search, or any system that can retrieve unstructured data given a user query.

Each document can take any number of fields e.g. `title`, `url`, `text`, etc.

```python PYTHON
documents = [
{
"text": "Reimbursing Travel Expenses: Easily manage your travel expenses by submitting them through our finance tool. Approvals are prompt and straightforward."
},
{
"text": "Health and Wellness Benefits: We care about your well-being and offer gym memberships, on-site yoga classes, and comprehensive health insurance."
},
]
```
### Response Generation

Next, call the Chat API by passing the documents in the `documents` parameter. This tells the model to run in RAG-mode and use these documents as the context in its response.

<Tabs>
<Tab title="Cohere Platform">
```python PYTHON
message = "Are there fitness-related benefits?"

response = co.chat(
model="command-r-plus-08-2024",
message=message,
documents=documents
)

print(response.text)
```
</Tab>

<Tab title="Private Deployment">
```python PYTHON
message = "Are there fitness-related benefits?"

response = co.chat(
model="command-r-plus-08-2024",
message=message,
documents=documents
)

print(response.text)
```
</Tab>

<Tab title="Bedrock">
```python PYTHON
message = "Are there fitness-related benefits?"

response = co.chat(
model="YOUR_MODEL_NAME",
message=message,
documents=documents
)

print(response.text)
```
</Tab>

<Tab title="SageMaker">
```python PYTHON
message = "Are there fitness-related benefits?"

response = co.chat(
model="YOUR_ENDPOINT_NAME",
message=message,
documents=documents
)

print(response.text)
```
</Tab>

<Tab title="Azure AI">
```python PYTHON
message = "Are there fitness-related benefits?"

response = co.chat(
message=message,
documents=documents
)

print(response.text)
```
</Tab>
</Tabs>

```mdx wordWrap
Yes, we offer gym memberships, on-site yoga classes, and comprehensive health insurance.

```

### Citation Generation

The response object contains a `citations` field, which contains specific text spans from the documents on which the response is grounded.

```python PYTHON
if response.citations:
for citation in response.citations:
print(citation, "\n")
```

```mdx wordWrap
start=14 end=88 text='gym memberships, on-site yoga classes, and comprehensive health insurance.' document_ids=['doc_1']

```

</Steps>

## Further Resources
- [Chat endpoint API reference](https://docs.cohere.com/v1/reference/chat)
- [Documentation on RAG](https://docs.cohere.com/v1/docs/retrieval-augmented-generation-rag)
- [LLM University module on RAG](https://cohere.com/llmu#rag)
Loading

0 comments on commit 540ebad

Please sign in to comment.