Skip to content
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

Add support for SEC API as a tool #974

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/superagent/app/api/workflow_configs/saml_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 5 additions & 1 deletion libs/superagent/app/models/tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel
from pydantic import BaseModel, Field


class AlgoliaInput(BaseModel):
Expand Down Expand Up @@ -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")
3 changes: 3 additions & 0 deletions libs/superagent/app/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
TTS1Input,
WolframInput,
ZapierInput,
SECInput,
)
from app.tools.advanced_scraper import AdvancedScraper
from app.tools.agent import Agent
Expand All @@ -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__)

Expand Down Expand Up @@ -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}
Expand Down
22 changes: 22 additions & 0 deletions libs/superagent/app/tools/sec.py
Original file line number Diff line number Diff line change
@@ -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:
homanp marked this conversation as resolved.
Show resolved Hide resolved
async with session.post(url, json=data) as response:
return await response.text()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "ToolType" ADD VALUE 'SEC';
1 change: 1 addition & 0 deletions libs/superagent/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum ToolType {
SCRAPER
ADVANCED_SCRAPER
GOOGLE_SEARCH
SEC
}

enum DatasourceType {
Expand Down
16 changes: 16 additions & 0 deletions libs/ui/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down