LukeMattingly commited on
Commit
ed95b63
·
1 Parent(s): 8e307ce

prompt modifications and new reasoning model

Browse files
Files changed (2) hide show
  1. app.py +5 -4
  2. prompts.yaml +48 -15
app.py CHANGED
@@ -195,7 +195,7 @@ def detect_code_smells(code: str) -> str:
195
 
196
  except Exception as e:
197
  return f"Error analyzing code: {str(e)}"
198
-
199
  @tool
200
  def get_file_content(github_url: str, file_path: str) -> str:
201
  """Fetches the content of a specific file from the GitHub repository.
@@ -216,7 +216,8 @@ def get_file_content(github_url: str, file_path: str) -> str:
216
  return response.text
217
  except Exception as e:
218
  return f"Error: {str(e)}"
219
-
 
220
  @tool
221
  def security_check_code(code: str) -> str:
222
  """Analyzes the provided code snippet for potential security vulnerabilities.
@@ -312,7 +313,7 @@ final_answer = FinalAnswerTool()
312
  model = HfApiModel(
313
  max_tokens=2096,
314
  temperature=0.5,
315
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
316
  custom_role_conversions=None,
317
  )
318
 
@@ -322,7 +323,7 @@ with open("prompts.yaml", 'r') as stream:
322
 
323
  agent = CodeAgent(
324
  model=model,
325
- tools=[final_answer, get_open_pull_requests, find_todo_comments, get_pr_diff, get_pr_files_changed, detect_code_smells, get_file_content, security_check_code, check_documentation_updates, lint_code, get_pr_diff_for_file ], ## add your tools here (don't remove final answer)
326
  max_steps=6,
327
  verbosity_level=1,
328
  grammar=None,
 
195
 
196
  except Exception as e:
197
  return f"Error analyzing code: {str(e)}"
198
+ '''
199
  @tool
200
  def get_file_content(github_url: str, file_path: str) -> str:
201
  """Fetches the content of a specific file from the GitHub repository.
 
216
  return response.text
217
  except Exception as e:
218
  return f"Error: {str(e)}"
219
+
220
+ '''
221
  @tool
222
  def security_check_code(code: str) -> str:
223
  """Analyzes the provided code snippet for potential security vulnerabilities.
 
313
  model = HfApiModel(
314
  max_tokens=2096,
315
  temperature=0.5,
316
+ model_id='deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',# it is possible that this model may be overloaded deepseek-ai/DeepSeek-R1-Distill-Qwen-32B || Qwen/Qwen2.5-Coder-32B-Instruct
317
  custom_role_conversions=None,
318
  )
319
 
 
323
 
324
  agent = CodeAgent(
325
  model=model,
326
+ tools=[final_answer, get_open_pull_requests, find_todo_comments, get_pr_diff, get_pr_files_changed, detect_code_smells, security_check_code, check_documentation_updates, lint_code, get_pr_diff_for_file ], ## add your tools here (don't remove final answer)
327
  max_steps=6,
328
  verbosity_level=1,
329
  grammar=None,
prompts.yaml CHANGED
@@ -11,33 +11,66 @@
11
 
12
  Here are a few examples using notional tools:
13
  ---
14
- Task: "Generate an image of the oldest person in this document."
 
 
15
 
16
- Thought: I will proceed step by step and use the following tools: `document_qa` to find the oldest person in the document, then `image_generator` to generate an image according to the answer.
17
  Code:
18
  ```py
19
- answer = document_qa(document=document, question="Who is the oldest person mentioned?")
20
- print(answer)
21
  ```<end_code>
22
- Observation: "The oldest person in the document is John Doe, a 55 year old lumberjack living in Newfoundland."
23
 
24
- Thought: I will now generate an image showcasing the oldest person.
25
- Code:
 
 
 
26
  ```py
27
- image = image_generator("A portrait of John Doe, a 55-year-old man living in Canada.")
28
- final_answer(image)
 
29
  ```<end_code>
30
 
31
  ---
32
- Task: "What is the result of the following operation: 5 + 3 + 1294.678?"
33
 
34
- Thought: I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool
35
- Code:
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  ```py
37
- result = 5 + 3 + 1294.678
38
- final_answer(result)
 
 
 
 
 
39
  ```<end_code>
40
 
 
 
 
 
 
 
 
 
 
 
 
41
  ---
42
  Task:
43
  "Answer the question in the variable `question` about the image stored in the variable `image`. The question is in French.
@@ -317,5 +350,5 @@
317
  Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
318
  And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
319
  "report": |-
320
- Here is the final answer from your managed agent '{{name}}':
321
  {{final_answer}}
 
11
 
12
  Here are a few examples using notional tools:
13
  ---
14
+ Task: "Review pull request #42 for TODO and FIXME comments."
15
+
16
+ Thought: I will start by retrieving the list of files changed in PR #42 using get_pr_files_changed, then fetch the diffs using get_pr_diff_for_file, and finally run find_todo_comments on each diff.
17
 
 
18
  Code:
19
  ```py
20
+ files_changed = get_pr_files_changed(github_url="https://github.com/user/repo", pr_number=42)
21
+ print(files_changed)
22
  ```<end_code>
 
23
 
24
+ **Observation:** "['src/main.py', 'docs/README.md']"
25
+
26
+ **Thought:** Now I will retrieve the diff for 'src/main.py' and check for any TODO or FIXME comments.
27
+
28
+ **Code:**
29
  ```py
30
+ diff_main = get_pr_diff_for_file(github_url="https://github.com/user/repo", pr_number=42, file_path="src/main.py")
31
+ comments = find_todo_comments(code=diff_main)
32
+ final_answer("TODO/FIXME Comments in src/main.py:\n" + comments)
33
  ```<end_code>
34
 
35
  ---
36
+ **Example 2: Full Code Quality and Security Review**
37
 
38
+ **Task:** "Review pull request #105 for potential code smells, linting issues, and security vulnerabilities."
39
+
40
+ **Thought:** I will start by listing all files changed in the PR, then for each file, fetch its diff and run `detect_code_smells`, `lint_code`, and `security_check_code` to capture any issues.
41
+
42
+ **Code:**
43
+ ```py
44
+ files_changed = get_pr_files_changed(github_url="https://github.com/user/repo", pr_number=105)
45
+ print(files_changed)
46
+ ```<end_code>
47
+
48
+ **Observation:** "['app/controller.py', 'app/model.py', 'README.md']"
49
+
50
+ **Thought:** Now, I will process each file. For instance, for 'app/controller.py':
51
+
52
+ **Code:**
53
  ```py
54
+ diff_controller = get_pr_diff_for_file(github_url="https://github.com/user/repo", pr_number=105, file_path="app/controller.py")
55
+ smells = detect_code_smells(code=diff_controller)
56
+ lint_issues = lint_code(code=diff_controller)
57
+ security_issues = security_check_code(code=diff_controller)
58
+ print("Smells:", smells)
59
+ print("Lint Issues:", lint_issues)
60
+ print("Security Issues:", security_issues)
61
  ```<end_code>
62
 
63
+ **Observation:** *(Outputs from each tool will be shown here.)*
64
+
65
+ **Thought:** Finally, check if documentation was updated:
66
+
67
+ **Code:**
68
+ ```py
69
+ docs_update = check_documentation_updates(changed_files="app/controller.py\napp/model.py\nREADME.md")
70
+ final_answer("Review Summary:\nDocumentation: " + docs_update + "\nPlease refer to the detailed logs for further recommendations.")
71
+ ```<end_code>
72
+
73
+
74
  ---
75
  Task:
76
  "Answer the question in the variable `question` about the image stored in the variable `image`. The question is in French.
 
350
  Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
351
  And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
352
  "report": |-
353
+ Here is the final review from your managed agent '{{name}}':
354
  {{final_answer}}