-
Notifications
You must be signed in to change notification settings - Fork 703
feat: add line range support to get_file_contents tool #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, added some notes. I haven't reviewed the line implementation because I'd rather see tests that pass first.
@@ -15,6 +15,66 @@ automation and interaction capabilities for developers and tools. | |||
## Prerequisites | |||
|
|||
1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed. | |||
|
|||
## Required Token Permissions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this section. I think it's interesting to have, but should have its own issue for discussion.
- `owner`: Repository owner (string, required) | ||
- `repo`: Repository name (string, required) | ||
- `sha`: Branch name, tag, or commit SHA (string, optional) | ||
- `path`: Only commits containing this file path (string, optional) | ||
- `page`: Page number (number, optional) | ||
- `perPage`: Results per page (number, optional) | ||
|
||
### Search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is moved.
@@ -471,7 +488,39 @@ func GetFileContents(getClient GetClientFn, t translations.TranslationHelperFunc | |||
|
|||
var result interface{} | |||
if fileContent != nil { | |||
result = fileContent | |||
if fileContent.Content != nil && (begin > 0 || end > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this implementation. Should it be possible for the LLM to only provide the beginning or the end? Whatever we choose should be documented so the LLM understands what is acceptable.
} | ||
} else { | ||
result = fileContent | ||
} | ||
} else { | ||
result = dirContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should happen if the LLM provides begin and end but the contents returned are dirContent
? How do we communicate what is acceptable to the LLM in the description?
@@ -471,7 +488,39 @@ func GetFileContents(getClient GetClientFn, t translations.TranslationHelperFunc | |||
|
|||
var result interface{} | |||
if fileContent != nil { | |||
result = fileContent | |||
if fileContent.Content != nil && (begin > 0 || end > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this needs to be unit tested.
} | ||
ranged := lines[startIdx:endIdx] | ||
joined := strings.Join(ranged, "\n") | ||
result = &github.RepositoryContent{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we should check the .Encoding
of the file content before deciding that we need to base64 encode it.
Closes: #350