Skip to content
Merged
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
20 changes: 8 additions & 12 deletions python/valuecell/agents/sec_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from enum import Enum
from typing import AsyncGenerator, Dict, Iterator

from agno.agent import Agent, RunResponseEvent
from agno.agent import Agent, RunOutputEvent
from agno.models.openrouter import OpenRouter
from edgar import Company, set_identity
from pydantic import BaseModel, Field, field_validator
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self):
self.request_timeout = int(os.getenv("SEC_REQUEST_TIMEOUT", "30"))


class SecAgent(BaseAgent):
class SECAgent(BaseAgent):
"""
Intelligent SEC analysis agent supporting financial data queries and 13F fund holdings analysis
"""
Expand Down Expand Up @@ -301,7 +301,7 @@ async def _process_financial_data_query(self, ticker: str):
filings = company.get_filings(form=filing_type).head(3)
if len(filings) > 0:
all_filings_data[filing_type] = []
for i, filing in filings.iterrows():
for filing in filings:
filing_info = {
"date": filing.filing_date,
"accession_number": filing.accession_number,
Expand Down Expand Up @@ -358,13 +358,11 @@ async def _process_financial_data_query(self, ticker: str):
Please ensure the analysis is objective and professional, based on actual data, avoiding excessive speculation.
"""

response_stream: Iterator[
RunResponseEvent
] = await self.analysis_agent.arun(
response_stream: Iterator[RunOutputEvent] = self.analysis_agent.arun(
analysis_prompt, stream=True, stream_intermediate_steps=True
)
async for event in response_stream:
if event.event == "RunResponseContent":
if event.event == "RunContent":
yield streaming.message_chunk(event.content)
elif event.event == "ToolCallStarted":
yield streaming.tool_call_started(
Expand Down Expand Up @@ -451,13 +449,11 @@ async def _process_fund_holdings_query(self, ticker: str):
Please ensure the analysis is objective and professional, based on actual data, avoiding excessive speculation.
"""

response_stream: Iterator[
RunResponseEvent
] = await self.analysis_agent.arun(
response_stream: Iterator[RunOutputEvent] = await self.analysis_agent.arun(
analysis_prompt, stream=True, stream_intermediate_steps=True
)
async for event in response_stream:
if event.event == "RunResponseContent":
if event.event == "RunContent":
yield streaming.message_chunk(event.content)
elif event.event == "ToolCallStarted":
yield streaming.tool_call_started(
Expand Down Expand Up @@ -622,5 +618,5 @@ def get_monitoring_status(self, session_id: str) -> Dict:


if __name__ == "__main__":
agent = create_wrapped_agent(SecAgent)
agent = create_wrapped_agent(SECAgent)
asyncio.run(agent.serve())