mirror of
https://github.com/vee1e/InstaFuel_Chatbot_public.git
synced 2026-09-03 03:37:36 +00:00
43 lines
No EOL
1.3 KiB
Python
43 lines
No EOL
1.3 KiB
Python
import pytest
|
||
|
||
from src.agents.base_agent import SharedMemory
|
||
from agents.retrieval_agent import KnowledgeRetrievalAgent
|
||
from src.models.schemas import (
|
||
AgentType,
|
||
ConversationContext,
|
||
ConversationState,
|
||
Message,
|
||
MessageType,
|
||
Platform,
|
||
)
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_knowledge_agent_offline_summary():
|
||
shared_memory = SharedMemory()
|
||
agent = KnowledgeRetrievalAgent(shared_memory=shared_memory, enable_cloud=False)
|
||
await shared_memory.register_agent(agent)
|
||
|
||
context = ConversationContext(
|
||
conversation_id="conv_knowledge_1",
|
||
user_id="user123",
|
||
platform=Platform.WEBSITE,
|
||
state=ConversationState.ACTIVE,
|
||
)
|
||
|
||
message = Message(
|
||
id="msg1",
|
||
conversation_id=context.conversation_id,
|
||
sender_id=context.user_id,
|
||
sender_type=AgentType.ORCHESTRATOR,
|
||
message_type=MessageType.USER_MESSAGE,
|
||
content="What are the benefits of whey protein?",
|
||
platform=Platform.WEBSITE,
|
||
)
|
||
|
||
response = await agent.process_message(message, context)
|
||
|
||
assert response.agent_type == AgentType.KNOWLEDGE_RETRIEVAL
|
||
assert response.response_text.startswith("Here’s what I can share right now:")
|
||
assert response.metadata.get("citations")
|
||
assert context.context_data["last_knowledge_query"] == message.content |