diff --git a/libs/superagent/app/api/workflow_configs/saml_schema.py b/libs/superagent/app/api/workflow_configs/saml_schema.py index 01253e758..2d7761881 100644 --- a/libs/superagent/app/api/workflow_configs/saml_schema.py +++ b/libs/superagent/app/api/workflow_configs/saml_schema.py @@ -82,6 +82,7 @@ class ToolModel(BaseModel): metaphor: Optional[Tool] function: Optional[Tool] research: Optional[Tool] + sec: 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 bc6d365f6..af0ce6185 100644 --- a/libs/superagent/app/models/tools.py +++ b/libs/superagent/app/models/tools.py @@ -1,6 +1,6 @@ from typing import Optional -from pydantic import BaseModel +from pydantic import BaseModel, Field class AlgoliaInput(BaseModel): @@ -108,3 +108,7 @@ class AdvancedScraperInput(BaseModel): class GoogleSearchInput(BaseModel): query: str + + +class SECInput(BaseModel): + ticker: str = Field(..., description="The stock ticker symbol for the company") diff --git a/libs/superagent/app/tools/__init__.py b/libs/superagent/app/tools/__init__.py index 049549501..92d25eb05 100644 --- a/libs/superagent/app/tools/__init__.py +++ b/libs/superagent/app/tools/__init__.py @@ -28,6 +28,7 @@ TTS1Input, WolframInput, ZapierInput, + SECInput, ) from app.tools.advanced_scraper import AdvancedScraper from app.tools.agent import Agent @@ -53,6 +54,7 @@ from app.tools.tts_1 import TTS1 from app.tools.wolfram_alpha import WolframAlpha from app.tools.zapier import ZapierNLA +from app.tools.sec import SEC logger = logging.getLogger(__name__) @@ -89,6 +91,7 @@ "SCRAPER": {"class": Scraper, "schema": ScraperInput}, "ADVANCED_SCRAPER": {"class": AdvancedScraper, "schema": AdvancedScraperInput}, "GOOGLE_SEARCH": {"class": GoogleSearch, "schema": GoogleSearchInput}, + "SEC": {"class": SEC, "schema": SECInput}, } OSS_TOOL_TYPE_MAPPING = {"BROWSER": Browser, "BING_SEARCH": BingSearch} diff --git a/libs/superagent/app/tools/sec.py b/libs/superagent/app/tools/sec.py new file mode 100644 index 000000000..114696611 --- /dev/null +++ b/libs/superagent/app/tools/sec.py @@ -0,0 +1,22 @@ +import aiohttp + +from langchain_community.tools import BaseTool + + +class SEC(BaseTool): + name = "SEC" + description = "useful for searching SEC filings for a company" + return_direct = False + + def _run(self, ticker: str) -> str: + pass + + async def _arun(self, ticker: str) -> str: + form = self.metadata.get("form") + identity = self.metadata.get("identity") + url = "https://super-sec.replit.app/search" + data = {"form": form, "identity": identity, "ticker": ticker} + + async with aiohttp.ClientSession() as session: + async with session.post(url, json=data) as response: + return await response.text() diff --git a/libs/superagent/prisma/migrations/20240424143511_add_sec_api/migration.sql b/libs/superagent/prisma/migrations/20240424143511_add_sec_api/migration.sql new file mode 100644 index 000000000..cff891724 --- /dev/null +++ b/libs/superagent/prisma/migrations/20240424143511_add_sec_api/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "ToolType" ADD VALUE 'SEC'; diff --git a/libs/superagent/prisma/schema.prisma b/libs/superagent/prisma/schema.prisma index c3125752d..d10bb6620 100644 --- a/libs/superagent/prisma/schema.prisma +++ b/libs/superagent/prisma/schema.prisma @@ -67,6 +67,7 @@ enum ToolType { SCRAPER ADVANCED_SCRAPER GOOGLE_SEARCH + SEC } enum DatasourceType { diff --git a/libs/ui/config/site.ts b/libs/ui/config/site.ts index f65099579..64fa1e01c 100644 --- a/libs/ui/config/site.ts +++ b/libs/ui/config/site.ts @@ -446,6 +446,22 @@ export const siteConfig = { }, ], }, + { + value: "SEC", + title: "SEC API", + metadata: [ + { + key: "identity", + type: "input", + label: "Identity string", + }, + { + key: "form", + type: "input", + label: "10-K, 10-Q, 8-K etc", + }, + ], + }, ], llmForm: [ {