Spaces:
Runtime error
Runtime error
Commit
·
951b324
1
Parent(s):
d139945
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the weather question answering model from Hugging Face
|
| 5 |
+
model = pipeline("question-answering", model="mrm8488/t5-base-finetuned-weather-questions")
|
| 6 |
+
|
| 7 |
+
def get_weather(question):
|
| 8 |
+
# Use the weather question answering model to get the answer
|
| 9 |
+
answer = model({
|
| 10 |
+
"question": question,
|
| 11 |
+
"context": "The weather today is sunny with a temperature of 25 degrees Celsius."
|
| 12 |
+
})
|
| 13 |
+
return answer["answer"]
|
| 14 |
+
|
| 15 |
+
# Create a Gradio interface for the weather app
|
| 16 |
+
def app():
|
| 17 |
+
weather_question = gr.inputs.Textbox(lines=2, label="Ask a weather-related question")
|
| 18 |
+
result = gr.outputs.Textbox(label="Answer")
|
| 19 |
+
|
| 20 |
+
gr.Interface(fn=get_weather, inputs=weather_question, outputs=result).launch()
|
| 21 |
+
|
| 22 |
+
# Run the weather app
|
| 23 |
+
app()
|