Download tests/test_quality.py from InvestmentResearchAI/LLM-ADE-dev: direct link, hf CLI and curl.
- Browser
- Download file 892 Bytes
-
https://huggingface.co/spaces/InvestmentResearchAI/LLM-ADE-dev/resolve/80098abb952ceb2e8494b94e2edd0ab0214535e7/tests/test_quality.py
- Command line
-
hf download hf://spaces/InvestmentResearchAI/LLM-ADE-dev@80098abb952ceb2e8494b94e2edd0ab0214535e7/tests/test_quality.py
-
curl -L -o test_quality.py https://huggingface.co/spaces/InvestmentResearchAI/LLM-ADE-dev/resolve/80098abb952ceb2e8494b94e2edd0ab0214535e7/tests/test_quality.py
892 Bytes
| import sys | |
| import json | |
| from io import StringIO | |
| from app import get_response | |
| def test_quality(): | |
| """Tests if the expected functions and values are used""" | |
| with open("tests/qa_questions.json") as f: | |
| qs = json.load(f) | |
| for q in qs: | |
| # Capture stdout | |
| stdout = StringIO() | |
| sys.stdout = stdout | |
| get_response(q["question"]) | |
| for include in q["expecteds"]["includes"]: | |
| assert include in stdout.getvalue(), f"Expected {include} in output" | |
| for exclude in q["expecteds"]["excludes"]: | |
| assert exclude not in stdout.getvalue(), f"Expected {exclude} not in output" | |
| for function in q["expecteds"]["functions"]: | |
| assert f"Invoking function call {function}" in stdout.getvalue(), f"{function} was not invoked" | |
| # Restore stdout | |
| sys.stdout = sys.__stdout__ | |