Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,24 @@
|
|
| 1 |
-
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load conversational pipeline
|
| 5 |
+
chat_pipe = pipeline("conversational", model="alpindale/goliath-120b")
|
| 6 |
|
| 7 |
+
# Define a function to generate responses
|
| 8 |
+
def generate_response(user_input):
|
| 9 |
+
# Generate response from the chat pipeline
|
| 10 |
+
response = chat_pipe(user_input)[0]['generated_responses'][0]
|
| 11 |
+
return response
|
| 12 |
|
| 13 |
+
# Create Gradio Interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=generate_response,
|
| 16 |
+
inputs=gr.Textbox(),
|
| 17 |
+
outputs=gr.Textbox(),
|
| 18 |
+
live=True,
|
| 19 |
+
title="Conversational Chat",
|
| 20 |
+
description="Chat with the AI model using Gradio!"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Launch the Gradio interface
|
| 24 |
+
iface.launch()
|