Spaces:
Paused
Paused
create app.py
Browse files- app.py +25 -0
- requirements.txt +2 -1
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def answer_question(question):
|
4 |
+
# This is a placeholder function. You should implement your model inference logic here.
|
5 |
+
# For demonstration purposes, we'll return a generic answer.
|
6 |
+
answers = {
|
7 |
+
"how to detect crop disease": "To detect crop diseases, use image recognition models trained on datasets of diseased and healthy crops.",
|
8 |
+
"best time to plant wheat": "The best time to plant wheat depends on your region. In temperate regions, it's usually early autumn.",
|
9 |
+
"improving soil fertility": "Improving soil fertility can be achieved by rotating crops, using compost, and avoiding overuse of chemical fertilizers.",
|
10 |
+
}
|
11 |
+
# Find the closest question and return the answer
|
12 |
+
question = question.lower()
|
13 |
+
for key in answers:
|
14 |
+
if key in question:
|
15 |
+
return answers[key]
|
16 |
+
return "I'm not sure how to answer that. Can you ask something else?"
|
17 |
+
|
18 |
+
app = gr.Interface(fn=answer_question,
|
19 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Ask a question about agriculture..."),
|
20 |
+
outputs="text",
|
21 |
+
title="Agriculture Assistant",
|
22 |
+
description="Ask any question about agriculture, and I'll try to provide an informative answer.")
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
app.launch()
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
python-dotenv
|
2 |
mistralai
|
3 |
langchain-community
|
4 |
-
faiss-cpu
|
|
|
|
1 |
python-dotenv
|
2 |
mistralai
|
3 |
langchain-community
|
4 |
+
faiss-cpu
|
5 |
+
gradio
|