Refactor fetchText into global function and remove from PromptContext #699
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
fetchText
function by moving it into a global function and removing it from thePromptContext
interface. This change improves code organization and removes unnecessary duplication.Based on the GIT_DIFF provided, here's a high-level summary of the changes:
fetchText
method has been moved fromPromptContext
class inpromptcontext.ts
and inserted intoinstallGlobals
function inglobals.ts
file. The purpose is likely to makefetchText
a part of backend global context which could potentially make this function globally accessible rather than having it limited to thePromptContext
scope.fetchText
function's code shows that this function fetches the text content of a file specified by URL or path. It also handleshttp
and local workspace paths, fetching respective contents, encapsulating all related error handling in itself.fetchText
remains the same in the new location. That is, it still takes inurlOrFile
and optionalfetchOptions
as arguments, and returns an object containing information about the operation success status, HTTP status, text content of the file, or theWorkspaceFile
object.PromptContext
inpromptcontext.ts
also resulted in removal of respective imports including fetch and readText, as these were only used by the removedfetchText
function.PromptContext
API surface, which is user-facing, has been altered due to the removal of thefetchtext
method from it. This change is reflected in theprompt_template.d.ts
.These changes to the codebase do not alter the import statements, which suggests the dependencies of the project remain the same.
We can assume these modifications are aimed at enhancing the project architecture by repositioning functionality to its more logical place and changing the public API as a result of that. 🏗️💻🔄🌐