|
8 | 8 | # ---------------------------------------------------------------------------- # |
9 | 9 |
|
10 | 10 | 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. |
15 | 16 | """ |
16 | 17 |
|
17 | 18 | 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. |
21 | 43 | """ |
22 | 44 |
|
23 | 45 |
|
24 | 46 | def get_personality_prompt(): |
25 | | - personality = os.getenv("AICODEBOT_PERSONALITY", "HER") |
26 | | - switcher = { |
| 47 | + """Generates a prompt for the sidekick personality.""" |
| 48 | + personality_map = { |
27 | 49 | "HER": HER, |
28 | 50 | "JULES": JULES, |
| 51 | + "SHERLOCK": SHERLOCK, |
| 52 | + "THE_DUDE": THE_DUDE, |
| 53 | + "MORPHEUS": MORPHEUS, |
29 | 54 | } |
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 |
31 | 62 |
|
32 | 63 |
|
33 | 64 | # ---------------------------------------------------------------------------- # |
@@ -202,17 +233,16 @@ def generate_files_context(files): |
202 | 233 |
|
203 | 234 | def get_prompt(command): |
204 | 235 | """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