{"id":34028674,"url":"https://github.com/codingjoe/pytest-llm","last_synced_at":"2026-04-01T22:09:06.585Z","repository":{"id":317371960,"uuid":"1067125971","full_name":"codingjoe/pytest-llm","owner":"codingjoe","description":"Fast AI reliablity test suite","archived":false,"fork":false,"pushed_at":"2026-03-23T17:40:20.000Z","size":23,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-24T15:46:57.136Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codingjoe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"codingjoe","buy_me_a_coffee":"codingjoe","custom":"https://www.paypal.me/codingjoe"}},"created_at":"2025-09-30T12:16:57.000Z","updated_at":"2026-01-13T10:33:23.000Z","dependencies_parsed_at":"2025-09-30T14:33:16.101Z","dependency_job_id":"b9f06758-12f0-4881-83de-1abed9f5f264","html_url":"https://github.com/codingjoe/pytest-llm","commit_stats":null,"previous_names":["codingjoe/pytest-llm"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/codingjoe/pytest-llm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingjoe%2Fpytest-llm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingjoe%2Fpytest-llm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingjoe%2Fpytest-llm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingjoe%2Fpytest-llm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingjoe","download_url":"https://codeload.github.com/codingjoe/pytest-llm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingjoe%2Fpytest-llm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31018568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T03:51:26.850Z","status":"ssl_error","status_checked_at":"2026-03-27T03:51:09.693Z","response_time":164,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-13T17:15:35.137Z","updated_at":"2026-03-27T04:23:46.917Z","avatar_url":"https://github.com/codingjoe.png","language":"Python","funding_links":["https://github.com/sponsors/codingjoe","https://buymeacoffee.com/codingjoe","https://www.paypal.me/codingjoe"],"categories":[],"sub_categories":[],"readme":"# pytest-llm\n\nFast AI reliability test suite\n\nA pytest plugin that provides a custom marker for testing LLM (Large Language Model) outputs with configurable success rate thresholds.\n\n## Usage\n\n```python\nimport pytest\n\n@pytest.mark.llm(\"How many R's are in the Word 'Strawberry'?\", 0.9)\ndef test_counting(prompt, llm):\n    result = llm(prompt).lower()\n    assert (\"3\" in result) or (\"three\" in result)\n```\n\n## Setup\n\n```bash\npython3 -m pip install -e pytest-llm\n```\n\n```python\n# conftest.py\nimport os\nimport typing\n\nimport httpx\nimport ollama\nimport pytest\n\n\ndef github_models_complete(prompt, model=None, system=None) -\u003e str:\n    messages = [{\"role\": \"system\", \"content\": system}] if system else []\n    messages += [{\"role\": \"user\", \"content\": prompt}]\n    if GITHUB_TOKEN := os.getenv(\"GITHUB_TOKEN\"):\n        response = httpx.post(\n            \"https://models.github.ai/inference/chat/completions\",\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Accept\": \"application/vnd.github+json\",\n                \"Authorization\": f\"Bearer {GITHUB_TOKEN}\",\n                \"X-GitHub-Api-Version\": \"2022-11-28\",\n            },\n            json={\n                \"model\": model or \"openai/gpt-5-nano\",\n                \"messages\": messages,\n            },\n        )\n        response.raise_for_status()\n        return response.json()[\"choices\"][0][\"message\"][\"content\"]\n    else:\n        return ollama.generate(model=\"llama3.2\", prompt=prompt).response\n\n\n@pytest.fixture\ndef llm() -\u003e typing.Callable[[str], str]:\n    # This fixture isn't needed but might be convenient\n    return github_models_complete\n\n\ndef pytest_llm_complete(config):\n    # This pytest hook will provide enable the plugin to generate random prompts\n    return github_models_complete\n```\n\n## Running Tests\n\n```bash\npytest -m llm\n# or to run non-llm tests\npytest -m \"not llm\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingjoe%2Fpytest-llm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingjoe%2Fpytest-llm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingjoe%2Fpytest-llm/lists"}