Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
-
import torch
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
inputs
|
13 |
-
outputs
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
temperature=0.7,
|
18 |
-
top_p=0.95,
|
19 |
-
repetition_penalty=1.2,
|
20 |
-
)
|
21 |
-
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
|
23 |
-
|
24 |
-
def embed_external():
|
25 |
-
return """<iframe src="https://cropseek-llm.netlify.app/" width="100%" height="800px" style="border:none;"></iframe>"""
|
26 |
|
27 |
-
# Gradio Tabs layout
|
28 |
-
with gr.Blocks(title="CropSeek-LLM") as demo:
|
29 |
-
gr.Markdown("# 🌿 CropSeek-LLM\nYour AI partner for crop planning, pest control, and soil optimization.")
|
30 |
-
|
31 |
-
with gr.Tab("🧠 Ask the Model"):
|
32 |
-
gr.Markdown("### Ask CropSeek-LLM a question:")
|
33 |
-
with gr.Row():
|
34 |
-
prompt = gr.Textbox(label="Your Question", lines=4, placeholder="e.g. Best time to plant tomatoes in Limpopo?")
|
35 |
-
output = gr.Textbox(label="Model Response")
|
36 |
-
ask_button = gr.Button("Submit")
|
37 |
-
ask_button.click(fn=cropseek_response, inputs=prompt, outputs=output)
|
38 |
-
|
39 |
-
with gr.Tab("🌐 External Dashboard"):
|
40 |
-
gr.HTML(embed_external())
|
41 |
-
|
42 |
-
# Launch app
|
43 |
-
if __name__ == "__main__":
|
44 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
+
def embed_cropseek():
|
4 |
+
return """
|
5 |
+
<iframe src="https://cropseek-llm.netlify.app/" width="100%" height="800px" style="border:none;"></iframe>
|
6 |
+
"""
|
7 |
|
8 |
+
iface = gr.Interface(
|
9 |
+
fn=embed_cropseek,
|
10 |
+
inputs=[],
|
11 |
+
outputs=gr.HTML(),
|
12 |
+
title="CropSeek-LLM (DARJYO)",
|
13 |
+
live=True,
|
14 |
+
)
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
iface.launch()
|
|
|
|
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|