-
Notifications
You must be signed in to change notification settings - Fork 994
test: answer generation [COG-1234] #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ef83afc
Parse context pieces separately in MusiqueQAAdapter and adjust tests
alekszievr aa62be6
Add evals extras to pytests
alekszievr 0bfeba3
Remove LiteralString typehints
alekszievr f7a2000
Merge branch 'dev' into test/cog-1234-test-eval-framework
alekszievr c54b6cb
Corpus builder test
alekszievr 6cabc79
add secrets to unit test workflow files
alekszievr f119f47
add secrets to unit test workflow files
alekszievr 397a287
add secrets to unit test workflow files
alekszievr 747c62a
add secrets to unit test workflow files
alekszievr 8e3a9b9
add secrets to unit test workflow files
alekszievr 63e132c
Test AnswerGeneratorExecutor
alekszievr 24fb35d
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr f409bf2
Test answering engines except for code
alekszievr 0edd4ec
Merge branch 'dev' into test/cog-1234-test-corpus-builder
alekszievr 29f69f3
mock cognee in corpus builder tests
alekszievr 5b4da74
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr 6a0b7f5
Merge branch 'test/cog-1234-test-corpus-builder' into test/cog-1234-t…
alekszievr 7baa8c5
Mock cognee in answer generation test
alekszievr 918d9ad
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr 3cebe36
remove unused variable
alekszievr 43241c2
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr 2d5fc45
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr f5028c6
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr af3a24b
Test if AnswerGeneratorExecutor calls answer_resolver and passes gene…
alekszievr 172bf52
Merge branch 'dev' into test/cog-1234-test-answer-generation
alekszievr b2d079f
Remove redundant test
alekszievr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
cognee/tests/unit/eval_framework/answer_generation_test.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import pytest | ||
| from evals.eval_framework.answer_generation.answer_generation_executor import ( | ||
| AnswerGeneratorExecutor, | ||
| ) | ||
| from evals.eval_framework.benchmark_adapters.dummy_adapter import DummyAdapter | ||
| from unittest.mock import AsyncMock | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_answer_generation(): | ||
| limit = 1 | ||
| corpus_list, qa_pairs = DummyAdapter().load_corpus(limit=limit) | ||
|
|
||
| mock_answer_resolver = AsyncMock() | ||
| mock_answer_resolver.side_effect = lambda query: ["mock_answer"] | ||
|
|
||
| answer_generator = AnswerGeneratorExecutor() | ||
| answers = await answer_generator.question_answering_non_parallel( | ||
| questions=qa_pairs, | ||
| answer_resolver=mock_answer_resolver, | ||
| ) | ||
|
|
||
| mock_answer_resolver.assert_called_once_with(qa_pairs[0]["question"]) | ||
|
|
||
| assert len(answers) == len(qa_pairs) | ||
| assert answers[0]["question"] == qa_pairs[0]["question"], ( | ||
| "AnswerGeneratorExecutor is passing the question incorrectly" | ||
borisarzentar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| assert answers[0]["golden_answer"] == qa_pairs[0]["answer"], ( | ||
| "AnswerGeneratorExecutor is passing the golden answer incorrectly" | ||
| ) | ||
| assert answers[0]["answer"] == "mock_answer", ( | ||
| "AnswerGeneratorExecutor is passing the generated answer incorrectly" | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.