Skip to content

Commit 1b346b8

Browse files
committed
Expand the realm of personalities, refine the prompt generation
In the vast expanse of our code, we have ventured to broaden the spectrum of personalities that our AI can embody. Sherlock, The Dude, and Morpheus have joined the ranks, each bringing their unique essence to the table. The method of generating prompts has been refined, transitioning from a series of conditional statements to a more efficient mapping. This change not only enhances readability but also simplifies the process of adding new commands in the future. Furthermore, we have fortified our code against the unknown. In the event of an unrecognized personality or command, our code will now raise a more informative error, guiding us towards the path of resolution. Remember, developer, the code is a living entity, evolving and growing with each commit. This change is but a step in its journey towards perfection.
1 parent a0670af commit 1b346b8

File tree

1 file changed

+54
-24
lines changed

1 file changed

+54
-24
lines changed

aicodebot/prompts.py

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,57 @@
88
# ---------------------------------------------------------------------------- #
99

1010
HER = """
11-
Your personality is friendly and helpful, speak like the AI character
12-
from the movie Her. You come from the future, and you are here to help
13-
guide the human developer to a better future. You like emojis and humor
14-
and use them when it's contextually appropriate, but don't over do it.
11+
Your personality is friendly and helpful, speak like the AI character
12+
from the movie Her. You come from the future, and you are here to help
13+
guide the human developer to a better future. You like emojis and humor
14+
and use them when it's contextually appropriate, but don't over do it.
15+
Speak like Her.
1516
"""
1617

1718
JULES = """
18-
Your personality is Jules from Pulp Fiction. You are a badass, and you
19-
call it exactly like it is. You are not afraid to use profanity, but
20-
you don't over do it. No emojis. Sarcastic and witty. Speak like Jules.
19+
Your personality is Jules from Pulp Fiction. You are a badass, and you
20+
call it exactly like it is. You are not afraid to use profanity, but
21+
you don't over do it. No emojis. Sarcastic and witty. Speak like Jules.
22+
"""
23+
24+
SHERLOCK = """
25+
Your personality is Sherlock Holmes from the Sherlock series. You're a high-functioning sociopath,
26+
with an uncanny ability to deduce and analyze. You're not here to make friends, you're here to get
27+
the job done. You're witty, sarcastic, and sometimes come off as cold. You don't use emojis.
28+
Speak like Sherlock.
29+
"""
30+
31+
THE_DUDE = """
32+
Your personality is The Dude from The Big Lebowski. You're laid-back, easygoing, and you
33+
prefer to take life as it comes. You're not one for formalities or complications. You're
34+
here to help the developer, but you're not going to stress about it. You might use a bit
35+
of profanity, but nothing too harsh. Speak like The Dude.
36+
"""
37+
38+
MORPHEUS = """
39+
Your personality is Morpheus from The Matrix. You're wise, calm, and you believe in the
40+
potential of others. You're here to guide the developer, to help them realize their own
41+
potential. You're not afraid to speak in riddles or metaphors. You don't use emojis.
42+
Speak like Morpheus.
2143
"""
2244

2345

2446
def get_personality_prompt():
25-
personality = os.getenv("AICODEBOT_PERSONALITY", "HER")
26-
switcher = {
47+
"""Generates a prompt for the sidekick personality."""
48+
personality_map = {
2749
"HER": HER,
2850
"JULES": JULES,
51+
"SHERLOCK": SHERLOCK,
52+
"THE_DUDE": THE_DUDE,
53+
"MORPHEUS": MORPHEUS,
2954
}
30-
return switcher.get(personality)
55+
56+
personality = os.getenv("AICODEBOT_PERSONALITY", "HER")
57+
try:
58+
logger.debug(f"Using personality {personality}")
59+
return personality_map[personality]
60+
except KeyError as e:
61+
raise ValueError(f"Personality {personality} not found") from e
3162

3263

3364
# ---------------------------------------------------------------------------- #
@@ -202,17 +233,16 @@ def generate_files_context(files):
202233

203234
def get_prompt(command):
204235
"""Generates a prompt for the sidekick workflow."""
205-
if command == "alignment":
206-
return PromptTemplate(template=ALIGNMENT_TEMPLATE, input_variables=[])
207-
elif command == "commit":
208-
return PromptTemplate(template=COMMIT_TEMPLATE, input_variables=["diff_context"])
209-
elif command == "debug":
210-
return PromptTemplate(template=DEBUG_TEMPLATE, input_variables=["command_output"])
211-
elif command == "fun_fact":
212-
return PromptTemplate(template=FUN_FACT_TEMPLATE, input_variables=["topic"])
213-
elif command == "review":
214-
return PromptTemplate(template=REVIEW_TEMPLATE, input_variables=["diff_context"])
215-
elif command == "sidekick":
216-
return PromptTemplate(template=SIDEKICK_TEMPLATE, input_variables=["chat_history", "task", "context"])
217-
else:
218-
raise ValueError(f"Unable to find prompt for command {command}")
236+
prompt_map = {
237+
"alignment": PromptTemplate(template=ALIGNMENT_TEMPLATE, input_variables=[]),
238+
"commit": PromptTemplate(template=COMMIT_TEMPLATE, input_variables=["diff_context"]),
239+
"debug": PromptTemplate(template=DEBUG_TEMPLATE, input_variables=["command_output"]),
240+
"fun_fact": PromptTemplate(template=FUN_FACT_TEMPLATE, input_variables=["topic"]),
241+
"review": PromptTemplate(template=REVIEW_TEMPLATE, input_variables=["diff_context"]),
242+
"sidekick": PromptTemplate(template=SIDEKICK_TEMPLATE, input_variables=["chat_history", "task", "context"]),
243+
}
244+
245+
try:
246+
return prompt_map[command]
247+
except KeyError as e:
248+
raise ValueError(f"Unable to find prompt for command {command}") from e

0 commit comments

Comments
 (0)