Spaces:
Sleeping
Sleeping
Created finalOutput.py It takes the user query and weather details as params and returns the llm generated output
Browse files- finalOutput.py +35 -0
finalOutput.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from groq import Groq
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
load_dotenv()
|
5 |
+
|
6 |
+
|
7 |
+
def final_output(input_string, weather_data_final):
|
8 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
9 |
+
response = client.chat.completions.create(
|
10 |
+
model="llama3-70b-8192",
|
11 |
+
messages=[
|
12 |
+
{
|
13 |
+
"role": "system",
|
14 |
+
"content": '''
|
15 |
+
given a query and weather details of a city
|
16 |
+
Describe what the weather conditions are like,
|
17 |
+
describe what can be done or not and if it is pleasant or not.
|
18 |
+
Mention 5 precautions (dont use bold font for anything)
|
19 |
+
Temperature is in celsius
|
20 |
+
'''
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"role": "user",
|
24 |
+
"content": "User entered query: " + input_string + "Weather data of the city: " + str(weather_data_final)
|
25 |
+
}
|
26 |
+
],
|
27 |
+
temperature=1,
|
28 |
+
max_tokens=2400,
|
29 |
+
top_p=1,
|
30 |
+
# stream=True,
|
31 |
+
stop=None,
|
32 |
+
)
|
33 |
+
final_response = response.choices[0].message.content
|
34 |
+
return final_response
|
35 |
+
|