Skip to content

Commit

Permalink
Merge pull request #183 from sambarza/small-fix
Browse files Browse the repository at this point in the history
Small fix
  • Loading branch information
pieroit authored Sep 7, 2024
2 parents 8f41b76 + 38c952f commit e170070
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 80 deletions.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ nav:
- Creating a Plugin: quickstart/prepare-plugin.md
- Writing the first Tool: quickstart/writing-tool.md
- Writing the first Hook: quickstart/writing-hook.md
- Stopping the Cat: quickstart/stopping-the-cat.md
- Conclusion: quickstart/conclusion.md

- Plugins:
- Plugin: plugins/plugins.md
Expand Down
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion mkdocs/production/administrators/env-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Core can be configured using environment variables, the values are read duri
To set environment variables:

- Create a file named `.env` at the same level of the `compose.yml` file.
- Here is a [`.env.example` file](https://github.com/cheshire-cat-ai/core/blob/main/.env.example) you can use as a reference.
- [Here](https://github.com/cheshire-cat-ai/core/blob/main/.env.example){:target="_blank"} there is a example you can use as a reference.
- Add to `compose.yml` the command to read the `.env`:

```yml hl_lines="5 6"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# 🚀 Stopping the Cat
# 🚀 Conclusion

## Stopping the Cat
Congratulations on completing the quickstart! You should now have an overview of how to install the Cat and its main capabilities!

When you're done using the Cat, stop the terminal by clicking on it and press `CTRL + c`. Then, run the command:

```bash
docker compose down
```

We want to remind you that Long-Term Memory is a locally persisted memory.
When you restart the Cat, all conversation history and uploaded documents will still be there.

## Next Step

Congratulations on completing the quickstart!
## What's Next?

We encourage you to explore the Cat further and try writing and publishing your own plugins to enhance your experience.

Expand Down
47 changes: 32 additions & 15 deletions mkdocs/quickstart/installation-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Hence, when you run the Cat for the first time, you need to configure the LLM an
Most people use [ChatGPT](https://platform.openai.com/docs/models/gpt-3-5), it's quite cheap and powerful enough.
We will do the same during the next steps.

To use `ChatGPT`, you need an API key. You can request one on the provider's website:
- visit your OpenAI [API Keys](https://platform.openai.com/account/api-keys) page;
- create an API key with `+ Create new secret key` and copy it
To use `ChatGPT`, you need an API key. You can request one on the provider's website:

- visit your OpenAI [API Keys](https://platform.openai.com/account/api-keys){:target="_blank"} page
- create an API key with `+ Create new secret key` and copy it

## Setup

Create a folder on your machine, and inside it create a file named `compose.yml`.
Create a folder on your machine, we will use `cheshire-cat-ai`, and inside it create a file named `compose.yml`.
Copy/paste the following inside:

```yaml
Expand All @@ -26,7 +27,7 @@ services:
container_name: cheshire_cat_core
ports:
- 1865:80
- 5678:5678 # only for development purposes (take away in production)
- 5678:5678
volumes:
- ./static:/app/cat/static
- ./plugins:/app/cat/plugins
Expand All @@ -35,28 +36,33 @@ services:
## Starting the Cat
- Open a terminal inside the same folder and run:
- Open a terminal inside the new folder and run:
```bash
docker compose up
```

The first time you run the `docker compose up` command,
it will take several minutes to pull the Docker Cat image depending on network connection.
The first time you run the `docker compose up` command, it will take several minutes to pull the Docker Cat image depending on network connection. Once the download is complete, the startup process will begin.

When you see the fantastic Cheshire Cat logo in terminal, it means that everything it's up and running!

You will see three new folders:
![Up and running](../assets/img/quickstart/installation-configuration/up-and-running.png){: style="height:50%;width:50%"}

Inside the new folder, you will see three newly created directories:

- `data`: where long term memory and settings are stored
- `plugins`: where you can install and develop plugins
- `plugins`: where we will install and develop plugins
- `static`: folder to serve static files from

These directories will retain your work even if the container is deleted.

## Stopping the Cat

Stop the terminal with `CTRL + c` and run `docker compose down`.
Stop the terminal with `CTRL + C`.

## Useful commands
## Starting the Cat in background

To start the container in background mode, use the `--detach` or `-d` flag to the command, as:
Now start again the container but in background mode, use the `--detach` or `-d` flag to the command, as:
```
docker compose up -d
```
Expand All @@ -68,10 +74,21 @@ To check the logs do the following:
docker compose logs -f
```

To stop the container, use this command in a separate terminal session:

```
docker compose down
```

## First configuration of the LLM

- Open the Admin Portal in your browser at [`localhost:1865/admin`](http://localhost:1865/admin){:target="_blank"}
- Configure the LLM in the `Settings` tab and paste your API key ([video](../assets/vid/setup.mp4))
- Start the Cat if it's stopped
- Open the `Admin Portal` in your browser at [`localhost:1865/admin`](http://localhost:1865/admin){:target="_blank"}
- Authenticate as administrator with user `admin` and password `admin`:
![alt text](../assets/img/quickstart/installation-configuration/logon.png){: style="height:50%;width:50%"}
- In the `Settings` tab configure the `Large Language Model` and the `Embedder` and paste your API key:
![alt text](../assets/img/quickstart/installation-configuration/configure-llm-embedder.png){: style="height:50%;width:50%"}
[video here](../assets/vid/setup.mp4)

## Next step
In the [next step](./play-with-the-cat.md), you will learn how to play with the Cat.
57 changes: 23 additions & 34 deletions mkdocs/quickstart/play-with-the-cat.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Play with the Cat

## Requirements

Ensure that the Cat is installed and running, and the LLM is configured.

## Chatting with the Cat: the Admin Portal playground

The Cat is an API-first framework, and it doesn't provide a ready-to-use UI for the end user.
Expand All @@ -27,61 +23,54 @@ You have learned how to use the playground to test your AI via the Admin Portal.

The Cat is an API-first framework, you can chat with it using the WebSocket protocol.

Here is an example of how to use it:
First, set the API key by creating a file named `.env` in the same folder as the `compose.yml` file with the following content. Then, restart the Cat with `docker compose down` followed by `docker compose up`.
```
CCAT_API_KEY_WS=meow_secret
```

Here is an example of how to use it in Python:

```python
import asyncio
import websockets
import json

from websockets.asyncio.client import connect


async def cat_chat():
# Creating a websocket connection
async with websockets.connect("ws://localhost:1865/ws") as websocket:
async with connect("ws://localhost:1865/ws?token=meow_secret") as websocket:

# Taking user input and sending it through the websocket
user_input = input("Human: ")
await websocket.send(json.dumps(
{
"text": user_input
}
))
await websocket.send(json.dumps({"text": user_input}))

# Receiving and printing the cat's response
cat_response = json.loads(await websocket.recv())
async for message in websocket:
cat_response = json.loads(message)

print("Cheshire Cat:", json.dumps(cat_response, indent=4))
if cat_response["type"] == "chat":
print("Cheshire Cat:", cat_response["content"])
break


# Running the function until completion
asyncio.get_event_loop().run_until_complete(cat_chat())
asyncio.run(cat_chat())
```

Run it and ask `what do you know about socks?` again, the output in the terminal should looks like:

```bash
python3 test.py
```
python main.py
Human: what do you know about socks?
Cheshire Cat: {
"error": false,
"type": "chat",
"content": "Ah, socks! They're quite fascinating little things, aren't they? Well, let me tell you what I know about socks. They come in all shapes, sizes, and colors, and they're usually worn on the feet to keep them warm and cozy. Some people like their socks plain and simple, while others prefer them with funky patterns or cute designs. Socks can be made from different materials like cotton, wool, or even synthetic fibers. They can also have different lengths, from ankle socks to knee-highs. And let's not forget about those toe socks that give each little piggy its own little cozy home! So, there you have it, a little glimpse into the world of socks. Is there anything specific you'd like to know about them?",
"why": {
"input": "what do you know about socks?",
"intermediate_steps": null,
"memory": {
"episodic": [],
"declarative": [],
"procedural": []
}
}
}
Cheshire Cat: Socks, my dear, are like the hidden wonders of the wardrobe! They can be plain or patterned, warm or cool, and often seem to vanish into thin air. Do you have a favorite pair?
```

This example explains the **Raw** use of the Cat APIs, however there are convinient and ready-made libraries available for various languages!
#### More Info

These are client libraries for different languages to speed up the connection with the Cat:
[`Production -> Client Libraries`](../production/network/clients.md)
This example explains the **Raw** use of the Cat APIs, however there are convenient and ready-made libraries available for various languages! [`Production → Client Libraries`](../production/network/clients.md)

For more methods of authentication look at [`Production → Authentication`](../production/auth/authentication.md)

## Next Step
In the [next step](./upload-document.md), you will learn how to load information into the Cat by uploading documents.
22 changes: 13 additions & 9 deletions mkdocs/quickstart/prepare-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ You don't distribute a `Tool` or a `Hook` directly, you will distribute a Plugin

## Creating the Plugin

To create a plugin just create a new folder in `core/cat/plugins/`, for our first plugin the folder name will be `poetic_sock_seller`.
To create a plugin just create a new subfolder in directory `plugins/`, for our first plugin the folder name will be `poetic_sock_seller`.

You need two files in your plugin folder:

├── core
│ ├── cat
│ │ ├── plugins
| | | ├── poetic_sock_seller
| | | | ├ poetic_sock_seller.py
| | | | ├ plugin.json
```
cheshire-cat-ai
├── compose.yml
├── data
├── plugins
│   └── poetic_sock_seller
│   ├── plugin.json
│   └── poetic_sock_seller.py
└── static
```

The `plugin.json` file contains plugin's title and description, and is useful in the Admin Portal to recognize the plugin and activate/deactivate it.

Expand All @@ -40,8 +44,8 @@ Your empty plugin will be there, activate it:

Here the plugins reference: [`Plugins`](../plugins/plugins.md)

If you plan to publish your plugin, also take a look at this [`Plugins -> Registry`](../plugins/plugins-registry/plugin-from-template.md)
If you plan to publish your plugin, also take a look at this [`Plugins Registry`](../plugins/plugins-registry/plugin-from-template.md)

## Next Step

In the [next step](./writing-tool.md), you will learn how to create your first `Tool`.
In the [next step](./writing-tool.md), you will learn how to create your first `Tool` inside the plugin.
9 changes: 4 additions & 5 deletions mkdocs/quickstart/writing-hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ The attached code will be invoked during the flow's execution and can modify the

## Transform the Cat into a Poetic Socks Seller

At the moment, if you ask the Cat “who are you?”, he will present himself as the Cheshire Cat AI.
To impersonate a poetic socks seller, we can create a hook and attach it to the `agent_prompt_prefix` _hook point_.

TODO: "hook point" what is this? "hook definition"?
At the moment, if you ask the Cat 'Who are you?', it will introduce itself as the Cheshire Cat AI.
To change the Cat's personality, for example, to make it a poetic socks seller, you can use the `agent_prompt_prefix` hook.
Copy and append the following source code to the file `poetic_sock_seller.py`:

```python
from cat.mad_hatter.decorators import hook
Expand Down Expand Up @@ -63,4 +62,4 @@ The plugin management flow also is customizable (using the `plugin` decorator in

## Next Step

In the [next step](./stopping-the-cat.md), you will learn how to `stop the cat`.
In the [next step](./conclusion.md), we will summarizes and wraps up.
2 changes: 1 addition & 1 deletion mkdocs/quickstart/writing-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Feel free to make changes within the code and observe the results.

Tools reference: [Plugins → Tools](../plugins/tools.md)

Sometimes debugging can be necessary, please refer to the [`Plugins -> Debugging`](../plugins/debugging/vscode.md) section for more information.
Sometimes debugging can be necessary, please refer to the [`Plugins Debugging`](../plugins/debugging/vscode.md) section for more information.

## Next Step

Expand Down

0 comments on commit e170070

Please sign in to comment.