Spaces:
Sleeping
Sleeping
Keira James
commited on
Commit
·
50d6a8f
1
Parent(s):
38afc93
updating again
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
8 |
|
9 |
# Function to generate a response from GPT-2
|
10 |
def generate_response(prompt):
|
|
|
11 |
inputs = tokenizer(prompt, return_tensors="pt")
|
12 |
output = model.generate(inputs['input_ids'], max_length=150)
|
13 |
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
@@ -23,7 +24,7 @@ st.write("This chatbot is your mentor to help you with learning Data Structures.
|
|
23 |
user_input = st.text_input("You:", "")
|
24 |
|
25 |
if user_input:
|
26 |
-
# Adding context to the prompt,
|
27 |
prompt = f"You are a mentor teaching data structures. Answer the following question: {user_input}"
|
28 |
response = generate_response(prompt)
|
29 |
st.text_area("Mentor's Response:", value=response, height=200, disabled=True)
|
|
|
8 |
|
9 |
# Function to generate a response from GPT-2
|
10 |
def generate_response(prompt):
|
11 |
+
# Only generate a response based on the given prompt
|
12 |
inputs = tokenizer(prompt, return_tensors="pt")
|
13 |
output = model.generate(inputs['input_ids'], max_length=150)
|
14 |
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
|
|
24 |
user_input = st.text_input("You:", "")
|
25 |
|
26 |
if user_input:
|
27 |
+
# Adding context to the prompt, but only once for the first input
|
28 |
prompt = f"You are a mentor teaching data structures. Answer the following question: {user_input}"
|
29 |
response = generate_response(prompt)
|
30 |
st.text_area("Mentor's Response:", value=response, height=200, disabled=True)
|