planner instructions workflow updated
Browse files- scripts/format_response.py +5 -1
- src/agents/agents.py +3 -24
- src/agents/retrievers/retrievers.py +8 -8
scripts/format_response.py
CHANGED
|
@@ -291,7 +291,11 @@ def format_response_to_markdown(api_response, agent_name = None, dataframe=None)
|
|
| 291 |
markdown.append("### Summary\n")
|
| 292 |
for line in summary_lines:
|
| 293 |
if line != "":
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
if 'refined_complete_code' in content and 'summary' in content:
|
| 297 |
try:
|
|
|
|
| 291 |
markdown.append("### Summary\n")
|
| 292 |
for line in summary_lines:
|
| 293 |
if line != "":
|
| 294 |
+
if line.strip().startswith('•') or line.strip().startswith('-') or line.strip().startswith('*'):
|
| 295 |
+
line = line.strip().replace('•', '').replace('-', '').replace('*', '')
|
| 296 |
+
markdown.append(f"* {line.strip()}\n")
|
| 297 |
+
else:
|
| 298 |
+
markdown.append(f"{line.strip()}\n")
|
| 299 |
|
| 300 |
if 'refined_complete_code' in content and 'summary' in content:
|
| 301 |
try:
|
src/agents/agents.py
CHANGED
|
@@ -4,9 +4,11 @@ import asyncio
|
|
| 4 |
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
import os
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
-
|
|
|
|
| 8 |
load_dotenv()
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
AGENTS_WITH_DESCRIPTION = {
|
|
@@ -920,26 +922,3 @@ class auto_analyst(dspy.Module):
|
|
| 920 |
yield name, inputs, result
|
| 921 |
except Exception as e:
|
| 922 |
yield agent_name, inputs, {"error": str(e)}
|
| 923 |
-
# Execute code combiner after all agents complete
|
| 924 |
-
# code_list = [result['code'] for _, result in completed_results if 'code' in result]
|
| 925 |
-
# # max tokens is number of characters - number of words / 2
|
| 926 |
-
# char_count = sum(len(code) for code in code_list)
|
| 927 |
-
# word_count = sum(len(code.split()) for code in code_list)
|
| 928 |
-
# max_tokens = int((char_count - word_count) / 2)
|
| 929 |
-
# print(f"Max tokens: {max_tokens}")
|
| 930 |
-
# try:
|
| 931 |
-
# with dspy.context(lm=dspy.LM(model="gemini/gemini-2.5-pro-preview-03-25", api_key = os.environ['GEMINI_API_KEY'], max_tokens=10000)):
|
| 932 |
-
# combiner_result = self.code_combiner_agent(agent_code_list=str(code_list), dataset=dict_['dataset'])
|
| 933 |
-
# yield 'code_combiner_agent__gemini', str(code_list), dict(combiner_result)
|
| 934 |
-
# except:
|
| 935 |
-
# try:
|
| 936 |
-
# with dspy.context(lm=dspy.LM(model="o3-mini", max_tokens=max_tokens, temperature=1.0, api_key=os.getenv("OPENAI_API_KEY"))):
|
| 937 |
-
# combiner_result = self.code_combiner_agent(agent_code_list=str(code_list), dataset=dict_['dataset'])
|
| 938 |
-
# yield 'code_combiner_agent__openai', str(code_list), dict(combiner_result)
|
| 939 |
-
# except:
|
| 940 |
-
# try:
|
| 941 |
-
# with dspy.context(lm=dspy.LM(model="claude-3-7-sonnet-latest", max_tokens=max_tokens, temperature=1.0, api_key=os.getenv("ANTHROPIC_API_KEY"))):
|
| 942 |
-
# combiner_result = self.code_combiner_agent(agent_code_list=str(code_list), dataset=dict_['dataset'])
|
| 943 |
-
# yield 'code_combiner_agent__anthropic', str(code_list), dict(combiner_result)
|
| 944 |
-
# except Exception as e:
|
| 945 |
-
# yield 'code_combiner_agent__none', str(code_list), {"error": "Error in code combiner: "+str(e)}
|
|
|
|
| 4 |
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
import os
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
+
# import logging
|
| 8 |
+
# from src.utils.logger import Logger
|
| 9 |
load_dotenv()
|
| 10 |
|
| 11 |
+
# logger = Logger("agents", see_time=True, console_log=False)
|
| 12 |
|
| 13 |
|
| 14 |
AGENTS_WITH_DESCRIPTION = {
|
|
|
|
| 922 |
yield name, inputs, result
|
| 923 |
except Exception as e:
|
| 924 |
yield agent_name, inputs, {"error": str(e)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/agents/retrievers/retrievers.py
CHANGED
|
@@ -55,14 +55,14 @@ def make_data(df, desc):
|
|
| 55 |
dict_['df_name'] = "The data is loaded as df"
|
| 56 |
dict_['Description'] = desc
|
| 57 |
dict_['dataframe_head_view'] = df.head(2).to_markdown()
|
| 58 |
-
dict_['all_column_names'] = str(list(df.columns[:20]))
|
| 59 |
-
|
| 60 |
-
for c in df.columns:
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
return dict_
|
| 67 |
|
| 68 |
|
|
|
|
| 55 |
dict_['df_name'] = "The data is loaded as df"
|
| 56 |
dict_['Description'] = desc
|
| 57 |
dict_['dataframe_head_view'] = df.head(2).to_markdown()
|
| 58 |
+
# dict_['all_column_names'] = str(list(df.columns[:20]))
|
| 59 |
+
|
| 60 |
+
# for c in df.columns:
|
| 61 |
+
# df[c] = correct_num(df,c)
|
| 62 |
+
# try:
|
| 63 |
+
# dict_[c] = {'column_name':c,'type':str(type(df[c].iloc[0])), 'column_information':return_vals(df,c)}
|
| 64 |
+
# except:
|
| 65 |
+
# dict_[c] = {'column_name':c,'type':str(type(df[c].iloc[0])), 'column_information':'NA'}
|
| 66 |
return dict_
|
| 67 |
|
| 68 |
|