@sec-edgar-agentkit/langchain
v0.1.0
Published
LangChain toolkit for SEC EDGAR data analysis
Maintainers
Readme
SEC EDGAR Agentkit for LangChain
SEC EDGAR toolkit for LangChain agents.
Installation
npm install @sec-edgar-agentkit/langchain @langchain/core @langchain/openai langchain zodUsage
import { SECEdgarAgentToolkit } from '@sec-edgar-agentkit/langchain';
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createStructuredChatAgent } from 'langchain/agents';
import { ChatPromptTemplate } from '@langchain/core/prompts';
// Initialize toolkit
const toolkit = new SECEdgarAgentToolkit({
userAgent: 'YourApp/1.0 ([email protected])', // Required by SEC EDGAR
configuration: {
actions: {
companies: { lookupCIK: true, getInfo: true, getFacts: true },
filings: { search: true, getContent: true, analyze8K: true },
financial: { getStatements: true, parseXBRL: true },
insiderTrading: { analyzeTransactions: true }
}
}
});
// Create agent
const llm = new ChatOpenAI({ modelName: 'gpt-4' });
const tools = toolkit.getTools();
const prompt = ChatPromptTemplate.fromMessages([
['system', 'You are a financial analyst with access to SEC EDGAR data.'],
['human', '{input}'],
['assistant', '{agent_scratchpad}']
]);
const agent = await createStructuredChatAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });
// Use the agent
const result = await executor.invoke({
input: "What is Apple's latest revenue and how does it compare to last year?"
});
console.log(result.output);Available Tools
sec_edgar_cik_lookup: Look up company CIKsec_edgar_company_info: Get company informationsec_edgar_company_facts: Get XBRL company factssec_edgar_filing_search: Search for filingssec_edgar_filing_content: Extract filing contentsec_edgar_analyze_8k: Analyze 8-K reportssec_edgar_financial_statements: Get financial statementssec_edgar_xbrl_parse: Parse XBRL datasec_edgar_insider_trading: Analyze insider trading
Configuration
Control which tools are available:
const toolkit = new SECEdgarAgentToolkit({
userAgent: 'YourApp/1.0 ([email protected])',
configuration: {
actions: {
companies: {
lookupCIK: true,
getInfo: false, // Disable company info tool
getFacts: true
},
// Disable all financial tools
financial: false
}
}
});