Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
-
|
| 4 |
"text-generation",
|
| 5 |
model="Nexusflow/NexusRaven-V2-13B",
|
| 6 |
torch_dtype="auto",
|
| 7 |
device_map="auto",
|
| 8 |
)
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
gr.Markdown(title)
|
| 21 |
-
gr.Markdown(description)
|
| 22 |
-
with gr.Row():
|
| 23 |
-
with gr.Column():
|
| 24 |
-
input = gr.Textbox()
|
| 25 |
-
with gr.Column():
|
| 26 |
-
output = gr.Textbox()
|
| 27 |
-
image_input.change(process_image, inputs=image_input, outputs=output)
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
|
|
|
| 30 |
app.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
raven_pipeline = pipeline(
|
| 5 |
"text-generation",
|
| 6 |
model="Nexusflow/NexusRaven-V2-13B",
|
| 7 |
torch_dtype="auto",
|
| 8 |
device_map="auto",
|
| 9 |
)
|
| 10 |
|
| 11 |
+
class DialogueToSpeechConverter:
|
| 12 |
+
def __init__(self):
|
| 13 |
+
self.raven_pipeline = raven_pipeline
|
| 14 |
|
| 15 |
+
def process_text(self, input_text: str) -> str:
|
| 16 |
+
prompt = f"User Query: {input_text}<human_end>"
|
| 17 |
+
result = self.raven_pipeline(prompt, max_new_tokens=2048, return_full_text=False, do_sample=False, temperature=0.001)[0]["generated_text"]
|
| 18 |
+
return result
|
| 19 |
|
| 20 |
+
# Gradio interface
|
| 21 |
+
def create_interface():
|
| 22 |
+
converter = DialogueToSpeechConverter()
|
| 23 |
+
with gr.Blocks() as app:
|
| 24 |
+
gr.Markdown("""# 🙋🏻♂️Welcome to🌟Tonic's Nexus🐦⬛Raven""")
|
| 25 |
+
gr.Markdown("""You can build with this endpoint using Nexus Raven. The demo is still a work in progress but we hope to add some endpoints for commonly used functions such as intention mappers and audiobook processing.""")
|
| 26 |
+
with gr.Row():
|
| 27 |
+
input_text = gr.Textbox(label="Input Text")
|
| 28 |
+
output_text = gr.Textbox(label="Nexus🐦⬛Raven", readonly=True)
|
| 29 |
+
input_text.change(converter.process_text, inputs=input_text, outputs=output_text)
|
| 30 |
|
| 31 |
+
return app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
+
app = create_interface()
|
| 35 |
app.launch()
|