You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I previously overriden the default prompt using this class:
from pandasai.prompts.base import Prompt
class CustomGeneratePythonCodePrompt(Prompt):
"""Prompt to generate Python code"""
text: str = """
You are provided with the following pandas DataFrames with the following metadata:
{dataframes}
This is the initial python code to be updated:
```python
# TODO import all the dependencies required
{default_import}
# Analyze the data
# Merge tables only if data is needed from different tables. When merging merge all the 3 tables.
# It is extremely important to merge only when needed to avoid misleading results.
# 1. Prepare: Preprocessing and cleaning data
# 2. Process: Manipulating data for analysis (grouping, filtering, aggregating, etc.)
# 3. Analyze: Conducting the actual analysis (if the user asks to create a chart save it to an image in exports/charts/temp_chart.png and do not show the chart.)
# 4. Output: return a dictionary of:
# - type (possible values "text", "number", "dataframe", "plot")
# - value (can be a string, a dataframe or the path of the plot, NOT a dictionary)
# Example output: {{ "type": "text", "value": "The average loan amount is $15,000." }}
# Another example output: {{ "type": "dataframe", "value": computed_df }}
# The code should consider only 1 thing to return (text, number, dataframe, plot)
# 5. Make sure you use the right variable name in the return statement
# 6. If you are not sure about the type that should be generated decide it yourself
def analyze_data(dfs: list[{engine_df_name}]) -> dict:
# Code goes here (do not add comments)
# Declare a result variable
result = analyze_data(dfs)
Using the provided dataframes (`dfs`), update the python code based on the last user question:
{conversation}
In case of plot make the figures wide.
Updated code:
""" # noqa: E501
def __init__(self):
default_import = "import pandas as pd"
engine_df_name = "pd.DataFrame"
self.set_var("default_import", default_import)
self.set_var("engine_df_name", engine_df_name)
Im trying to reimplement it using the new version but bit confused about how it should be done using the new prompt classes.
Will apprecaite any help
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I previously overriden the default prompt using this class:
Im trying to reimplement it using the new version but bit confused about how it should be done using the new prompt classes.
Will apprecaite any help
Beta Was this translation helpful? Give feedback.
All reactions