diff --git a/README.md b/README.md index a9bb58f97..d12b5a9eb 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ from pandasai.llm.openai import OpenAI llm = OpenAI(api_token="YOUR_API_TOKEN") pandas_ai = PandasAI(llm, conversational=False) -pandas_ai.run(df, prompt='Which are the 5 happiest countries?') +pandas_ai(df, prompt='Which are the 5 happiest countries?') ``` The above code will return the following: @@ -64,7 +64,7 @@ Name: country, dtype: object Of course, you can also ask PandasAI to perform more complex queries. For example, you can ask PandasAI to find the sum of the GDPs of the 2 unhappiest countries: ```python -pandas_ai.run(df, prompt='What is the sum of the GDPs of the 2 unhappiest countries?') +pandas_ai(df, prompt='What is the sum of the GDPs of the 2 unhappiest countries?') ``` The above code will return the following: @@ -76,7 +76,7 @@ The above code will return the following: You can also ask PandasAI to draw a graph: ```python -pandas_ai.run( +pandas_ai( df, "Plot the histogram of countries showing for each the gpd, using different colors for each bar", ) diff --git a/pandasai/__init__.py b/pandasai/__init__.py index 42535dc03..545de10b5 100644 --- a/pandasai/__init__.py +++ b/pandasai/__init__.py @@ -170,6 +170,25 @@ def run( self.log(f"Conversational answer: {answer}") return answer + def __call__( + self, + data_frame: pd.DataFrame, + prompt: str, + is_conversational_answer: bool = None, + show_code: bool = False, + anonymize_df: bool = True, + use_error_correction_framework: bool = True, + ) -> str: + """Run the LLM with the given prompt""" + return self.run( + data_frame, + prompt, + is_conversational_answer, + show_code, + anonymize_df, + use_error_correction_framework + ) + def remove_unsafe_imports(self, code: str) -> str: """Remove non-whitelisted imports from the code to prevent malicious code execution"""