-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move prompt templates to files (#593)
* (refactor): define base prompt class as an abstract * (refactor): attribute `text` rename to `template` (since it's essentially is a template) * (feat): add FileBasedPrompt
- Loading branch information
1 parent
57c5259
commit b9f4c37
Showing
26 changed files
with
201 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
You are provided with the following {engine} DataFrames with the following metadata: | ||
|
||
{dataframes} | ||
|
||
The user asked the following question: | ||
{conversation} | ||
|
||
You generated this python code: | ||
{code} | ||
|
||
It fails with the following error: | ||
{error_returned} | ||
|
||
Correct the python code and return a new python code (do not import anything) that fixes the above mentioned error. Do not generate the same code again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
You are provided with the following pandas DataFrames: | ||
|
||
{dataframes} | ||
|
||
<conversation> | ||
{conversation} | ||
</conversation> | ||
|
||
This is the initial python code to be updated: | ||
```python | ||
# TODO import all the dependencies required | ||
{default_import} | ||
|
||
def analyze_data(dfs: list[{engine_df_name}]) -> dict: | ||
""" | ||
Analyze the data | ||
1. Prepare: Preprocessing and cleaning data if necessary | ||
2. Process: Manipulating data for analysis (grouping, filtering, aggregating, etc.) | ||
3. Analyze: Conducting the actual analysis (if the user asks to plot a chart save it to an image in {save_charts_path}/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." }} | ||
""" | ||
``` | ||
|
||
Using the provided dataframes (`dfs`), update the python code based on the last question in the conversation. | ||
|
||
Updated code: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from .base import Prompt | ||
from .correct_error_prompt import CorrectErrorPrompt | ||
from .generate_python_code import GeneratePythonCodePrompt | ||
from .base import AbstractPrompt | ||
from .correct_error_prompt import CorrectErrorAbstractPrompt | ||
from .generate_python_code import GeneratePythonCodeAbstractPrompt | ||
|
||
__all__ = [ | ||
"Prompt", | ||
"CorrectErrorPrompt", | ||
"GeneratePythonCodePrompt", | ||
"AbstractPrompt", | ||
"CorrectErrorAbstractPrompt", | ||
"GeneratePythonCodeAbstractPrompt", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.