-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: types * test: Added some integration tests * test: improvements * test: test_paraphrase.py * fix: doc * fix: removed unused comment * test: test_summarize.py * test: Added tests for test_summarize_by_segment.py * test: test_segmentation.py * fix: file id in library response * fix: example for library * ci: Add rc branch prefix trigger for integration tests (#43) * ci: rc branch trigger for integration test * fix: wrapped in quotes * fix: types * test: Added some integration tests * test: improvements * test: test_paraphrase.py * fix: doc * fix: removed unused comment * test: test_summarize.py * test: Added tests for test_summarize_by_segment.py * test: test_segmentation.py * fix: file id in library response * fix: example for library * docs: docstrings * fix: question * fix: CR * test: Added tests to segment type in embed
- Loading branch information
1 parent
127cef4
commit 78709a7
Showing
28 changed files
with
692 additions
and
6 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
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
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
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
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from ai21 import AI21Client | ||
from ai21.models import AnswerLength, Mode | ||
|
||
_CONTEXT = ( | ||
"Holland is a geographical region[2] and former province on the western coast of" | ||
" the Netherlands. From the " | ||
"10th to the 16th century, Holland proper was a unified political region within the Holy Roman Empire as a county " | ||
"ruled by the counts of Holland. By the 17th century, the province of Holland had risen to become a maritime and " | ||
"economic power, dominating the other provinces of the newly independent Dutch Republic." | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
ids=[ | ||
"when_answer_is_in_context", | ||
"when_answer_not_in_context", | ||
], | ||
argnames=["question", "is_answer_in_context", "expected_answer_type"], | ||
argvalues=[ | ||
("When did Holland become an economic power?", True, str), | ||
("Is the ocean blue?", False, None), | ||
], | ||
) | ||
def test_answer(question: str, is_answer_in_context: bool, expected_answer_type: type): | ||
client = AI21Client() | ||
response = client.answer.create( | ||
context=_CONTEXT, | ||
question=question, | ||
answer_length=AnswerLength.LONG, | ||
mode=Mode.FLEXIBLE, | ||
) | ||
|
||
assert response.answer_in_context == is_answer_in_context | ||
if is_answer_in_context: | ||
assert isinstance(response.answer, str) | ||
else: | ||
assert response.answer is None |
Oops, something went wrong.