Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions peak_assistant/able_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# SPDX-License-Identifier: MIT

from typing import List
from typing import List, Optional

from autogen_core.models import UserMessage, SystemMessage

Expand All @@ -32,7 +32,7 @@ async def able_table(
research_document: str,
local_data_document: str,
local_context: str,
previous_run: list[SystemMessage | UserMessage] = list(),
previous_run: Optional[list[SystemMessage | UserMessage]] = None,
) -> str:
"""
Generate a PEAK ABLE table based on the given hypothesis and research document.
Expand Down
4 changes: 3 additions & 1 deletion peak_assistant/data_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#
# SPDX-License-Identifier: MIT

from typing import Optional

from autogen_agentchat.base import TaskResult
from autogen_agentchat.messages import TextMessage
from autogen_agentchat.agents import AssistantAgent
Expand All @@ -38,7 +40,7 @@ async def identify_data_sources(
able_info: str,
local_context: str,
verbose: bool = False,
previous_run: list = list(),
previous_run: Optional[list] = None,
mcp_server_group: str = "data_discovery",
msg_preprocess_callback=None,
msg_preprocess_kwargs=None,
Expand Down
58 changes: 30 additions & 28 deletions peak_assistant/hypothesis_assistant/hypothesis_refiner_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import os
import sys
import argparse
from typing import List
import traceback
from typing import List, Optional
from dotenv import load_dotenv
import asyncio

Expand All @@ -51,7 +52,7 @@ async def refiner(
research_document: str,
local_data_document: str,
verbose: bool = False,
previous_run: list = list(),
previous_run: Optional[list] = None,
msg_preprocess_callback=None,
msg_preprocess_kwargs=None,
msg_postprocess_callback=None,
Expand Down Expand Up @@ -354,24 +355,19 @@ async def refiner(
msgs=messages, **(msg_preprocess_kwargs or {})
)

try:
# Run the team asynchronously
if verbose:
result = await Console(team.run_stream(task=messages), output_stats=True)
else:
result = await team.run(task=messages)
# Run the team asynchronously
if verbose:
result = await Console(team.run_stream(task=messages), output_stats=True)
else:
result = await team.run(task=messages)

# Postprocess the result
if msg_postprocess_callback:
result = msg_postprocess_callback(
result=result, **(msg_postprocess_kwargs or {})
)
# Postprocess the result
if msg_postprocess_callback:
result = msg_postprocess_callback(
result=result, **(msg_postprocess_kwargs or {})
)

# Access the content from the CreateResult object
return result # Use the correct attribute to access the generated content
except Exception as e:
print(f"Error while refining hypotheses: {e}")
raise Exception("An error occurred while refining the hypothesis.") from e
return result


def main() -> None:
Expand Down Expand Up @@ -497,17 +493,23 @@ def main() -> None:

while True:
# Run the hypothesizer asynchronously
response = asyncio.run(
refiner(
hypothesis=current_hypothesis,
local_context=local_context or "",
research_document=research_data,
local_data_document=local_data or "",
verbose=args.verbose,
previous_run=messages,
**debug_agents_opts,
try:
response = asyncio.run(
refiner(
hypothesis=current_hypothesis,
local_context=local_context or "",
research_document=research_data,
local_data_document=local_data or "",
verbose=args.verbose,
previous_run=messages,
**debug_agents_opts,
)
)
)
except Exception as e:
print(f"Error refining hypothesis: {e}", file=sys.stderr)
if args.verbose:
traceback.print_exc()
sys.exit(1)

# Extract the refined hypothesis using the centralized extractor
current_hypothesis, acceptance_msg = extract_refined_hypothesis(response, original_hypothesis=current_hypothesis)
Expand Down
4 changes: 3 additions & 1 deletion peak_assistant/planning_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#
# SPDX-License-Identifier: MIT

from typing import Optional

from autogen_agentchat.messages import TextMessage
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
Expand All @@ -38,7 +40,7 @@ async def plan_hunt(
data_discovery: str,
local_context: str,
verbose: bool = False,
previous_run: list = list(),
previous_run: Optional[list] = None,
msg_preprocess_callback=None,
msg_preprocess_kwargs=None,
msg_postprocess_callback=None,
Expand Down
4 changes: 2 additions & 2 deletions peak_assistant/research_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def researcher(
technique: str,
local_context: str,
verbose: bool = False,
previous_run: list = list(),
previous_run: Optional[list] = None,
mcp_server_group_external: str = "research-external",
user_id: Optional[str] = None,
msg_preprocess_callback=None,
Expand Down Expand Up @@ -397,7 +397,7 @@ async def local_data_searcher(
local_context: str,
research_document: str,
verbose: bool = False,
previous_run: list = list(),
previous_run: Optional[list] = None,
mcp_server_group_local_data: str = "local-data-search",
user_id: Optional[str] = None,
msg_preprocess_callback=None,
Expand Down
Loading