|
| 1 | +from humanloop.client import Humanloop |
| 2 | +from tests.integration.conftest import TestIdentifiers |
| 3 | + |
| 4 | + |
| 5 | +def test_prompts_call( |
| 6 | + humanloop_test_client: Humanloop, |
| 7 | + prompt: TestIdentifiers, |
| 8 | + test_prompt_config: TestIdentifiers, |
| 9 | +) -> None: |
| 10 | + response = humanloop_test_client.prompts.call( |
| 11 | + path=prompt.file_path, |
| 12 | + prompt={**test_prompt_config}, |
| 13 | + inputs={"question": "What is the capital of the France?"}, |
| 14 | + ) |
| 15 | + assert response is not None |
| 16 | + assert response.log_id is not None |
| 17 | + assert response.logs is not None |
| 18 | + for log in response.logs: |
| 19 | + assert log is not None |
| 20 | + assert log.output or log.error or log.output_message is not None |
| 21 | + assert "Paris" in log.output |
| 22 | + assert response.prompt.path == prompt.file_path |
| 23 | + |
| 24 | + |
| 25 | +def test_prompts_call_stream( |
| 26 | + humanloop_test_client: Humanloop, |
| 27 | + prompt: TestIdentifiers, |
| 28 | + test_prompt_config: TestIdentifiers, |
| 29 | +) -> None: |
| 30 | + response = humanloop_test_client.prompts.call_stream( |
| 31 | + path=prompt.file_path, |
| 32 | + prompt={**test_prompt_config}, |
| 33 | + inputs={"question": "What is the capital of the France?"}, |
| 34 | + ) |
| 35 | + |
| 36 | + output = "" |
| 37 | + for chunk in response: |
| 38 | + assert chunk is not None |
| 39 | + assert chunk.output or chunk.error or chunk.output_message is not None |
| 40 | + assert chunk.id is not None |
| 41 | + assert chunk.prompt_id is not None |
| 42 | + assert chunk.version_id is not None |
| 43 | + output += chunk.output |
| 44 | + |
| 45 | + assert "Paris" in output |
0 commit comments