adding model recommendation
Browse files- pag/monitor.py +24 -2
pag/monitor.py
CHANGED
@@ -364,9 +364,9 @@ def monitor_fields():
|
|
364 |
# print(f"interval_dates:{len(interval_dates)}")
|
365 |
# print(f"history_metric_data:{len(history_metric_data)}")
|
366 |
# print(f"masked_future_metric_data:{len(masked_future_metric_data)}")
|
367 |
-
print(predictions)
|
368 |
|
369 |
-
print(interval_dates)
|
370 |
prediction_chart_data = pd.DataFrame(
|
371 |
{
|
372 |
f"history_{metric}_values": history_metric_data,
|
@@ -379,6 +379,28 @@ def monitor_fields():
|
|
379 |
|
380 |
st.area_chart(prediction_chart_data, x="date", y=[f"history_{metric}_values", f"predicted_{metric}_values"])
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
|
383 |
|
384 |
|
|
|
364 |
# print(f"interval_dates:{len(interval_dates)}")
|
365 |
# print(f"history_metric_data:{len(history_metric_data)}")
|
366 |
# print(f"masked_future_metric_data:{len(masked_future_metric_data)}")
|
367 |
+
# print(predictions)
|
368 |
|
369 |
+
# print(interval_dates)
|
370 |
prediction_chart_data = pd.DataFrame(
|
371 |
{
|
372 |
f"history_{metric}_values": history_metric_data,
|
|
|
379 |
|
380 |
st.area_chart(prediction_chart_data, x="date", y=[f"history_{metric}_values", f"predicted_{metric}_values"])
|
381 |
|
382 |
+
crop = "Wheat"
|
383 |
+
|
384 |
+
try:
|
385 |
+
prompt = "given the ndvi values weekly for the next 30 weeks, comment if they are appropriate to grow {crop} (write one paragraph showing your conclusion): NDVI values:{predictions}"
|
386 |
+
response = client.chat.completions.create(
|
387 |
+
model="gpt-4o",
|
388 |
+
messages=[
|
389 |
+
{
|
390 |
+
"role": "user",
|
391 |
+
"content": prompt
|
392 |
+
}
|
393 |
+
],
|
394 |
+
temperature=1,
|
395 |
+
max_tokens=256,
|
396 |
+
top_p=1,
|
397 |
+
frequency_penalty=0,
|
398 |
+
presence_penalty=0
|
399 |
+
)
|
400 |
+
st.write(response.choices[0].message.content)
|
401 |
+
except:
|
402 |
+
st.write("Server Error: Could't generate recommendation!")
|
403 |
+
|
404 |
|
405 |
|
406 |
|