firts agent concept
This commit is contained in:
16
tests/conftest.py
Normal file
16
tests/conftest.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import pytest
|
||||
from src.naliiabot.bot.agent.agent import Agent
|
||||
from src.naliiabot.bot.factories.llm_factory import LLMFactory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def anthropic_model():
|
||||
llmFactory = LLMFactory("anthropic")
|
||||
anthropic_model = llmFactory.get_model()
|
||||
|
||||
return anthropic_model
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def agent(anthropic_model):
|
||||
return Agent(model=anthropic_model)
|
||||
9
tests/test_agent.py
Normal file
9
tests/test_agent.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# import pytest
|
||||
from langchain.messages import HumanMessage
|
||||
|
||||
|
||||
def test_invoke_agent(agent):
|
||||
messages = [HumanMessage(content="divide 3 and 4.")]
|
||||
messages = agent.invoke({"messages": messages})
|
||||
|
||||
assert messages is not None
|
||||
23
tests/test_factories.py
Normal file
23
tests/test_factories.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
from src.naliiabot.bot.factories.llm_factory import LLMFactory
|
||||
from src.naliiabot.bot.exceptions import NotFoundProviderError
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_deepseek import ChatDeepSeek
|
||||
|
||||
|
||||
def test_llm_factory():
|
||||
|
||||
antrophicModel = LLMFactory("anthropic").get_model()
|
||||
assert isinstance(antrophicModel, ChatAnthropic) is True
|
||||
|
||||
deepseekModel = LLMFactory("deepseek").get_model()
|
||||
assert isinstance(deepseekModel, ChatDeepSeek)
|
||||
|
||||
|
||||
def test_get_model_raises_exception_when_provider_not_found():
|
||||
factory = LLMFactory(provider="openai")
|
||||
|
||||
with pytest.raises(NotFoundProviderError) as exc_info:
|
||||
factory.get_model()
|
||||
|
||||
assert str(exc_info.value) == "OPENAI Not Provider Found"
|
||||
Reference in New Issue
Block a user