Skip to content

Commit

Permalink
refactor(file tree): moved md files
Browse files Browse the repository at this point in the history
  • Loading branch information
valentimarco committed Jun 23, 2024
1 parent 9c22420 commit 0c4d42f
Show file tree
Hide file tree
Showing 62 changed files with 211 additions and 174 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ There is a [dedicated channel for Docs on our official Discord](https://discord.

### 🪝 Hooks documentation

To help documenting the [hooks table](./mkdocs/technical/plugins/hooks.md#available-hooks), ensure these elements are not missing and please keep the order:
To help documenting the [hooks table](mkdocs/plugins/hooks.md#available-hooks), ensure these elements are not missing and please keep the order:

1. Annotation number with bold heading
2. *Input arguments* description with *code snippet* example
Expand Down
94 changes: 47 additions & 47 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,77 +36,77 @@ nav:
- Playing with the Cat: quickstart/play-with-the-cat.md
# - Interacting using APIs: quickstart/interact-using-api.md
- Uploading a Document: quickstart/upload-document.md
- Installing a Plugin: plugins-registry/installing-plugin.md
- Installing a Plugin: quickstart/installing-plugin.md
- 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

- Plugins:
- Plugin: technical/plugins/plugins.md
- Tools: technical/plugins/tools.md
- Hooks: technical/plugins/hooks.md
- Forms: technical/plugins/forms.md
- Logging: technical/plugins/logging.md
- Settings: technical/plugins/settings.md
- Dependencies: technical/plugins/dependencies.md
- Python Reference: technical/API_Documentation/
- Plugin: plugins/plugins.md
- Tools: plugins/tools.md
- Hooks: plugins/hooks.md
- Forms: plugins/forms.md
- Logging: plugins/logging.md
- Settings: plugins/settings.md
- Dependencies: plugins/dependencies.md
- Python Reference: API_Documentation/
- Registry:
- Using the Plugin Template: plugins-registry/plugin-from-template.md
- Publishing a Plugin: plugins-registry/publishing-plugin.md
- Using the Plugin Template: plugins/plugins-registry/plugin-from-template.md
- Publishing a Plugin: plugins/plugins-registry/publishing-plugin.md
- Debugging:
- Visual Studio Code: technical/debugging/vscode.md
- Visual Studio Code: plugins/debugging/vscode.md

- Framework:
- LLM Concepts:
- Language Models: llm-concepts/llm.md
- Retrieval Augmented Generation: llm-concepts/rag.md
- Prompt: llm-concepts/prompt.md
- Encoder: llm-concepts/embedder.md
- Vector Memory: llm-concepts/vector-memory.md
- Language Models: framework/llm-concepts/llm.md
- Retrieval Augmented Generation: framework/llm-concepts/rag.md
- Prompt: framework/llm-concepts/prompt.md
- Encoder: framework/llm-concepts/embedder.md
- Vector Memory: framework/llm-concepts/vector-memory.md
- Cat Components:
- The Core: conceptual/cheshire_cat/core.md
- The Core: framework/conceptual/cheshire_cat/core.md
- The Agent:
- Introduction: conceptual/cheshire_cat/agent.md
- Tool Chain: conceptual/cheshire_cat/tool_chain.md
- Memory Chain: conceptual/cheshire_cat/memory_chain.md
- Introduction: framework/conceptual/cheshire_cat/agent.md
- Tool Chain: framework/conceptual/cheshire_cat/tool_chain.md
- Memory Chain: framework/conceptual/cheshire_cat/memory_chain.md
- The Prompts:
- Main Prompt: conceptual/prompts/main_prompt.md
- Instruction Prompt: conceptual/prompts/instructions.md
- Main Prompt: framework/conceptual/prompts/main_prompt.md
- Instruction Prompt: framework/conceptual/prompts/instructions.md
- The Vector Memory:
- Vector Memory Collections: conceptual/memory/vector_memory.md
- Vector Memory Collections: framework/conceptual/memory/vector_memory.md
- The Long Term Memory:
- Introduction: conceptual/memory/long_term_memory.md
- Episodic Memory: conceptual/memory/episodic_memory.md
- Declarative Memory: conceptual/memory/declarative_memory.md
- Procedural Memory: conceptual/memory/procedural_memory.md
- The Working Memory: conceptual/memory/working_memory.md
- The Rabbit Hole: conceptual/cheshire_cat/rabbit_hole.md
- The Mad Hatter: conceptual/cheshire_cat/mad_hatter.md
- Introduction: framework/conceptual/memory/long_term_memory.md
- Episodic Memory: framework/conceptual/memory/episodic_memory.md
- Declarative Memory: framework/conceptual/memory/declarative_memory.md
- Procedural Memory: framework/conceptual/memory/procedural_memory.md
- The Working Memory: framework/conceptual/memory/working_memory.md
- The Rabbit Hole: framework/conceptual/cheshire_cat/rabbit_hole.md
- The Mad Hatter: framework/conceptual/cheshire_cat/mad_hatter.md
- Technical Diagrams:
- The Cat Bootstrap: technical/flows/cat-bootstrap.md
- Chatting with the Cat: technical/flows/chatting-with-the-cat.md
- Plugins Lifecycle: technical/flows/plugins-lifecycle.md
- The Cat Bootstrap: framework/flows/cat-bootstrap.md
- Chatting with the Cat: framework/flows/chatting-with-the-cat.md
- Plugins Lifecycle: framework/flows/plugins-lifecycle.md

- Production:
- Client Libraries:
- Python: technical/clientlib/clientlib-python.md
- TypeScript: technical/clientlib/clientlib-typescript.md
- PHP: technical/clientlib/clientlib-php.md
- Ruby: technical/clientlib/clientlib-ruby.md
- C#: technical/clientlib/clientlib-csharp.md
- Python: production/clientlib/clientlib-python.md
- TypeScript: production/clientlib/clientlib-typescript.md
- PHP: production/clientlib/clientlib-php.md
- Ruby: production/clientlib/clientlib-ruby.md
- C#: production/clientlib/clientlib-csharp.md
- Administrations:
- Architecture: administrators/architecture.md
- Environment Variables: administrators/env-variables.md
- User Management: technical/advanced/user_system.md
- Automatic Tests: technical/advanced/tests.md
- Architecture: production/administrators/architecture.md
- Environment Variables: production/administrators/env-variables.md
- User Management: production/advanced/user_system.md
- Automatic Tests: production/advanced/tests.md
- Use Cases:
- Cat as Main product: use-cases/main-product.md
- Cat as Sidecar of your product: use-cases/side-car.md
- Cat as Discord BOT: use-cases/discord-bot.md
- Cat as Main product: production/use-cases/main-product.md
- Cat as Sidecar of your product: production/use-cases/side-car.md
- Cat as Discord BOT: production/use-cases/discord-bot.md
- Guides:
# - How to update the Cat Core: guides/update-the-core.md
- How to backup the Long Term Memory: technical/advanced/memory_backup.md
- How to backup the Long Term Memory: production/advanced/memory_backup.md

- FAQ: faq.md
# - Altro:
Expand Down
3 changes: 0 additions & 3 deletions mkdocs/conceptual/cheshire_cat/core.md

This file was deleted.

8 changes: 0 additions & 8 deletions mkdocs/conceptual/cheshire_cat/rabbit_hole.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When suitable tools for the task at hand are retrieved from the [procedural memo
the Agent Manager calls the Tool Agent to execute the tool chain; otherwise the memory chain is executed to answer the user's
question with the context retrieved from the episodic and declarative [memories](../memory/long_term_memory.md).

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/agent-manager.jpg){width=400px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/agent-manager.jpg){width=400px style="display: block; margin: 0 auto"}

Specifically, the default execution pipeline is the following:

Expand Down
3 changes: 3 additions & 0 deletions mkdocs/framework/conceptual/cheshire_cat/core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The Core

![Schema of the Cheshire Cat components](../../../assets/img/diagrams/components.png){width=600px style="display: block; margin: 0 auto"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Mad Hatter generated by Midjourney](../../assets/img/mad_hatter_10.png)
![Mad Hatter generated by Midjourney](../../../assets/img/mad_hatter_10.png)

# Mad Hatter

Expand All @@ -9,6 +9,6 @@ Specifically, the Mad Hatter lists all available plugins in proper folder and so
When the Cat invokes them, it executes them following that order.

!!! note "Developer documentation"
- [How to write a plugin](../../technical/plugins/plugins.md)
- [Hooks](../../technical/plugins/hooks.md)
- [Tools](../../technical/plugins/tools.md)
- [How to write a plugin](../../../plugins/plugins.md)
- [Hooks](../../../plugins/hooks.md)
- [Tools](../../../plugins/tools.md)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The Memory Chain is a simple chain that takes the user's input and the context r
[memories](../memory/long_term_memory.md) and formats them in the [main prompt](../prompts/main_prompt.md). Such prompt
is submitted to the language model.

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/memory-chain.jpg){width=650px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/memory-chain.jpg){width=650px style="display: block; margin: 0 auto"}
8 changes: 8 additions & 0 deletions mkdocs/framework/conceptual/cheshire_cat/rabbit_hole.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Rabbit Hole

The Rabbit Hole is the Cat's component that takes care of ingesting documents and storing them in the [declarative memory](../memory/long_term_memory.md).
You can interact with it either through its [endpoint](../../../technical/basics/basics.md), the [GUI](../../../technical/basics/admin/admin-interface.md) or a Python script.

Currently supported file formats are: `.txt`, `.md`, `.pdf` or `.html` via web URL.

![Schema of the Cheshire Cat components](../../../assets/img/diagrams/rabbithole.jpg){width=400px style="display: block; margin: 0 auto"}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ from the Cat's [procedural memory](../memory/long_term_memory.md).
The tools selection and usage is planned according to a set of [instructions](../prompts/main_prompt.md#instructions).
Finally, the Tool Agent parses the formatting of the tool output.

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/tool-chain.jpg){width=650px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/tool-chain.jpg){width=650px style="display: block; margin: 0 auto"}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ For instance, measuring the distance between two points can inform us about the
## Language Models flow :material-information-outline:{ title="click on the nodes with hooks to see their documentation" }

!!! note "Developer documentation"
[Language Models hooks](../technical/API_Documentation/mad_hatter/core_plugin/hooks/models.md)
[Language Models hooks](../../API_Documentation/mad_hatter/core_plugin/hooks/models.md)

Nodes with the 🪝 point the execution places where there is an available [hook](../technical/plugins/plugins.md) to customize the execution pipeline.
Nodes with the 🪝 point the execution places where there is an available [hook](../../plugins/plugins.md) to customize the execution pipeline.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The *Declarative Memory* contains uploaded documents' content. It is stored in a

The `declarative memory` is a key component in the [memory chain](../cheshire_cat/memory_chain.md).

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/declarative-memory.jpg){width=550px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/declarative-memory.jpg){width=550px style="display: block; margin: 0 auto"}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The *Episodic Memory* contains user and eventually cat utterances. It is stored

The `episodic memory` is a key component in the [memory chain](../cheshire_cat/memory_chain.md).

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/episodic-memory.jpg){width=550px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/episodic-memory.jpg){width=550px style="display: block; margin: 0 auto"}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ The name of this memory is `Long Term Memory` (LTM), it is made of three compone
- [*Declarative Memory*](declarative_memory.md), contains an extract of documents uploaded to the Cat;
- [*Procedural Memory*](procedural_memory.md), contains the set of Python functions that defines what the Cat is able to do.

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/ltm.jpg){width=450px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/ltm.jpg){width=450px style="display: block; margin: 0 auto"}


During conversation between the Cat and the user, the memories are accessed by the Cat to retrieve relevant context for passing to the LLM and are updated when the LLM responds (details of the read and write flow of the Long Term Memory can be found in this [diagram](../../../technical/flows/chatting-with-the-cat/)).
During conversation between the Cat and the user, the memories are accessed by the Cat to retrieve relevant context for passing to the LLM and are updated when the LLM responds (details of the read and write flow of the Long Term Memory can be found in this [diagram](../../flows/chatting-with-the-cat.md)).

The retrieved relevant context is used to make up the [Main prompt](../prompts/main_prompt.md) and the Instruction prompt.

You can interact with the LTM using the [memory](../../technical/basics/admin/memory.md) page of the Admin Portal.
You can interact with the LTM using the [memory](../../../technical/basics/admin/memory.md) page of the Admin Portal.

Check about `long term memory` [backup](../../technical/advanced/memory_backup.md) to prevent loosing `cat` memories.
Check about `long term memory` [backup](../../../technical/advanced/memory_backup.md) to prevent loosing `cat` memories.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

The *Procedural Memory* contains tools and knowledge on how to do things. It is stored in a vector memory collection together with `declarative` and `episodic` memories.

To dive into `procedural memory` and `tool docstrings` reference the [tool basics](../../quickstart/writing-tool.md) page.
To dive into `procedural memory` and `tool docstrings` reference the [tool basics](../../../quickstart/writing-tool.md) page.

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/procedural-memory.jpg){width=550px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/procedural-memory.jpg){width=550px style="display: block; margin: 0 auto"}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Additionally, it collects relevant context from the *episodic*, *declarative* an

The Working Memory can be used also to store custom data during a session. This capability is essential for creating a [state machine](#use-the-working-memory-as-a-state-machine) within your own plugin.

![Schema of the Cheshire Cat memories](../../assets/img/diagrams/working-memory.jpg){width=500px style="display: block; margin: 0 auto"}
![Schema of the Cheshire Cat memories](../../../assets/img/diagrams/working-memory.jpg){width=500px style="display: block; margin: 0 auto"}

## Interacting with the Working Memory

Expand Down Expand Up @@ -55,13 +55,13 @@ One of the most powerful features of the Working Memory is its ability to functi

Each time you send a message to the Cat, it stores useful data in the Working Memory, which can be retrieved to produce the output for the next message. This, along with the ability to store custom data throughout the session, is the key to implementing your specific agent in a more programmatic way.

An example of this usage in the Cheshire Cat is the [Conversational Form](../../technical/plugins/forms.md) which provides a well-crafted and comprehensive state machine to guide both the user and LLM during the conversation.
An example of this usage in the Cheshire Cat is the [Conversational Form](../../../plugins/forms.md) which provides a well-crafted and comprehensive state machine to guide both the user and LLM during the conversation.

### Example of the Working Memory as a State Machine

Given that the Conversational Form state-machine implementation is quite advanced, let's create a simpler example: a technical support agent for the Cheshire Cat.

First of all, we need to create a new plugin. [Plugin? Is that some kind of exotic dish?](../../quickstart/prepare-plugin.md)
First of all, we need to create a new plugin. [Plugin? Is that some kind of exotic dish?](../../../quickstart/prepare-plugin.md)

Once there, we need to define what are the states of our conversation. This can be done by creating a `SupportRequest` enum. Like so:

Expand All @@ -74,7 +74,7 @@ class SupportRequest(Enum):
ASK_HELP = 3
```

Now, we need to build a state machine to manage the conversation flow without blocking users who do not require support. To achieve this, we will use the [`agent_fast_reply`](../../technical/plugins/hooks.md#available-hooks) hook. This hook will check if a support request has already been initiated in the current session using the Working Memory. If no request exists, it will classify the user input as either support-related or not. If it is, the request state will begin to be tracked in the Working Memory.
Now, we need to build a state machine to manage the conversation flow without blocking users who do not require support. To achieve this, we will use the [`agent_fast_reply`](../../../plugins/hooks.md#available-hooks) hook. This hook will check if a support request has already been initiated in the current session using the Working Memory. If no request exists, it will classify the user input as either support-related or not. If it is, the request state will begin to be tracked in the Working Memory.

```python

Expand Down Expand Up @@ -126,8 +126,8 @@ Now we can write some code to control the conversation flow in a more granular a

```

As you've noticed, this state machine is quite basic and does not include comprehensive features such as handling conversation exits. Additionally, strict control flow chatbot like this belong to an older generation of chatbot design.
As you've noticed, this state machine is quite basic and does not include comprehensive features such as handling conversation exits. Additionally, strict control flow chatbot like this belong to an older generation of chatbot design.

For a more dynamic and stateful approach you can check the [Conversational Form](https://github.com/CheshireCatAI/conversational-forms).
For a more dynamic and stateful approach you can check the [Conversational Form](https://github.com/CheshireCatAI/conversational-forms).

Nevertheless, if you need complete control over your conversation flow, you can extend this example by incorporating more dynamic steps, interactions with LLMs, and other features.
Nevertheless, if you need complete control over your conversation flow, you can extend this example by incorporating more dynamic steps, interactions with LLMs, and other features.
Loading

0 comments on commit 0c4d42f

Please sign in to comment.