SEC EDGAR agentkit for Hugging Face smolagents framework
Project description
SEC EDGAR agentkit for smolagents
A lightweight integration of SEC EDGAR data access tools for Hugging Face's smolagents framework.
Installation
pip install sec-edgar-agentkit-smolagents
# or
pip install -r requirements.txt
Quick Start
from sec_edgar_smolagents import create_sec_edgar_agent
# Create an agent with all SEC EDGAR tools
agent = create_sec_edgar_agent("gpt-4")
# Ask questions about companies and filings
result = agent.run("What was Apple's revenue last year?")
print(result)
Available Tools
CIKLookupTool- Look up company CIK by name or tickerCompanyInfoTool- Get detailed company informationCompanyFactsTool- Retrieve XBRL company factsFilingSearchTool- Search for SEC filingsFilingContentTool- Extract filing contentAnalyze8KTool- Analyze 8-K material eventsFinancialStatementsTool- Extract financial statementsXBRLParseTool- Parse XBRL dataInsiderTradingTool- Analyze Forms 3/4/5
Usage Examples
Basic Company Research
from sec_edgar_smolagents import create_sec_edgar_agent
agent = create_sec_edgar_agent("gpt-4")
# Simple queries
agent.run("Find Microsoft's latest 10-K filing")
agent.run("What were Tesla's material events in the last quarter?")
agent.run("Show me insider trading activity for Apple")
Using Specific Tools
from sec_edgar_smolagents import CIKLookupTool, FilingSearchTool
# Create agent with only specific tools
agent = create_sec_edgar_agent(
"gpt-4",
tools=[CIKLookupTool(), FilingSearchTool()]
)
result = agent.run("Find Amazon's CIK and recent filings")
Different Model Providers
# OpenAI
agent = create_sec_edgar_agent("gpt-4")
# Anthropic
agent = create_sec_edgar_agent("claude-3-opus-20240229")
# Hugging Face API
from smolagents import HfApiModel
model = HfApiModel("meta-llama/Llama-3-8b-instruct")
agent = create_sec_edgar_agent(model)
# Local model
from smolagents import TransformersModel
model = TransformersModel("microsoft/Phi-3-mini-4k-instruct")
agent = create_sec_edgar_agent(model)
Financial Analysis
agent = create_sec_edgar_agent("gpt-4")
# Complex multi-step analysis
analysis = agent.run("""
1. Find Apple's last 3 years of 10-K filings
2. Extract revenue and net income from each
3. Calculate year-over-year growth rates
4. Compare with Microsoft's performance
""")
print(analysis)
MCP Server Configuration
The tools connect to the sec-edgar-mcp server. By default, it looks for the server at the sec-edgar-mcp command. You can customize this:
from sec_edgar_smolagents import SECEdgarToolkit
from sec_edgar_smolagents.mcp_client import MCPClient
# Custom MCP server command
client = MCPClient(server_command="/path/to/sec-edgar-mcp")
toolkit = SECEdgarToolkit(mcp_client=client)
agent = create_sec_edgar_agent("gpt-4", tools=toolkit.get_tools())
Development
Running Tests
pytest integrations/smolagents/__tests__/
Running Examples
cd integrations/smolagents
python examples/basic_usage.py
python examples/financial_analysis.py
Requirements
- Python 3.8+
- smolagents >= 0.1.0
- sec-edgar-mcp server installed (
pip install sec-edgar-mcp)
License
AGPL-3.0 - See LICENSE for details.
Author
Stefano Amorelli stefano@amorelli.tech
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sec_edgar_agentkit_smolagents-0.1.0.tar.gz.
File metadata
- Download URL: sec_edgar_agentkit_smolagents-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21c4ad84fa025267d58399801a5422f939487fa9f5a6ee443de33a9a08637aa
|
|
| MD5 |
9b7eac52c1d7889d349e5d0fb95bb101
|
|
| BLAKE2b-256 |
0852a19b665d4565b7abc8b9f93b018e6af17f0973305de2b403788d7a1130f5
|
File details
Details for the file sec_edgar_agentkit_smolagents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sec_edgar_agentkit_smolagents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58473b9833e3a8a846d15bcb33babd30aa7accac30a27be0b1dda6258b961627
|
|
| MD5 |
d80c539538732e6f5c142d4d0c705d92
|
|
| BLAKE2b-256 |
1036ff4c1b4ee2a1cdbeb878621887a4fa399c0d3b9c92b49f8a8b1cf96de528
|