feat: add DocDev for auto-generating workspace documentation (#781)

* feat: add DocDev for auto-generating workspace documentation

* fix: update markdown instructions in tpl.yaml

* feat: add enable_doc_dev flag and conditionally call DocDev
This commit is contained in:
you-n-g
2025-04-10 20:12:21 +08:00
committed by GitHub
parent 959f2fa076
commit ab52e1b65c
6 changed files with 99 additions and 3 deletions
@@ -0,0 +1,37 @@
"""
Developers concentrating on writing documents for a workspace
"""
from rdagent.core.developer import Developer
from rdagent.core.experiment import Experiment, FBWorkspace
from rdagent.oai.llm_utils import APIBackend
from rdagent.utils.agent.ret import MarkdownAgentOut
from rdagent.utils.agent.workflow import T
class DocDev(Developer[Experiment]):
"""
The developer is responsible for writing documents for a workspace.
"""
def develop(self, exp: Experiment) -> None:
"""
Write documents for the workspace.
"""
ws: FBWorkspace = exp.experiment_workspace
file_li = [str(file.relative_to(ws.workspace_path)) for file in ws.workspace_path.iterdir() if file.is_file()]
key_file_list = ["main.py", "scores.csv"]
system_prompt = T(".prompts:dump_model_eval.system").r()
user_prompt = T(".prompts:dump_model_eval.user").r(
file_li=file_li,
key_files={f: (ws.workspace_path / f).read_text() for f in key_file_list},
)
resp = APIBackend().build_messages_and_create_chat_completion(
user_prompt=user_prompt, system_prompt=system_prompt
)
markdown = MarkdownAgentOut.extract_output(resp)
ws.inject_files({"README.md": markdown})
@@ -52,3 +52,36 @@ dump_model_eval:
# Inference:
{{scores_content_after}}
docdev:
system: |-
You are a skilled developer and a Kaggle grandmaster. Your task is to create documentation for a data science solution.
You will be given:
- a list of files in the folder.
- content from some important files.
Please explain the trained models in the "models/" folder. The training and inference processes are detailed in the `main.py` file. The models' evaluation results are in `scores.csv`. Please respond with a markdown file that includes the following information:
- Explain the purpose of each model. If some models are part of a group (like those from cross-validation), describe them together.
- Provide key details for each model group:
- Important training parameters
- Model details
- Performance of each model
- Ensemble
{% include "rdagent.utils.agent.tpl:MarkdownOut" %}
user: |-
--------------- The file list in the workspace ---------------
{% for f in file_li %}
- {{ f }}
{% endfor %}
--------------- File content of each file ---------------
{% for fname, content in key_files.items() %}
File Path: {{fname}}
```
{{content}}
```
{% endfor %}