juancamval commited on
Commit
47c422b
verified
1 Parent(s): 5073fa8

Update app.py

Browse files

Probando el comportamiento con plotly, a帽ad铆 instrucciones al propmt:

1. Usar plotly como herramienta para graficar
2. Dar ejemplo de uso de traces con marks para mejor visualizaci贸n

Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -13,6 +13,7 @@ from supabase import create_client, Client # type: ignore
13
  from pandasai import SmartDatalake # type: ignore # Porque ya usamos m谩s de un df (m谩s de una tabla de nuestra db)
14
  from pandasai.llm.local_llm import LocalLLM # type: ignore
15
  from pandasai import Agent
 
16
  import matplotlib.pyplot as plt
17
  import time
18
 
@@ -27,9 +28,12 @@ def generate_graph_prompt(user_query):
27
 
28
  Given the user's request: "{user_query}"
29
 
30
- 1. Plot the relevant data using matplotlib:
31
  - Use `df.query("geo == 'X'")` to filter the country, instead of chained comparisons.
32
  - Avoid using filters like `df[df['geo'] == 'Germany']`.
 
 
 
33
  - Include clear axis labels and a descriptive title.
34
  - Save the plot as an image file (e.g., temp_chart.png).
35
 
 
13
  from pandasai import SmartDatalake # type: ignore # Porque ya usamos m谩s de un df (m谩s de una tabla de nuestra db)
14
  from pandasai.llm.local_llm import LocalLLM # type: ignore
15
  from pandasai import Agent
16
+ import plotly.graph_objects as go
17
  import matplotlib.pyplot as plt
18
  import time
19
 
 
28
 
29
  Given the user's request: "{user_query}"
30
 
31
+ 1. Plot the relevant data using graph_objects plotly:
32
  - Use `df.query("geo == 'X'")` to filter the country, instead of chained comparisons.
33
  - Avoid using filters like `df[df['geo'] == 'Germany']`.
34
+ - Use traces with 'line+markers' mode. (e.g, fig.add_trace(go.Scatter(x='X', y='Y',
35
+ mode='lines+markers',
36
+ name='Country_name')))
37
  - Include clear axis labels and a descriptive title.
38
  - Save the plot as an image file (e.g., temp_chart.png).
39