From 8223bb255ba44fac051e0a76b3fed001e4ccae79 Mon Sep 17 00:00:00 2001 From: JunhaoQiu <56094690+qchiujunhao@users.noreply.github.com> Date: Wed, 9 Jul 2025 11:29:30 -0400 Subject: [PATCH 1/2] fully sync with docker image & fix model selection --- dspy_agent/chat_dspy.py | 60 ++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/dspy_agent/chat_dspy.py b/dspy_agent/chat_dspy.py index d3fafc8..8cd6f4f 100644 --- a/dspy_agent/chat_dspy.py +++ b/dspy_agent/chat_dspy.py @@ -282,7 +282,16 @@ class DataAnalysisSignature(dspy.Signature): you MUST use the special 'finish' action. The 'finish' action takes NO arguments. Here is a literal example of the final step: - Thought: I have collected all the results and I am ready to provide the final answer. 'answer={"explanation": "The analysis is complete.", "plots": ["generated_files/plot1.png"], "files": ["generated_files/data.csv"], "next_steps_suggestion": ["Consider further analysis."]}' + Thought: I have collected all the results and I am ready to provide the final answer. Provide the final answer in the though and an example of final answer is 'answer = { + "explanation": "The analysis revealed that...", + "plots": ["generated_files/plot_a8d3.png", "generated_files/plot_b2c4.png"], + "files": ["generated_files/data_summary.csv", "generated_files/model_weights.pth"], + "next_steps_suggestion": [ + "Would you like to visualize the data further?", + "Do you want to perform any additional analyses?", + "Shall we save this analysis for future reference?" + ] + }' Action: finish() Finally, provide a comprehensive answer to the user in JSON format. This JSON MUST include: @@ -481,7 +490,6 @@ class NiceGuiApp: "groq/gemma-7b-it": "Groq (Gemma-7B-IT)" } - def __init__(self, user_id: str, cli_args_ns: argparse.Namespace): self.user_id = user_id self.cli_args = cli_args_ns @@ -1109,17 +1117,18 @@ def format_raw_middle_steps_for_display(self, trajectory_data) -> str: for i in range(max_idx + 1): is_last_step = (i == max_idx) - observation_for_check = str(trajectory_data.get(f'observation{i}') or trajectory_data.get(f'tool_output{i}', '')) - is_failed_step = "is not in the tool's args" in observation_for_check or 'Execution error in finish' in observation_for_check + observation_for_check = str(trajectory_data.get(f'observation_{i}') or trajectory_data.get(f'tool_output_{i}', '')) + is_failed_step = "is not in the tool's args" in observation_for_check or "Execution error in finish" in observation_for_check + current_step_md_parts = [f"\n##### Step {i + 1}"] thought_content = trajectory_data.get(f'thought_{i}') or trajectory_data.get(f'rationale_{i}') action_name = trajectory_data.get(f'tool_name_{i}') or trajectory_data.get(f'action_{i}') action_input_dict = trajectory_data.get(f'tool_args_{i}') or trajectory_data.get(f'action_input_{i}') observation = trajectory_data.get(f'observation_{i}') or trajectory_data.get(f'tool_output_{i}') - + if is_last_step and is_failed_step: - observation = None + observation = None # Don't show observation for failed last step, it might be an error message if thought_content: current_step_md_parts.append(f"**Thought:**\n```text\n{str(thought_content).strip()}\n```") @@ -1243,6 +1252,17 @@ async def run_eda_action(self): await self.handle_user_input(eda_user_query) + def _on_model_change(self, new_model_id: str): + self.selected_model_id = new_model_id + self.selected_model_name = self.MODEL_OPTIONS_SELECT.get(new_model_id, new_model_id) + ui.notify( + f"Model set to: {self.selected_model_name}", + type='info', + position='top-right', + timeout=2000 + ) + self.try_initialize_agent() + def build_ui(self): ui.add_head_html("""