Spaces:
Running
Running
Deepak Sahu
commited on
Commit
·
ccd9d62
1
Parent(s):
ad716b8
Update pandas_expression_generator_function.py
Browse files
pandas_expression_generator/src/pandas_expression_generator/pandas_expression_generator_function.py
CHANGED
@@ -54,9 +54,10 @@ async def pandas_expression_generator_function(
|
|
54 |
def expression_executor(input_exp: str, df=None) -> tuple:
|
55 |
# Convert the input string to a list
|
56 |
commands = ast.literal_eval(input_exp)
|
57 |
-
|
58 |
# local_vars = dict([(str.strip, command.split('=', 1)) for command in commands])
|
59 |
local_vars:dict = dict([list(map(str.strip, command.split('=', 1))) for command in commands])
|
|
|
60 |
|
61 |
# Dictionary to simulate local scope
|
62 |
local_vars.update({'df': df, 'pd': pd, 'np': np})
|
@@ -107,6 +108,8 @@ async def pandas_expression_generator_function(
|
|
107 |
// reset the index of df if requrired
|
108 |
// convert the grouped dataframe to dictionaries
|
109 |
//
|
|
|
|
|
110 |
"output" = sting. Have the string as list (records) of dictionaries (columns). Ensure to reset index if required
|
111 |
]
|
112 |
|
@@ -129,6 +132,7 @@ async def pandas_expression_generator_function(
|
|
129 |
structured_text_str = extract_bracket_content(ai_message.content)
|
130 |
output_message = str(expression_executor(structured_text_str, df))[:800]
|
131 |
#
|
|
|
132 |
prompt_ = f'''You are part of big system. Your task is to respond the user in conversational way.
|
133 |
|
134 |
This was the query of the end users:
|
|
|
54 |
def expression_executor(input_exp: str, df=None) -> tuple:
|
55 |
# Convert the input string to a list
|
56 |
commands = ast.literal_eval(input_exp)
|
57 |
+
print(input_exp)
|
58 |
# local_vars = dict([(str.strip, command.split('=', 1)) for command in commands])
|
59 |
local_vars:dict = dict([list(map(str.strip, command.split('=', 1))) for command in commands])
|
60 |
+
print("THIS")
|
61 |
|
62 |
# Dictionary to simulate local scope
|
63 |
local_vars.update({'df': df, 'pd': pd, 'np': np})
|
|
|
108 |
// reset the index of df if requrired
|
109 |
// convert the grouped dataframe to dictionaries
|
110 |
//
|
111 |
+
// the last step should always assign output to the variable `output`
|
112 |
+
// never use 'print' in the expression
|
113 |
"output" = sting. Have the string as list (records) of dictionaries (columns). Ensure to reset index if required
|
114 |
]
|
115 |
|
|
|
132 |
structured_text_str = extract_bracket_content(ai_message.content)
|
133 |
output_message = str(expression_executor(structured_text_str, df))[:800]
|
134 |
#
|
135 |
+
print("*"*80, output_message)
|
136 |
prompt_ = f'''You are part of big system. Your task is to respond the user in conversational way.
|
137 |
|
138 |
This was the query of the end users:
|