diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-09-12 01:16:41 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-09-12 01:16:41 -0700 |
commit | db3277bdc207cc8233ccc4c1d44a5c8e50785769 (patch) | |
tree | d0197d581bc89ffa3f19c407729c9ccf2f39e9fd | |
parent | 84fc39407648131d54a8ed5c95891906afc3cd60 (diff) | |
download | sncontinue-db3277bdc207cc8233ccc4c1d44a5c8e50785769.tar.gz sncontinue-db3277bdc207cc8233ccc4c1d44a5c8e50785769.tar.bz2 sncontinue-db3277bdc207cc8233ccc4c1d44a5c8e50785769.zip |
docs: :memo: additional cleanup for context providers docs
14 files changed, 51 insertions, 30 deletions
diff --git a/continuedev/src/continuedev/plugins/context_providers/diff.py b/continuedev/src/continuedev/plugins/context_providers/diff.py index 97e2a9da..157cbc33 100644 --- a/continuedev/src/continuedev/plugins/context_providers/diff.py +++ b/continuedev/src/continuedev/plugins/context_providers/diff.py @@ -1,6 +1,8 @@ import subprocess from typing import List +from pydantic import Field + from ...core.context import ContextProvider from ...core.main import ContextItem, ContextItemDescription, ContextItemId @@ -15,9 +17,11 @@ class DiffContextProvider(ContextProvider): description = "Output of 'git diff' in current repo" dynamic = True - DIFF_CONTEXT_ITEM_ID = "diff" + _DIFF_CONTEXT_ITEM_ID = "diff" - workspace_dir: str = None + workspace_dir: str = Field( + None, description="The workspace directory in which to run `git diff`" + ) @property def BASE_CONTEXT_ITEM(self): @@ -27,7 +31,7 @@ class DiffContextProvider(ContextProvider): name="Diff", description="Reference the output of 'git diff' for the current workspace", id=ContextItemId( - provider_title=self.title, item_id=self.DIFF_CONTEXT_ITEM_ID + provider_title=self.title, item_id=self._DIFF_CONTEXT_ITEM_ID ), ), ) diff --git a/continuedev/src/continuedev/plugins/context_providers/filetree.py b/continuedev/src/continuedev/plugins/context_providers/filetree.py index 60838350..5b3d3a50 100644 --- a/continuedev/src/continuedev/plugins/context_providers/filetree.py +++ b/continuedev/src/continuedev/plugins/context_providers/filetree.py @@ -1,6 +1,6 @@ from typing import List -from pydantic import BaseModel +from pydantic import BaseModel, Field from ...core.context import ContextProvider from ...core.main import ContextItem, ContextItemDescription, ContextItemId @@ -41,7 +41,7 @@ class FileTreeContextProvider(ContextProvider): description = "Add a formatted file tree of this directory to the context" dynamic = True - workspace_dir: str = None + workspace_dir: str = Field(None, description="The workspace directory to display") async def _get_file_tree(self, directory: str) -> str: contents = await self.sdk.ide.listDirectoryContents(directory, recursive=True) diff --git a/continuedev/src/continuedev/plugins/context_providers/github.py b/continuedev/src/continuedev/plugins/context_providers/github.py index 2e54631d..c031f310 100644 --- a/continuedev/src/continuedev/plugins/context_providers/github.py +++ b/continuedev/src/continuedev/plugins/context_providers/github.py @@ -1,6 +1,7 @@ from typing import List from github import Auth, Github +from pydantic import Field from ...core.context import ( ContextItem, @@ -16,8 +17,13 @@ class GitHubIssuesContextProvider(ContextProvider): """ title = "issues" - repo_name: str - auth_token: str + repo_name: str = Field( + ..., description="The name of the GitHub repo from which to pull issues" + ) + auth_token: str = Field( + ..., + description="The GitHub auth token to use to authenticate with the GitHub API", + ) display_title = "GitHub Issues" description = "Reference GitHub issues" diff --git a/continuedev/src/continuedev/plugins/context_providers/google.py b/continuedev/src/continuedev/plugins/context_providers/google.py index ce616d74..852f4e9a 100644 --- a/continuedev/src/continuedev/plugins/context_providers/google.py +++ b/continuedev/src/continuedev/plugins/context_providers/google.py @@ -2,6 +2,7 @@ import json from typing import List import aiohttp +from pydantic import Field from ...core.context import ContextProvider from ...core.main import ContextItem, ContextItemDescription, ContextItemId @@ -17,9 +18,12 @@ class GoogleContextProvider(ContextProvider): dynamic = True requires_query = True - serper_api_key: str + serper_api_key: str = Field( + ..., + description="Your SerpAPI key, used to programmatically make Google searches. You can get a key at https://serper.dev.", + ) - GOOGLE_CONTEXT_ITEM_ID = "google_search" + _GOOGLE_CONTEXT_ITEM_ID = "google_search" @property def BASE_CONTEXT_ITEM(self): @@ -29,7 +33,7 @@ class GoogleContextProvider(ContextProvider): name="Google Search", description="Enter a query to search google", id=ContextItemId( - provider_title=self.title, item_id=self.GOOGLE_CONTEXT_ITEM_ID + provider_title=self.title, item_id=self._GOOGLE_CONTEXT_ITEM_ID ), ), ) diff --git a/continuedev/src/continuedev/plugins/context_providers/search.py b/continuedev/src/continuedev/plugins/context_providers/search.py index fc09f6b8..4e2e33da 100644 --- a/continuedev/src/continuedev/plugins/context_providers/search.py +++ b/continuedev/src/continuedev/plugins/context_providers/search.py @@ -1,6 +1,7 @@ import os from typing import List +from pydantic import Field from ripgrepy import Ripgrepy from ...core.context import ContextProvider @@ -18,9 +19,9 @@ class SearchContextProvider(ContextProvider): dynamic = True requires_query = True - SEARCH_CONTEXT_ITEM_ID = "search" + _SEARCH_CONTEXT_ITEM_ID = "search" - workspace_dir: str = None + workspace_dir: str = Field(None, description="The workspace directory to search") @property def BASE_CONTEXT_ITEM(self): @@ -30,7 +31,7 @@ class SearchContextProvider(ContextProvider): name="Search", description="Search the workspace for all matches of an exact string (e.g. '@search console.log')", id=ContextItemId( - provider_title=self.title, item_id=self.SEARCH_CONTEXT_ITEM_ID + provider_title=self.title, item_id=self._SEARCH_CONTEXT_ITEM_ID ), ), ) diff --git a/continuedev/src/continuedev/plugins/context_providers/terminal.py b/continuedev/src/continuedev/plugins/context_providers/terminal.py index 728e7934..c63239e4 100644 --- a/continuedev/src/continuedev/plugins/context_providers/terminal.py +++ b/continuedev/src/continuedev/plugins/context_providers/terminal.py @@ -1,5 +1,7 @@ from typing import Any, Coroutine, List +from pydantic import Field + from ...core.context import ContextProvider from ...core.main import ChatMessage, ContextItem, ContextItemDescription, ContextItemId @@ -12,8 +14,9 @@ class TerminalContextProvider(ContextProvider): description = "Reference the contents of the terminal" dynamic = True - workspace_dir: str = None - get_last_n_commands: int = 3 + get_last_n_commands: int = Field( + 3, description="The number of previous commands to reference" + ) def _terminal_context_item(self, content: str = ""): return ContextItem( @@ -32,7 +35,6 @@ class TerminalContextProvider(ContextProvider): return msgs async def provide_context_items(self, workspace_dir: str) -> List[ContextItem]: - self.workspace_dir = workspace_dir return [self._terminal_context_item()] async def get_item(self, id: ContextItemId, query: str) -> ContextItem: diff --git a/continuedev/src/continuedev/plugins/context_providers/url.py b/continuedev/src/continuedev/plugins/context_providers/url.py index 8b7f137d..2a293dc7 100644 --- a/continuedev/src/continuedev/plugins/context_providers/url.py +++ b/continuedev/src/continuedev/plugins/context_providers/url.py @@ -2,6 +2,7 @@ from typing import List import requests from bs4 import BeautifulSoup +from pydantic import Field from ...core.context import ContextProvider from ...core.main import ContextItem, ContextItemDescription, ContextItemId @@ -18,13 +19,16 @@ class URLContextProvider(ContextProvider): requires_query = True # Allows users to provide a list of preset urls - preset_urls: List[str] = [] + preset_urls: List[str] = Field( + [], + description="A list of preset URLs that you will be able to quickly reference by typing '@url'", + ) # Static items loaded from preset_urls - static_url_context_items: List[ContextItem] = [] + _static_url_context_items: List[ContextItem] = [] # There is only a single dynamic url context item, so it has a static id - DYNAMIC_URL_CONTEXT_ITEM_ID = "url" + _DYNAMIC_URL_CONTEXT_ITEM_ID = "url" # This is a template dynamic item that will generate context item on demand # when get item is called @@ -36,7 +40,7 @@ class URLContextProvider(ContextProvider): name="Dynamic URL", description="Reference the contents of a webpage (e.g. '@url https://www.w3schools.com/python/python_ref_functions.asp')", id=ContextItemId( - provider_title=self.title, item_id=self.DYNAMIC_URL_CONTEXT_ITEM_ID + provider_title=self.title, item_id=self._DYNAMIC_URL_CONTEXT_ITEM_ID ), ), ) @@ -64,18 +68,18 @@ class URLContextProvider(ContextProvider): return soup.get_text(), title async def provide_context_items(self, workspace_dir: str) -> List[ContextItem]: - self.static_url_context_items = [ + self._static_url_context_items = [ self.static_url_context_item_from_url(url) for url in self.preset_urls ] - return [self.DYNAMIC_CONTEXT_ITEM] + self.static_url_context_items + return [self.DYNAMIC_CONTEXT_ITEM] + self._static_url_context_items async def get_item(self, id: ContextItemId, query: str) -> ContextItem: # Check if the item is a static item matching_static_item = next( ( item - for item in self.static_url_context_items + for item in self._static_url_context_items if item.description.id.item_id == id.item_id ), None, diff --git a/docs/docs/reference/Context Providers/diff.md b/docs/docs/reference/Context Providers/diff.md index 00d63d58..2b809b91 100644 --- a/docs/docs/reference/Context Providers/diff.md +++ b/docs/docs/reference/Context Providers/diff.md @@ -8,7 +8,7 @@ Type '@diff' to reference all of the changes you've made to your current branch. ## Properties -<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "type": "string"}' required={false} default=""/><ClassPropertyRef name='DIFF_CONTEXT_ITEM_ID' details='{"title": "Diff Context Item Id", "default": "diff", "type": "string"}' required={false} default="diff"/> +<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory in which to run `git diff`", "type": "string"}' required={false} default=""/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/filetree.md b/docs/docs/reference/Context Providers/filetree.md index 94492d3d..8af3ba03 100644 --- a/docs/docs/reference/Context Providers/filetree.md +++ b/docs/docs/reference/Context Providers/filetree.md @@ -8,7 +8,7 @@ Type '@tree' to reference the contents of your current workspace. The LLM will b ## Properties -<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "type": "string"}' required={false} default=""/> +<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory to display", "type": "string"}' required={false} default=""/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/github.md b/docs/docs/reference/Context Providers/github.md index 21171ced..bd1f7cc3 100644 --- a/docs/docs/reference/Context Providers/github.md +++ b/docs/docs/reference/Context Providers/github.md @@ -8,7 +8,7 @@ The GitHubIssuesContextProvider is a ContextProvider that allows you to search G ## Properties -<ClassPropertyRef name='repo_name' details='{"title": "Repo Name", "type": "string"}' required={true} default=""/><ClassPropertyRef name='auth_token' details='{"title": "Auth Token", "type": "string"}' required={true} default=""/> +<ClassPropertyRef name='repo_name' details='{"title": "Repo Name", "description": "The name of the GitHub repo from which to pull issues", "type": "string"}' required={true} default=""/><ClassPropertyRef name='auth_token' details='{"title": "Auth Token", "description": "The GitHub auth token to use to authenticate with the GitHub API", "type": "string"}' required={true} default=""/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/google.md b/docs/docs/reference/Context Providers/google.md index d8452ab0..e5586982 100644 --- a/docs/docs/reference/Context Providers/google.md +++ b/docs/docs/reference/Context Providers/google.md @@ -8,7 +8,7 @@ Type '@google' to reference the results of a Google search. For example, type "@ ## Properties -<ClassPropertyRef name='serper_api_key' details='{"title": "Serper Api Key", "type": "string"}' required={true} default=""/><ClassPropertyRef name='GOOGLE_CONTEXT_ITEM_ID' details='{"title": "Google Context Item Id", "default": "google_search", "type": "string"}' required={false} default="google_search"/> +<ClassPropertyRef name='serper_api_key' details='{"title": "Serper Api Key", "description": "Your SerpAPI key, used to programmatically make Google searches. You can get a key at https://serper.dev.", "type": "string"}' required={true} default=""/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/search.md b/docs/docs/reference/Context Providers/search.md index 5d80f607..efc82131 100644 --- a/docs/docs/reference/Context Providers/search.md +++ b/docs/docs/reference/Context Providers/search.md @@ -8,7 +8,7 @@ Type '@search' to reference the results of codebase search, just like the result ## Properties -<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "type": "string"}' required={false} default=""/><ClassPropertyRef name='SEARCH_CONTEXT_ITEM_ID' details='{"title": "Search Context Item Id", "default": "search", "type": "string"}' required={false} default="search"/> +<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "description": "The workspace directory to search", "type": "string"}' required={false} default=""/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/terminal.md b/docs/docs/reference/Context Providers/terminal.md index dce6f0a4..f97d2bf8 100644 --- a/docs/docs/reference/Context Providers/terminal.md +++ b/docs/docs/reference/Context Providers/terminal.md @@ -8,7 +8,7 @@ Type '@terminal' to reference the contents of your IDE's terminal. ## Properties -<ClassPropertyRef name='workspace_dir' details='{"title": "Workspace Dir", "type": "string"}' required={false} default=""/><ClassPropertyRef name='get_last_n_commands' details='{"title": "Get Last N Commands", "default": 3, "type": "integer"}' required={false} default="3"/> +<ClassPropertyRef name='get_last_n_commands' details='{"title": "Get Last N Commands", "description": "The number of previous commands to reference", "default": 3, "type": "integer"}' required={false} default="3"/> ### Inherited Properties diff --git a/docs/docs/reference/Context Providers/url.md b/docs/docs/reference/Context Providers/url.md index 3917dc38..e147e626 100644 --- a/docs/docs/reference/Context Providers/url.md +++ b/docs/docs/reference/Context Providers/url.md @@ -8,7 +8,7 @@ Type '@url' to reference the contents of a URL. You can either reference preset ## Properties -<ClassPropertyRef name='preset_urls' details='{"title": "Preset Urls", "default": [], "type": "array", "items": {"type": "string"}}' required={false} default="[]"/><ClassPropertyRef name='static_url_context_items' details='{"title": "Static Url Context Items", "default": [], "type": "array", "items": {"$ref": "#/definitions/ContextItem"}}' required={false} default="[]"/><ClassPropertyRef name='DYNAMIC_URL_CONTEXT_ITEM_ID' details='{"title": "Dynamic Url Context Item Id", "default": "url", "type": "string"}' required={false} default="url"/> +<ClassPropertyRef name='preset_urls' details='{"title": "Preset Urls", "description": "A list of preset URLs that you will be able to quickly reference by typing '@url'", "default": [], "type": "array", "items": {"type": "string"}}' required={false} default="[]"/> ### Inherited Properties |