From 0622fb42b0dffb61f200de998bc51d0004b25f43 Mon Sep 17 00:00:00 2001 From: Ismail Pelaseyed Date: Mon, 18 Mar 2024 09:21:48 +0100 Subject: [PATCH 1/2] Add support for Github tool --- .../app/api/workflow_configs/saml_schema.py | 1 + libs/superagent/app/models/tools.py | 4 ++++ libs/superagent/app/tools/__init__.py | 3 +++ libs/superagent/app/tools/github.py | 13 +++++++++++++ .../20240318081112_github_tool/migration.sql | 2 ++ libs/superagent/prisma/schema.prisma | 1 + libs/ui/config/site.ts | 8 ++++++++ 7 files changed, 32 insertions(+) create mode 100644 libs/superagent/app/tools/github.py create mode 100644 libs/superagent/prisma/migrations/20240318081112_github_tool/migration.sql diff --git a/libs/superagent/app/api/workflow_configs/saml_schema.py b/libs/superagent/app/api/workflow_configs/saml_schema.py index e494e0197..ee3160266 100644 --- a/libs/superagent/app/api/workflow_configs/saml_schema.py +++ b/libs/superagent/app/api/workflow_configs/saml_schema.py @@ -81,6 +81,7 @@ class ToolModel(BaseModel): metaphor: Optional[Tool] function: Optional[Tool] research: Optional[Tool] + github: Optional[Tool] # ~~~~~~Assistants as tools~~~~~~ superagent: Optional["SuperagentAgentTool"] openai_assistant: Optional["OpenAIAgentTool"] diff --git a/libs/superagent/app/models/tools.py b/libs/superagent/app/models/tools.py index 431e0af7a..89ee6d60a 100644 --- a/libs/superagent/app/models/tools.py +++ b/libs/superagent/app/models/tools.py @@ -98,3 +98,7 @@ class HTTPInput(BaseModel): class TavilyInput(BaseModel): query: str + + +class GithubInput(BaseModel): + query: str diff --git a/libs/superagent/app/tools/__init__.py b/libs/superagent/app/tools/__init__.py index d80a85a9b..f527b2362 100644 --- a/libs/superagent/app/tools/__init__.py +++ b/libs/superagent/app/tools/__init__.py @@ -25,6 +25,7 @@ WolframInput, ZapierInput, TavilyInput, + GithubInput, ) from app.tools.agent import Agent from app.tools.algolia import Algolia @@ -47,6 +48,7 @@ from app.tools.wolfram_alpha import WolframAlpha from app.tools.zapier import ZapierNLA from app.tools.tavily import Tavily +from app.tools.github import Github logger = logging.getLogger(__name__) @@ -80,6 +82,7 @@ "HTTP": {"class": LCHttpTool, "schema": HTTPInput}, "SUPERRAG": {"class": SuperRagTool, "schema": SuperRagInput}, "RESEARCH": {"class": Tavily, "schema": TavilyInput}, + "GITHUB": {"class": Github, "schema": GithubInput}, } OSS_TOOL_TYPE_MAPPING = {"BROWSER": Browser, "BING_SEARCH": BingSearch} diff --git a/libs/superagent/app/tools/github.py b/libs/superagent/app/tools/github.py new file mode 100644 index 000000000..5c783c32e --- /dev/null +++ b/libs/superagent/app/tools/github.py @@ -0,0 +1,13 @@ +from langchain_community.tools import BaseTool + + +class Github(BaseTool): + name = "Github" + description = "useful for answering questions about github projects" + return_direct = False + + def _run(self, query: str) -> str: + pass + + async def _arun(self, query: str) -> str: + pass diff --git a/libs/superagent/prisma/migrations/20240318081112_github_tool/migration.sql b/libs/superagent/prisma/migrations/20240318081112_github_tool/migration.sql new file mode 100644 index 000000000..90b89b6c5 --- /dev/null +++ b/libs/superagent/prisma/migrations/20240318081112_github_tool/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "ToolType" ADD VALUE 'GITHUB'; diff --git a/libs/superagent/prisma/schema.prisma b/libs/superagent/prisma/schema.prisma index c30657d57..3c24d9459 100644 --- a/libs/superagent/prisma/schema.prisma +++ b/libs/superagent/prisma/schema.prisma @@ -59,6 +59,7 @@ enum ToolType { HTTP SUPERRAG RESEARCH + GITHUB } enum DatasourceType { diff --git a/libs/ui/config/site.ts b/libs/ui/config/site.ts index 4b4f7a75c..4637a24e6 100644 --- a/libs/ui/config/site.ts +++ b/libs/ui/config/site.ts @@ -377,6 +377,14 @@ export const siteConfig = { title: "Research", metadata: [{ key: "apiKey", type: "input", label: "Tavily API key" }], }, + { + value: "GITHUB", + title: "Github", + metadata: [ + { key: "apiKey", type: "input", label: "Github API key" }, + { key: "repository", type: "input", label: "Github Repository" }, + ], + }, { value: "SUPERRAG", title: "SuperRag", From c53542b129bc1b0f9719328331b777e9f691c97a Mon Sep 17 00:00:00 2001 From: Ismail Pelaseyed Date: Mon, 18 Mar 2024 09:55:36 +0100 Subject: [PATCH 2/2] Add branch to tool option --- libs/ui/config/site.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ui/config/site.ts b/libs/ui/config/site.ts index 4637a24e6..98a53b7ae 100644 --- a/libs/ui/config/site.ts +++ b/libs/ui/config/site.ts @@ -383,6 +383,7 @@ export const siteConfig = { metadata: [ { key: "apiKey", type: "input", label: "Github API key" }, { key: "repository", type: "input", label: "Github Repository" }, + { key: "branch", type: "input", label: "Repositroy branch" }, ], }, {