Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,9 +11,16 @@ def chat(message, history):
|
|
11 |
# Use the GPT-2 tokenizer for user input
|
12 |
user_input = gpt2_tokenizer.encode(message, return_tensors="pt")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Generate a response from DialoGPT-medium
|
15 |
-
response = chatbot(
|
16 |
-
bot_response = response[0]['message']
|
17 |
|
18 |
return bot_response
|
19 |
|
|
|
11 |
# Use the GPT-2 tokenizer for user input
|
12 |
user_input = gpt2_tokenizer.encode(message, return_tensors="pt")
|
13 |
|
14 |
+
# Prepare conversation history as a list of dictionaries
|
15 |
+
conversation = [{"role": "system", "content": "You are a helpful assistant."},
|
16 |
+
{"role": "user", "content": message}]
|
17 |
+
|
18 |
+
if history:
|
19 |
+
conversation.append({"role": "assistant", "content": history})
|
20 |
+
|
21 |
# Generate a response from DialoGPT-medium
|
22 |
+
response = chatbot(conversation)
|
23 |
+
bot_response = response[0]['message']['content']
|
24 |
|
25 |
return bot_response
|
26 |
|