Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
raven_pipeline = pipeline( | |
"text-generation", | |
model="Nexusflow/NexusRaven-V2-13B", | |
torch_dtype="auto", | |
device_map="auto", | |
) | |
class DialogueToSpeechConverter: | |
def __init__(self): | |
self.raven_pipeline = raven_pipeline | |
def process_text(self, input_text: str) -> str: | |
prompt = f"User Query: {input_text}<human_end>" | |
result = self.raven_pipeline(prompt, max_new_tokens=2048, return_full_text=False, do_sample=False, temperature=0.001)[0]["generated_text"] | |
return result | |
# Gradio interface | |
def create_interface(): | |
converter = DialogueToSpeechConverter() | |
with gr.Blocks() as app: | |
gr.Markdown("""# 🙋🏻♂️Welcome to🌟Tonic's Nexus🐦⬛Raven""") | |
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. | |
You can also use Nexus🐦⬛Raven on your laptop & by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/Tonic1/NexusRaven2?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3> | |
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha) | |
""") | |
with gr.Row(): | |
input_text = gr.Textbox(label="Input Text") | |
submit_button = gr.Button("Submit") | |
output_text = gr.Textbox(label="Nexus🐦⬛Raven") | |
submit_button.click(converter.process_text, inputs=input_text, outputs=output_text) | |
return app | |
if __name__ == "__main__": | |
app = create_interface() | |
app.launch() |