Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
|
| 4 |
+
# Load model and tokenizer
|
| 5 |
+
model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free"
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
|
| 9 |
+
# Function to generate text
|
| 10 |
+
def generate_text(prompt):
|
| 11 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 12 |
+
outputs = model.generate(inputs["input_ids"], max_length=50)
|
| 13 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 14 |
+
|
| 15 |
+
# Set up Gradio Interface
|
| 16 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
| 17 |
+
|
| 18 |
+
# Launch app
|
| 19 |
+
iface.launch()
|