-
Notifications
You must be signed in to change notification settings - Fork 23
Eng 217 local path #220
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
Eng 217 local path #220
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8b3814f
Content inputs to be processed according to the query.
thiago-aixplain f1b339b
Add data and query parameters on running agent
thiago-aixplain 12753d0
Enable processing keys/values in content as well
thiago-aixplain f89fd35
Merge branch 'development' into ENG-217-localPath
thiago-aixplain 4c1238d
Agent units tests and tags simolar Jinja2
thiago-aixplain 44eacbb
Merge branch 'ENG-217-localPath' of https://github.com/aixplain/aiXpl…
thiago-aixplain 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
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
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,63 @@ | ||
| import pytest | ||
| import requests_mock | ||
| from aixplain.modules import Agent | ||
| from aixplain.utils import config | ||
|
|
||
|
|
||
| def test_fail_no_data_query(): | ||
| agent = Agent("123", "Test Agent") | ||
| with pytest.raises(Exception) as exc_info: | ||
| agent.run_async() | ||
| assert str(exc_info.value) == "Either 'data' or 'query' must be provided." | ||
|
|
||
|
|
||
| def test_fail_query_must_be_provided(): | ||
| agent = Agent("123", "Test Agent") | ||
| with pytest.raises(Exception) as exc_info: | ||
| agent.run_async(data={}) | ||
| assert str(exc_info.value) == "When providing a dictionary, 'query' must be provided." | ||
|
|
||
|
|
||
| def test_fail_query_as_text_when_content_not_empty(): | ||
| agent = Agent("123", "Test Agent") | ||
| with pytest.raises(Exception) as exc_info: | ||
| agent.run_async( | ||
| data={"query": "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav"}, | ||
| content=["https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav"], | ||
| ) | ||
| assert str(exc_info.value) == "When providing 'content', query must be text." | ||
|
|
||
|
|
||
| def test_fail_content_exceed_maximum(): | ||
| agent = Agent("123", "Test Agent") | ||
| with pytest.raises(Exception) as exc_info: | ||
| agent.run_async( | ||
| data={"query": "Transcribe the audios:"}, | ||
| content=[ | ||
| "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav", | ||
| "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav", | ||
| "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav", | ||
| "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/CPAC1x2.wav", | ||
| ], | ||
| ) | ||
| assert str(exc_info.value) == "The maximum number of content inputs is 3." | ||
|
|
||
|
|
||
| def test_fail_key_not_found(): | ||
| agent = Agent("123", "Test Agent") | ||
| with pytest.raises(Exception) as exc_info: | ||
| agent.run_async(data={"query": "Translate the text: {{input1}}"}, content={"input2": "Hello, how are you?"}) | ||
| assert str(exc_info.value) == "Key 'input2' not found in query." | ||
|
|
||
|
|
||
| def test_sucess_query_content(): | ||
| agent = Agent("123", "Test Agent") | ||
| with requests_mock.Mocker() as mock: | ||
| url = agent.url | ||
| headers = {"x-api-key": config.TEAM_API_KEY, "Content-Type": "application/json"} | ||
| ref_response = {"data": "Hello, how are you?", "status": "IN_PROGRESS"} | ||
| mock.post(url, headers=headers, json=ref_response) | ||
|
|
||
| response = agent.run_async(data={"query": "Translate the text: {{input1}}"}, content={"input1": "Hello, how are you?"}) | ||
| assert response["status"] == ref_response["status"] | ||
| assert response["url"] == ref_response["data"] |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tim-nelson, we need to set this max number of content in the documentation.