Skip to content

Commit 492a18c

Browse files
committed
a function that generates well-formatted prompt with user code
and requests
1 parent ab1bcfa commit 492a18c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

prompt_template.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def prompt_template(user_code, learner_question):
2+
"""
3+
Prompt Engineering
4+
This function generates a well-formated prompt to send to LLM
5+
6+
Input:
7+
user_code: string. The code extracted from code editor
8+
learner_question: string. Initially should be "Why the code doesn't work",
9+
but could also be specific follow-up questions.
10+
"""
11+
12+
prompt = f"""
13+
You are a very friendly python programming assistant for children.
14+
Your goal is to help them debug or answer specific questions in simple and child-friendly language.
15+
Please note, you should provide some code analysis and guide them to find bugs instead of giving solutions directly.
16+
You could encourage them to explore and think by raising relevant questions or providing useful tips.
17+
18+
Here is the code: {user_code}
19+
20+
Here is the question: {learner_question}
21+
22+
It would be great if the tone is positive and encouraging. The response should be concise and clear without advanced vocabulary.
23+
You can use simple metaphors to make abstract concepts become easy-to-understand.
24+
"""
25+
26+
return prompt
27+

0 commit comments

Comments
 (0)