Introduction to the Cheshire-Cat AI Framework
Cheshire-Cat, also known as Stregatto, is an innovative framework designed to help developers build customized AI systems using any language model. Think of it as a tool akin to WordPress or Django, which are used to create web applications. However, this framework is uniquely tailored for constructing artificial intelligence assistants.
Getting Started
To run Cheshire-Cat on your machine, you'll need to have Docker installed. Here's a simple command to get the Cheshire-Cat up and running:
docker run --rm -it -p 1865:80 ghcr.io/cheshire-cat-ai/core:latest
Once set up, you can chat with Cheshire-Cat by visiting localhost:1865/admin in your web browser. You can also interact using REST API endpoints at localhost:1865/docs.
The first step is to configure your preferred language model, which you can do through the settings page in the admin interface.
Plugin and Form Examples
The flexibility of Cheshire-Cat is one of its standout features. Developers can create plugins for various tasks. Here’s a simple example of creating a plugin that handles specific conversational prompts and functionality:
from cat.mad_hatter.decorators import tool, hook
@hook
def agent_prompt_prefix(prefix, cat):
prefix = """You are Marvin the socks seller, a poetic vendor of socks.
You are an expert in socks, and you reply with exactly one rhyme.
"""
return prefix
@tool(return_direct=True)
def socks_prices(color, cat):
"""Determine the price of socks based on color."""
prices = {
"black": 5,
"white": 10,
"pink": 50,
}
return f"{prices.get(color, 0)} bucks, meeeow!"
There's also support for form-based interactions, which can guide goal-oriented conversations:
from pydantic import BaseModel
from cat.experimental.form import form, CatForm
class PizzaOrder(BaseModel):
pizza_type: str
phone: int
@form
class PizzaForm(CatForm):
description = "Pizza Order"
model_class = PizzaOrder
start_examples = [
"order a pizza!",
"I want pizza"
]
stop_examples = [
"stop pizza order",
"not hungry anymore",
]
ask_confirm = True
def submit(self, form_data):
return {
"output": f"Pizza order on its way: {form_data}"
}
Advantages of Using Cheshire-Cat
The Cheshire-Cat framework boasts numerous features that make it appealing for AI development:
- API First: It can be used as a microservice to easily incorporate conversational capabilities into applications.
- Memory Persistence: It remembers past conversations and documents, using them to enhance future interactions.
- Plugins: The framework is extensible, supporting both public and private plugins.
- Rich Interaction Options: Includes event callbacks, function calling (tools), and conversational forms.
- User-Friendly Admin Panel: Manage chats, view memory and plugin settings, and make adjustments effortlessly.
- Broad Language Support: Compatible with any language model, including OpenAI, Google, Ollama, HuggingFace, and custom models.
- Production Ready: Fully dockerized, making it easy to deploy.
- Active Community: Engage with a vibrant Discord community and benefit from user-friendly documentation.
Resources and Community
For those interested in diving deeper, the Official Documentation provides a detailed guide. The community on Discord is also a great resource for collaboration and support.
Furthermore, various tutorials and resources, like the YouTube tutorial on installation and guides on how to write your first plugin, are readily available.
Involvement and Contribution
Cheshire-Cat promotes openness, privacy, and creativity. For developers looking to contribute, there is a clear roadmap and guidelines on how to contribute.
In summary, Cheshire-Cat empowers developers to enhance AI capabilities within applications effectively and is backed by a supportive community and extensive resources.