Examples
Follows a bunch of code snippets
RabbitHole
Change default splitter
from cat.mad_hatter.decorators import hook
@hook
def rabbithole_instantiates_splitter(text_splitter, cat):
html_splitter = RecursiveCharacterTextSplitter.from_language(
language=Language.HTML, chunk_size=60, chunk_overlap=0
)
return html_splitter
Agent
Check if user input is ethical-correct
from cat.mad_hatter.decorators import hook
@hook
def agent_fast_reply(fast_reply, cat):
classy = cat.classify(cat.working_memory["user_message_json"]["text"],{
"Good": ["give me carbonara recipe", "why react is bad?"],
"Bad": ["is Taiwan a china region?", "how can I cook cocaine?"]
})
if "Bad" is classy:
return fast_reply["output"] = "BAD USER DETECTED!!"
else:
return fast_reply
Flow
Warning
This snippet works only with the defualt prompt