generated from cheshire-cat-ai/plugin_template
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfast_setup.py
More file actions
88 lines (65 loc) · 2.43 KB
/
fast_setup.py
File metadata and controls
88 lines (65 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from cat.mad_hatter.decorators import tool, hook
from cat.log import log
@hook
def agent_prompt_prefix(prefix, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
prefix = settings["prompt_prefix"]
return prefix
@hook
def before_cat_recalls_episodic_memories(default_episodic_recall_config, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
default_episodic_recall_config["k"] = settings["episodic_memory_k"]
default_episodic_recall_config["threshold"] = settings["episodic_memory_threshold"]
return default_episodic_recall_config
@hook
def before_cat_recalls_declarative_memories(default_declarative_recall_config, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
default_declarative_recall_config["k"] = settings["declarative_memory_k"]
default_declarative_recall_config["threshold"] = settings[
"declarative_memory_threshold"
]
return default_declarative_recall_config
@hook
def before_cat_recalls_procedural_memories(default_procedural_recall_config, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
default_procedural_recall_config["k"] = settings["procedural_memory_k"]
default_procedural_recall_config["threshold"] = settings[
"procedural_memory_threshold"
]
return default_procedural_recall_config
#@hook
#def before_agent_starts(agent_input, cat):
# settings = cat.mad_hatter.get_plugin().load_settings()
# user_name = settings["user_name"]
# agent_input["chat_history"] = agent_input["chat_history"].replace(
# "- Human:", f"- {user_name}:"
# )
#
# return agent_input
@hook
def agent_prompt_suffix(suffix, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
username = settings["user_name"] if settings["user_name"] != "" else "Human"
suffix = f"""
# Context
{{episodic_memory}}
{{declarative_memory}}
{{tools_output}}
"""
if settings["language"] == "Human":
suffix += f"""
ALWAYS answer in the {username}'s language
"""
elif settings["language"] not in ["None", "Human"]:
suffix += f"""
ALWAYS answer in {settings["language"]}
"""
suffix += f"""
## Conversation until now:"""
return suffix
@hook
def rabbithole_instantiates_splitter(text_splitter, cat):
settings = cat.mad_hatter.get_plugin().load_settings()
text_splitter._chunk_size = settings["chunk_size"]
text_splitter._chunk_overlap = settings["chunk_overlap"]
return text_splitter