Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,17 @@ from transformers import pipeline
|
|
| 4 |
# Load the conversational pipeline with the "facebook/blenderbot-400M-distill" model
|
| 5 |
pipe = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
| 6 |
|
| 7 |
-
def chat_with_model(
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
response = pipe(conversation)
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
iface = gr.Interface(
|
| 13 |
fn=chat_with_model,
|
|
|
|
| 4 |
# Load the conversational pipeline with the "facebook/blenderbot-400M-distill" model
|
| 5 |
pipe = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
| 6 |
|
| 7 |
+
def chat_with_model(input_text):
|
| 8 |
+
# Start a new conversation with the user's input
|
| 9 |
+
conversation = [{"role": "user", "content": input_text}]
|
| 10 |
+
|
| 11 |
+
# Generate a response from the model
|
| 12 |
response = pipe(conversation)
|
| 13 |
+
|
| 14 |
+
# Extract the assistant's reply
|
| 15 |
+
reply = response[0]['message']['content']
|
| 16 |
+
|
| 17 |
+
return reply
|
| 18 |
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=chat_with_model,
|