Paarth commited on
Commit
461efc7
1 Parent(s): a7dab17

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -44
app.py DELETED
@@ -1,44 +0,0 @@
1
- import gradio as gr
2
- import requests
3
- import cohere
4
-
5
-
6
- def get_weather_data():
7
- lat = 27.0238
8
- lon = 74.2179
9
- key = "d07f2290a30824b709b50a94237cfcb7"
10
- url = f"https://api.openweathermap.org/data/2.5/weather?units=metric&lat={lat}&lon={lon}&appid={key}"
11
- response = requests.get(url)
12
- result = response.json()
13
- result["main"].update({"description": result["weather"][0]["description"]})
14
- return result["main"]
15
-
16
- def generate_prompt(data):
17
- weather_json = get_weather_data()
18
- prompt = \
19
- f'''Category: {data["Category"]}
20
- Crop Type: {data["Crop"]}
21
- Query Type: {data["QueryType"]}
22
- State: {data["StateName"].lower()}
23
- District: {data["DistrictName"].lower()}
24
- Max Temprature: {weather_json["temp_max"]}
25
- Min Temprature: {weather_json["temp_min"]}
26
- Humidity: {weather_json["humidity"]}
27
- Weather Description: {weather_json["description"]}
28
- Question: {data["QueryTranslated"]}
29
- '''
30
- return prompt
31
-
32
- def get_response(prompt):
33
- co = cohere.Client('EoYqxEa60C0EEeKadblGW8NE94geVCEE75lDqySe')
34
- response = co.generate(
35
- prompt = prompt,
36
- )
37
- return response.text
38
-
39
- outputs = gr.outputs.Textbox()
40
- iface = gr.Interface(fn=get_response,
41
- inputs=[gr.Textbox(label = 'First Code snippet')],
42
- outputs=[gr.Textbox(label = 'Summary of first Code snippet')],
43
- description='The similarity score')
44
- iface.launch()