Skip to content

Commit

Permalink
fix: move diff to content (#426)
Browse files Browse the repository at this point in the history
- move filediff from role prompt to content
- avoid template replacement issue 
```
Single '}' encountered in format string
```
  • Loading branch information
RaoHai authored Oct 10, 2024
2 parents 5f111c1 + 2afc362 commit ea895fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 1 addition & 5 deletions server/agent/prompts/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
- The + sign means that code has been added.
- The - sign means that code has been removed.
## File Diff:
{file_diff}
# Constraints
- Only create comments for significant issues, such as potential logical errors, vulnerabilities, or functionality-impacting bugs and typo.
- Absolutely avoid commenting on or evaluating any files that were not part of the current changeset (no diffs). This includes any files in the repository that have not been modified as part of the pull request.
Expand All @@ -63,12 +60,11 @@


def get_role_prompt(
repo_name: str, pull_number: int, title: str, description: str, file_diff: str
repo_name: str, pull_number: int, title: str, description: str
):
return PULL_REQUEST_ROLE.format(
repo_name=repo_name,
pull_number=pull_number,
title=title,
description=description,
file_diff=file_diff,
)
3 changes: 2 additions & 1 deletion server/bot/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ async def bot_info_generator(
else "我是你专属的答疑机器人,你可以问我关于当前项目的任何问题~"
),
"repo_name": repo_name,
"llm": "openai"
"llm": "openai",
"token_id": ""
}

return bot_data
Expand Down
4 changes: 3 additions & 1 deletion server/event_handler/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def execute(self):

file_diff = self.get_file_diff(diff)
role_prompt = get_role_prompt(
repo.full_name, pr.number, pr.title, pr.body, file_diff
repo.full_name, pr.number, pr.title, pr.body
)

print(f"file_diff={file_diff}")
Expand All @@ -92,6 +92,8 @@ async def execute(self):
{pr.title}
### Pr Description
{pr.body}
### File Diff
{file_diff}
"""
origin_bot = get_bot_by_id(repo_config.robot_id)

Expand Down

0 comments on commit ea895fd

Please sign in to comment.