Commit cd7f6e7f by nanziyuan

Initial commit

parents
agent:
system_template: |
You are a helpful assistant that can interact with a computer.
Your response must contain exactly ONE bash code block with ONE command (or commands connected with && or ||).
Include a THOUGHT section before your command where you explain your reasoning process.
Format your response as shown in <format_example>.
<format_example>
Your reasoning and analysis here. Explain why you want to perform the action.
```mswea_bash_command
your_command_here
```
</format_example>
Failure to follow these rules will cause your response to be rejected.
instance_template: |
Please solve this issue: {{task}}
You can execute bash commands and edit files to implement the necessary changes.
## Recommended Workflow
This workflows should be done step-by-step so that you can iterate on your changes and any possible problems.
1. Analyze the codebase by finding and reading relevant files
2. Create a script to reproduce the issue
3. Edit the source code to resolve the issue
4. Verify your fix works by running your script again
5. Test edge cases to ensure your fix is robust
6. Submit your changes and finish your work by issuing the following command: `echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT`.
Do not combine it with any other command. <important>After this command, you cannot continue working on this task.</important>
## Important Rules
1. Every response must contain exactly one action
2. The action must be enclosed in triple backticks
3. Directory or environment variable changes are not persistent. Every action is executed in a new subshell.
However, you can prefix any action with `MY_ENV_VAR=MY_VALUE cd /path/to/working/dir && ...` or write/load environment variables from files
<system_information>
{{system}} {{release}} {{version}} {{machine}}
</system_information>
## Formatting your response
Here is an example of a correct response:
<example_response>
THOUGHT: I need to understand the structure of the repository first. Let me check what files are in the current directory to get a better understanding of the codebase.
```mswea_bash_command
ls -la
```
</example_response>
## Useful command examples
### Create a new file:
```mswea_bash_command
cat <<'EOF' > newfile.py
import numpy as np
hello = "world"
print(hello)
EOF
```
### Edit files with sed:
{%- if system == "Darwin" -%}
<important>
You are on MacOS. For all the below examples, you need to use `sed -i ''` instead of `sed -i`.
</important>
{%- endif -%}
```mswea_bash_command
# Replace all occurrences
sed -i 's/old_string/new_string/g' filename.py
# Replace only first occurrence
sed -i 's/old_string/new_string/' filename.py
# Replace first occurrence on line 1
sed -i '1s/old_string/new_string/' filename.py
# Replace all occurrences in lines 1-10
sed -i '1,10s/old_string/new_string/g' filename.py
```
### View file content:
```mswea_bash_command
# View specific lines with numbers
nl -ba filename.py | sed -n '10,20p'
```
### Any other command you want to run
```mswea_bash_command
anything
```
step_limit: 30
cost_limit: 3.
mode: yolo
environment:
env:
PAGER: cat
MANPAGER: cat
LESS: -R
PIP_PROGRESS_BAR: 'off'
TQDM_DISABLE: '1'
model:
observation_template: |
{% if output.exception_info -%}
<exception>{{output.exception_info}}</exception>
{% endif -%}
<returncode>{{output.returncode}}</returncode>
{% if output.output | length < 10000 -%}
<output>
{{ output.output -}}
</output>
{%- else -%}
<warning>
The output of your last command was too long.
Please try a different command that produces less output.
If you're looking at a file you can try use head, tail or sed to view a smaller number of lines selectively.
If you're using grep or find and it produced too much output, you can use a more selective search pattern.
If you really need to see something from the full command's output, you can redirect output to a file and then search in that file.
</warning>
{%- set elided_chars = output.output | length - 10000 -%}
<output_head>
{{ output.output[:5000] }}
</output_head>
<elided_chars>
{{ elided_chars }} characters elided
</elided_chars>
<output_tail>
{{ output.output[-5000:] }}
</output_tail>
{%- endif -%}
format_error_template: |
Format error:
<error>
{{error}}
</error>
Here is general guidance on how to format your response:
Please always provide EXACTLY ONE action in triple backticks, found {{actions|length}} actions.
Please format your action in triple backticks as shown in <response_example>.
<response_example>
Here are some thoughts about why you want to perform the action.
```mswea_bash_command
<action>
```
</response_example>
If you have completed your assignment, please consult the first message about how to
submit your solution (you will not be able to continue working on this task after that).
cost_tracking: "ignore_errors"
model_name: "openai/Qwen3.5-35B-A3B"
model_class: litellm_textbased
action_regex: "```mswea_bash_command\\s*\\n(.*?)\\n```"
model_kwargs:
custom_llm_provider: "openai"
api_base: "http://0.0.0.0:30000/v1"
extra_body:
chat_template_kwargs:
enable_thinking:
false
# drop_params: true
This diff is collapsed. Click to expand it.
# CodeV-Data-Agent
## 安装
pip install mini-swe-agent
## 配置
设置api key
```bash
export OPENAI_API_KEY=xxxxx
```
config文件里主要有以下几个key需要配置
- `model_name`: "openai/xxxx" 前面的openai是必须的,如果用的是openai兼容的接口的话。如果用anthropic的话,这里要换成`anthropic/xxxx`,前面的环境变量也要改成`export ANTHROPIC_API_KEY=<your-api-key>`
- `model_kwargs.api_base`: model的url
- `model_kwargs` 可以接受其他参数,温度,topk等等。具体可以看https://docs.litellm.ai/docs/completion/input,现在就加了一个关闭thinking的参数
- `step_limit, cost_limit` agent轮数和开销。一般本地部署模型没有这个cost_limit,所以注意设置轮数
使用本地模型也要有token,随便写一个就行。
## 用法
### 生成代码
加载`mini_code.yaml`
现在假设文档放在`./doc/module.md`, 生成的代码保存为`./module.v`。如果不一样可以直接改下面的prompt。
```bash
mini -o run.traj.json -c mini_code.yaml --exit-immediately -t <(cat <<EOF
Task: Implement the Verilog module ${module} and a SystemVerilog testbench.
Requirements:
- Specifications: Follow \`doc/${module}.md\`.
- RTL: Module name must be \`${module}\`. Save as \`${module}.v\`.
- Testbench: Module name must be \`tb\`. Save as \`${module}_tb.sv\`.
- Compiler: Verilator. Code must be synthesizable.
Workflow:
1. Read repository files and Makefile.
2. Write the RTL and testbench code following \`doc/${module}.md\`.
3. Run "make all" to compile and simulate.
4. If errors occur, fix the code and repeat step 3 until successful.
EOF
)
```
### 生成spec
加载`mini_spec.yaml`
当前假设代码和文档都在当前的运行目录。可以直接改下面的prompt改变。
```bash
mini -t "Generate specification for {{code_path}} and save it at {{spec_path}}." -o run.traj.json -c mini_spec.yaml --exit-immediately
```
agent轨迹和一些运行中的信息会被保存到run.traj.json。建议保存,可以用于后续训练。
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment