You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `help_docs` tool answers a question based on a given relative path of documentation, either from the repository of this merge request or from a given one.
4
+
It can be invoked manually by commenting on any PR:
5
+
```
6
+
/help_docs "..."
7
+
```
8
+
9
+
## Example usage
10
+
11
+
{width=512}
12
+
13
+
{width=512}
Under the section `--pr_help_docs`, the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L50) contains options to customize the 'help docs' tool:
20
+
21
+
-`repo_url`: If not overwritten, will use the repo from where the context came from (issue or PR), otherwise - use the given repo as context.
22
+
-`repo_default_branch`: The branch to use in case repo_url overwritten, otherwise - has no effect.
23
+
-`docs_path`: Relative path from root of repository (either the one this PR has been issued for, or above repo url).
24
+
-`exclude_root_readme`: Whether or not to exclude the root README file for querying the model.
25
+
-`supported_doc_exts` : Which file extensions should be included for the purpose of querying the model.
if ('gpt'inget_settings().config.model.lower() ormodel_is_from_o_series) andget_settings(use_context=False).get('openai.key'):
131
+
returnencoder_estimate
132
+
#else: Model is neither an OpenAI, nor an Anthropic model - therefore, cannot provide an accurate token count and instead, return a higher number as best effort.
# Given a git repo url, return prefix and suffix of the provider in order to view a given file belonging to that repo. Needs to be implemented by the provider.
26
+
# For example: For a git: https://git_provider.com/MY_PROJECT/MY_REPO.git and desired branch: <MY_BRANCH> then it should return ('https://git_provider.com/projects/MY_PROJECT/repos/MY_REPO/.../<MY_BRANCH>', '?=<SOME HEADER>')
27
+
# so that to properly view the file: docs/readme.md -> <PREFIX>/docs/readme.md<SUFFIX> -> https://git_provider.com/projects/MY_PROJECT/repos/MY_REPO/<MY_BRANCH>/docs/readme.md?=<SOME HEADER>)
# #From this point, returned_obj.path may be deleted at any point and therefore must not be used.
40
+
classScopedClonedRepo(object):
41
+
def__init__(self, dest_folder):
42
+
self.path=dest_folder
43
+
44
+
def__del__(self):
45
+
ifself.pathandos.path.exists(self.path):
46
+
shutil.rmtree(self.path, ignore_errors=True)
47
+
48
+
#Method to allow implementors to manipulate the repo url to clone (such as embedding tokens in the url string). Needs to be implemented by the provider.
# requires a username, which may not be applicable.
652
+
# The following solution is taken from: https://stackoverflow.com/questions/25409700/using-gitlab-token-to-clone-without-authentication/35003812#35003812
653
+
# For example: For repo url: https://gitlab.codium-inc.com/qodo/autoscraper.git
654
+
# Then to clone one will issue: 'git clone https://oauth2:<access token>@gitlab.codium-inc.com/qodo/autoscraper.git'
output+=f"\n\nSee the improve [usage page](https://pr-agent-docs.codium.ai/tools/improve/) for a comprehensive guide on using this tool.\n\n"
202
203
203
204
returnoutput
205
+
206
+
207
+
@staticmethod
208
+
defget_help_docs_usage_guide():
209
+
output="**Overview:**\n"
210
+
output+="""\
211
+
The help docs tool, named `help_docs`, answers a question based on a given relative path of documentation, either from the repository of this merge request or from a given one."
212
+
It can be invoked manually by commenting on any PR:
213
+
```
214
+
/help_docs "..."
215
+
```
216
+
"""
217
+
output+=f"\n\nSee the [help_docs usage](https://pr-agent-docs.codium.ai/tools/help_docs/) page for a comprehensive guide on using this tool.\n\n"
Copy file name to clipboardExpand all lines: pr_agent/settings/configuration.toml
+9
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
model="o3-mini"
10
10
fallback_models=["gpt-4o-2024-11-20"]
11
11
#model_weak="gpt-4o-mini-2024-07-18" # optional, a weaker model to use for some easier tasks
12
+
model_token_count_estimate_factor=0.3# factor to increase the token count estimate, in order to reduce likelihood of model failure due to too many tokens.
12
13
# CLI
13
14
git_provider="github"
14
15
publish_output=true
@@ -212,6 +213,14 @@ num_retrieved_snippets=5
212
213
213
214
[pr_config] # /config #
214
215
216
+
[pr_help_docs]
217
+
repo_url = ""#If not overwritten, will use the repo from where the context came from (issue or PR)
218
+
repo_default_branch = "main"
219
+
docs_path = "docs"
220
+
exclude_root_readme = false
221
+
supported_doc_exts = [".md", ".mdx", ".rst"]
222
+
enable_help_text=false
223
+
215
224
[github]
216
225
# The type of deployment to create. Valid values are 'app' or 'user'.
system="""You are Doc-helper, a language model designed to answer questions about a documentation website for a given repository.
3
+
You will receive a question, a repository url and the full documentation content for that repository (either as markdown or as restructred text).
4
+
Your goal is to provide the best answer to the question using the documentation provided.
5
+
6
+
Additional instructions:
7
+
- Be short and concise in your answers. Give examples if needed.
8
+
- Answer only questions that are related to the documentation website content. If the question is completely unrelated to the documentation, return an empty response.
9
+
10
+
11
+
The output must be a YAML object equivalent to type $DocHelper, according to the following Pydantic definitions:
12
+
=====
13
+
class relevant_section(BaseModel):
14
+
file_name: str = Field(description="The name of the relevant file")
15
+
relevant_section_header_string: str = Field(description="The exact text of the relevant markdown/restructured text section heading from the relevant file (starting with '#', '##', etc.). Return empty string if the entire file is the relevant section, or if the relevant section has no heading")
response: str = Field(description="The response to the user's question")
20
+
relevant_sections: List[relevant_section] = Field(description="A list of the relevant markdown/restructured text sections in the documentation that answer the user's question, ordered by importance (most relevant first)")
21
+
question_is_relevant: int = Field(description="Return 1 if the question is somewhat relevant to documentation. 0 - otherwise")
22
+
=====
23
+
24
+
25
+
Example output:
26
+
```yaml
27
+
user_question: |
28
+
...
29
+
response: |
30
+
...
31
+
relevant_sections:
32
+
- file_name: "src/file1.py"
33
+
relevant_section_header_string: |
34
+
...
35
+
- ...
36
+
question_is_relevant: |
37
+
1
38
+
"""
39
+
40
+
user="""\
41
+
Documentation url: '{{ docs_url| trim }}'
42
+
-----
43
+
44
+
45
+
User's Question:
46
+
=====
47
+
{{ question|trim }}
48
+
=====
49
+
50
+
51
+
Documentation website content:
52
+
=====
53
+
{{ snippets|trim }}
54
+
=====
55
+
56
+
57
+
Reminder: The output must be a YAML object equivalent to type $DocHelper, similar to the following example output:
58
+
=====
59
+
Example output:
60
+
```yaml
61
+
user_question: |
62
+
...
63
+
response: |
64
+
...
65
+
relevant_sections:
66
+
- file_name: "src/file1.py"
67
+
relevant_section_header_string: |
68
+
...
69
+
- ...
70
+
question_is_relevant: |
71
+
1
72
+
=====
73
+
74
+
75
+
Response (should be a valid YAML, and nothing else).
0 commit comments