Refactor agent handling in Pipeline; add tests for report generation and team agent responses
This commit is contained in:
31
tests/agents/test_report.py
Normal file
31
tests/agents/test_report.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
from app.agents.prompts import REPORT_GENERATION_INSTRUCTIONS
|
||||
from app.configs import AppConfig
|
||||
|
||||
|
||||
class TestReportGenerationAgent:
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup(self):
|
||||
self.configs = AppConfig.load()
|
||||
self.model = self.configs.get_model_by_name("qwen3:1.7b")
|
||||
self.agent = self.model.get_agent(REPORT_GENERATION_INSTRUCTIONS)
|
||||
|
||||
def test_report_generation(self):
|
||||
sample_data = """
|
||||
The analysis reported from the Market Agent have highlighted the following key metrics for the cryptocurrency market:
|
||||
Bitcoin (BTC) has shown strong performance over the last 24 hours with a price of $30,000 and a Market Cap of $600 Billion
|
||||
Ethereum (ETH) is currently priced at $2,000 with a Market Cap of $250 Billion and a 24h Volume of $20 Billion.
|
||||
The overall market sentiment is bullish with a 5% increase in total market capitalization.
|
||||
No significant regulatory news has been reported and the social media sentiment remains unknown.
|
||||
"""
|
||||
|
||||
response = self.agent.run(sample_data) #type: ignore
|
||||
assert response is not None
|
||||
assert response.content is not None
|
||||
content = response.content
|
||||
assert isinstance(content, str)
|
||||
print(content)
|
||||
assert "Bitcoin" in content
|
||||
assert "Ethereum" in content
|
||||
assert "Summary" in content
|
||||
|
||||
38
tests/agents/test_team.py
Normal file
38
tests/agents/test_team.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import asyncio
|
||||
import pytest
|
||||
from app.agents.core import PipelineInputs
|
||||
from app.agents.prompts import *
|
||||
from app.configs import AppConfig
|
||||
|
||||
|
||||
# fix warning about no event loop
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def event_loop():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
yield loop
|
||||
loop.close()
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
class TestTeamAgent:
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup(self):
|
||||
self.configs = AppConfig.load()
|
||||
self.configs.agents.team_model = "qwen3:1.7b"
|
||||
self.configs.agents.team_leader_model = "qwen3:1.7b"
|
||||
self.inputs = PipelineInputs(self.configs)
|
||||
self.team = self.inputs.get_agent_team()
|
||||
|
||||
def test_team_agent_response(self):
|
||||
self.inputs.user_query = "Is Bitcoin a good investment now?"
|
||||
inputs = self.inputs.get_query_inputs()
|
||||
response = self.team.run(inputs) # type: ignore
|
||||
|
||||
assert response is not None
|
||||
assert response.content is not None
|
||||
content = response.content
|
||||
print(content)
|
||||
assert isinstance(content, str)
|
||||
assert "Bitcoin" in content
|
||||
assert False
|
||||
Reference in New Issue
Block a user