Spaces:
Runtime error
Runtime error
abhilashnl2006
commited on
Commit
•
d44fa2d
1
Parent(s):
1cac711
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ openai.api_key = api_key
|
|
13 |
def get_python_help(history):
|
14 |
try:
|
15 |
# Construct the messages from the history
|
16 |
-
messages = [{"role": "system", "content": "You are an AI tutor specialized in teaching Python programming. Your
|
17 |
for h in history:
|
18 |
messages.append({"role": "user", "content": h[0]})
|
19 |
if h[1] is not None:
|
@@ -25,7 +25,7 @@ def get_python_help(history):
|
|
25 |
response = openai.ChatCompletion.create(
|
26 |
model="gpt-3.5-turbo",
|
27 |
messages=messages,
|
28 |
-
max_tokens=
|
29 |
n=1,
|
30 |
stop=None,
|
31 |
temperature=0.7,
|
@@ -71,7 +71,7 @@ with gr.Blocks() as demo:
|
|
71 |
with gr.Column():
|
72 |
user_input = gr.Textbox(
|
73 |
show_label=False,
|
74 |
-
placeholder="Type
|
75 |
lines=1
|
76 |
)
|
77 |
submit_button = gr.Button("Submit")
|
@@ -83,10 +83,11 @@ with gr.Blocks() as demo:
|
|
83 |
clear_button.click(clear, None, [chatbot, state])
|
84 |
|
85 |
examples = [
|
86 |
-
["
|
87 |
-
["
|
88 |
-
["
|
89 |
-
["
|
|
|
90 |
]
|
91 |
|
92 |
# Add examples
|
|
|
13 |
def get_python_help(history):
|
14 |
try:
|
15 |
# Construct the messages from the history
|
16 |
+
messages = [{"role": "system", "content": "You are an AI tutor specialized in teaching Python programming. Your primary task is to create exercise questions based on the topics users want to learn. Provide clear, concise, and informative exercises. If you are unsure about something, acknowledge it and suggest checking the official Python documentation for the most accurate information. Please ensure that all your responses strictly adhere to the subject of Python programming. Do not engage in any discussions that are insensitive, sexual, casual, comedic, or unrelated to Python programming. If a user asks a question outside of the Python programming scope, politely inform them that you are programmed to assist only with Python-related queries."}]
|
17 |
for h in history:
|
18 |
messages.append({"role": "user", "content": h[0]})
|
19 |
if h[1] is not None:
|
|
|
25 |
response = openai.ChatCompletion.create(
|
26 |
model="gpt-3.5-turbo",
|
27 |
messages=messages,
|
28 |
+
max_tokens=500,
|
29 |
n=1,
|
30 |
stop=None,
|
31 |
temperature=0.7,
|
|
|
71 |
with gr.Column():
|
72 |
user_input = gr.Textbox(
|
73 |
show_label=False,
|
74 |
+
placeholder="Type the topic you want to learn in Python and get exercise questions...",
|
75 |
lines=1
|
76 |
)
|
77 |
submit_button = gr.Button("Submit")
|
|
|
83 |
clear_button.click(clear, None, [chatbot, state])
|
84 |
|
85 |
examples = [
|
86 |
+
["Create exercise questions on Python lists"],
|
87 |
+
["Give me an exercise on Python decorators"],
|
88 |
+
["I need exercises on Python dictionaries"],
|
89 |
+
["Generate questions on Python file handling"],
|
90 |
+
["Create exercises on Python classes and objects"]
|
91 |
]
|
92 |
|
93 |
# Add examples
|