forked from ScottLogic/InferLLM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
688533e
commit 195f990
Showing
7 changed files
with
18 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,20 @@ | ||
import pytest | ||
from unittest.mock import patch, AsyncMock | ||
import json | ||
from src.agents.generalist_agent import GeneralistAgent | ||
|
||
from src.llm.factory import get_llm | ||
from src.agents.generalist_agent import GeneralistAgent | ||
|
||
@pytest.mark.asyncio | ||
@patch("src.agents.generalist_agent.answer_user_question", new_callable=AsyncMock) | ||
async def test_generalist_agent( | ||
mock_answer_user_question, | ||
): | ||
mock_answer_user_question.return_value = json.dumps( | ||
{"status": "success", "response": json.dumps({"is_valid": True, "answer": "Example summary."})} | ||
) | ||
generalist_agent = GeneralistAgent("llm", "mock_model") | ||
|
||
result = await generalist_agent.invoke("example query") | ||
expected_response = {"content": "Example summary.", "ignore_validation": "false"} | ||
assert json.loads(result) == expected_response | ||
mock_model = "mockmodel" | ||
mock_llm = get_llm("mockllm") | ||
|
||
|
||
@pytest.mark.asyncio | ||
@patch("src.agents.generalist_agent.answer_user_question", new_callable=AsyncMock) | ||
async def test_generalist_agent_reponse_format_error( | ||
mock_answer_user_question, | ||
): | ||
mock_answer_user_question.return_value = json.dumps( | ||
{"status": "success", "response": json.dumps({"is_valid": True, "answer_wrong_format": "Example summary."})} | ||
) | ||
generalist_agent = GeneralistAgent("llm", "mock_model") | ||
async def test_generalist_agent(mocker): | ||
mock_llm.chat = mocker.AsyncMock(return_value="Example summary.") | ||
|
||
result = await generalist_agent.invoke("example query") | ||
agent = GeneralistAgent(llm_name="mockllm", model=mock_model) | ||
|
||
expected_response = {"content": "Error in answer format.", "ignore_validation": "false"} | ||
result = await agent.invoke("example query") | ||
expected_response = {"content": "Example summary.", "ignore_validation": "false"} | ||
assert json.loads(result) == expected_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters