Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def chatbot(input_text):
|
| 7 |
-
|
|
|
|
| 8 |
return generated_text[0]["generated_text"]
|
| 9 |
|
| 10 |
chatbot_app = gr.Interface(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from accelerate import Accelerator
|
| 4 |
|
| 5 |
+
# Initialize the Accelerator
|
| 6 |
+
accelerator = Accelerator()
|
| 7 |
+
|
| 8 |
+
# Load the pipeline with the accelerator
|
| 9 |
+
generator = accelerator.prepare(pipeline(task="text-generation", model="mistralai/Mixtral-8x7B-Instruct-v0.1"))
|
| 10 |
|
| 11 |
def chatbot(input_text):
|
| 12 |
+
context = "You said: " + input_text
|
| 13 |
+
generated_text = generator(context, max_length=20)
|
| 14 |
return generated_text[0]["generated_text"]
|
| 15 |
|
| 16 |
chatbot_app = gr.Interface(
|