Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
# Load Hugging Face model and tokenizer
|
5 |
+
model_name = "abrotech/Zora-ALM-7.2B-gguf" # Your Hugging Face model space
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
|
9 |
+
# Define function to handle user input and generate response
|
10 |
+
def generate_response(user_input):
|
11 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
12 |
+
outputs = model.generate(input_ids=inputs["input_ids"], max_length=150, temperature=0.7)
|
13 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
+
return response
|
15 |
+
|
16 |
+
# Set up the Gradio interface
|
17 |
+
with gr.Blocks() as demo:
|
18 |
+
gr.HTML("<h1 style='text-align: center;'>Welcome to Zora Assistant</h1>")
|
19 |
+
gr.HTML("<p style='text-align: center;'>Ask anything and Zora will answer!</p>")
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
with gr.Column():
|
23 |
+
user_input = gr.Textbox(label="Enter your question", placeholder="Ask Zora anything...")
|
24 |
+
submit_btn = gr.Button("Get Answer")
|
25 |
+
response_output = gr.Textbox(label="Zora's Answer", interactive=False)
|
26 |
+
|
27 |
+
submit_btn.click(generate_response, inputs=user_input, outputs=response_output)
|
28 |
+
|
29 |
+
# Launch the Gradio app
|
30 |
+
demo.launch(share=True)
|