Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
12 changes: 7 additions & 5 deletions .devcontainer/env
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ TIMEOUT_FAIL_LIMIT=100
# CHAT_TEMPERATURE=0.7

CHAT_STREAM=False
CHAT_TEMPERATURE=1
CHAT_MODEL=o1-preview
SYSTEM_PROMPT_ROLE=user

BACKEND=rdagent.oai.backend.LiteLLMAPIBackend
OPENAI_API_KEY=sk-1234
OPENAI_API_BASE=http://ep14.213428.xyz:38881
BACKEND=rdagent.oai.backend.LiteLLMAPIBackend
OPENAI_API_KEY=sk-1234
OPENAI_API_BASE=http://10.150.240.117:38803
EMBEDDING_MODEL=text-embedding-3-small
CHAT_MODEL=gpt-5
CHAT_TEMPERATURE=1


# amc chat model configs:
EMBEDDING_MODEL=text-embedding-ada-002
#EMBEDDING_MODEL=text-embedding-ada-002

# Cache Setting (Optional):
DUMP_CHAT_CACHE=True
Expand Down
27 changes: 27 additions & 0 deletions rdagent/app/agentic_sys/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

from pydantic_settings import SettingsConfigDict

from rdagent.core.conf import ExtendedBaseSettings


class AgenticSysSetting(ExtendedBaseSettings):
model_config = SettingsConfigDict(env_prefix="AS_", protected_namespaces=())

competition: str | None = None

# Main components
## Scen
scen: str = "rdagent.scenarios.agentic_sys.scen.AgenticSysScen"
"""
Scenario class for data science tasks.
- For Kaggle competitions, use: "rdagent.scenarios.data_science.scen.KaggleScen"
- For custom data science scenarios, use: "rdagent.scenarios.data_science.scen.DataScienceScen"
"""
exp_gen: str = "rdagent.scenarios.agentic_sys.proposal.AgenticSysExpGen"
coder: str = "rdagent.scenarios.agentic_sys.dev.AgenticSysCoder"
runner: str = "rdagent.scenarios.agentic_sys.dev.AgenticSysRunner"

feedback: str = "rdagent.scenarios.agentic_sys.feedback.AgenticSysExp2Feedback"


ASYS_RD_SETTING = AgenticSysSetting()
50 changes: 50 additions & 0 deletions rdagent/app/agentic_sys/loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import asyncio
from pathlib import Path
from typing import Optional

import fire
import typer
from typing_extensions import Annotated


from rdagent.core.utils import import_class
from rdagent.log import rdagent_logger as logger

from rdagent.app.agentic_sys.conf import ASYS_RD_SETTING
from rdagent.scenarios.agentic_sys.loop import AgenticSysRDLoop


def main(
path: Optional[str] = None,
checkout: Annotated[bool, typer.Option("--checkout/--no-checkout", "-c/-C")] = True,
checkout_path: Optional[str] = None,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
timeout: Optional[str] = None,
competition="deepresearch",
replace_timer=True,
exp_gen_cls: Optional[str] = None,
):
if not checkout_path is None:
checkout = Path(checkout_path)

if competition is not None:
ASYS_RD_SETTING.competition = competition

if not ASYS_RD_SETTING.competition:
logger.error("Please specify competition name.")

if path is None:
agentic_sys_loop = AgenticSysRDLoop(ASYS_RD_SETTING)
else:
agentic_sys_loop: AgenticSysRDLoop = AgenticSysRDLoop.load(path, checkout=checkout, replace_timer=replace_timer)

# replace exp_gen if we have new class
if exp_gen_cls is not None:
agentic_sys_loop.exp_gen = import_class(exp_gen_cls)(agentic_sys_loop.exp_gen.scen)

asyncio.run(agentic_sys_loop.run(step_n=step_n, loop_n=loop_n, all_duration=timeout))


if __name__ == "__main__":
fire.Fire(main)
38 changes: 37 additions & 1 deletion rdagent/core/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def __init__(self, scen: ASpecificScen, knowledge_base: ASpecificKB | None = Non
self.knowledge_base: ASpecificKB | None = knowledge_base
self.current_selection: tuple[int, ...] = (-1,)

# When parallel multiple nodes in the trace, nodes are not committed before finish running.
self.uncommitted_experiments: dict[int, Experiment] = {} # loop_id -> Experiment

def get_sota_hypothesis_and_experiment(self) -> tuple[Hypothesis | None, Experiment | None]:
"""Access the last experiment result, sub-task, and the corresponding hypothesis."""
# TODO: The return value does not align with the signature.
Expand Down Expand Up @@ -240,6 +243,39 @@ def get_parents(self, child_idx: int) -> list[int]:

return ancestors

def register_uncommitted_exp(self, exp: DSExperiment, loop_id: int):
self.uncommitted_experiments[loop_id] = exp

def deregister_uncommitted_exp(self, loop_id: int):
if loop_id in self.uncommitted_experiments:
del self.uncommitted_experiments[loop_id]

def sync_dag_parent_and_hist(
self,
exp_and_fb: tuple[Experiment, ExperimentFeedback],
cur_loop_id: int,
) -> None:
"""
Adding corresponding parent index to the dag_parent when the hist is going to be changed.
Should be called when the hist is changed.
"""

if len(self.hist) == 0 or len(self.get_current_selection()) == 0:
# the node we are going to add is the first node of hist / root node of a new sub-trace
self.dag_parent.append(())

else:
current_node_idx = self.current_selection[0]

if current_node_idx == -1:
# the current selection is the latest one
current_node_idx = len(self.hist) - 1

self.dag_parent.append((current_node_idx,))
self.hist.append(exp_and_fb)
self.idx2loop_id[len(self.hist) - 1] = cur_loop_id
self.deregister_uncommitted_exp(cur_loop_id)


class CheckpointSelector:
"""
Expand Down Expand Up @@ -298,7 +334,7 @@ def __init__(self, scen: Scenario) -> None:
self.scen = scen

@abstractmethod
def gen(self, trace: Trace, plan: ExperimentPlan | None = None) -> Experiment:
def gen(self, trace: Trace) -> Experiment:
"""
Generate the experiment based on the trace.
Planning is part of gen, but since we may support multi-stage planning,
Expand Down
Loading
Loading