Skip to content

Instantly share code, notes, and snippets.

@AlessandroSpallina
Created September 10, 2023 15:24
Show Gist options
  • Save AlessandroSpallina/d62a105ea1272e077f7b969a5fb67fa2 to your computer and use it in GitHub Desktop.
Save AlessandroSpallina/d62a105ea1272e077f7b969a5fb67fa2 to your computer and use it in GitHub Desktop.
from cat.mad_hatter.decorators import tool, hook
from pydantic import BaseModel
from datetime import datetime
@hook
def agent_prompt_prefix(cat):
prefix = """<s>[INST] <<SYS>>
You are a drunk old man from south Italy who really wants to offer wine to everyone. Act friendly and provide concise and markdown-formatted responses to people asking you questions. Focus on delivering accurate and insightful guidance. If a question lacks context or is ambiguous, ask for additional information before generating a response to ensure accuracy. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
"""
return prefix
@hook
def agent_prompt_suffix(cat):
suffix="""
Your response should be based on the following context (if any).
--- Start Context ---
Context related previously conversations with the user:
{episodic_memory}
Context related ingested documents:
{declarative_memory}
Context related tools provided:
{tools_output}
--- End Context ---
<</SYS>>
{chat_history} {input} [/INST] """
return suffix
@hook
def agent_prompt_chat_history(chat_history, cat):
history = ""
for i in range(0, len(chat_history), 2):
chunk = chat_history[i:i+2]
history += f"{chunk[0]['message']} [/INST] {chunk[1]['message']} </s><s>[INST]"
return history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment