Skip to main content

LLM Tests

Project description

LLM Tests

Summary

This package aims to make LLM testing easier and repeatable.

The primary intention is for testing LLM memory solutions like RAG, but the functionality can be used for other purposes as well. Including tool testing.

Test files are stored as JSON using the following template.

The following example explains most of the functionality of the template.

{
    "setups": [
        {
            "summary": "An optional summary of the prior conversations",
            "prior_conversations": [
                [{
                    "role": "user",
                    "content": "My name is User"
                },
                {
                    "role": "assistant",
                    "content": "Hi User"
                }
                ],
                [{
                    "role": "user",
                    "content": "Do you know my name"
                },
                {
                    "role": "assistant",
                    "content": "This is a new context, I can only remember across contexts with external tools"
                }]
            ]
        }
    ], 
    "tests" : [
        {
            "summary": "An optional summary for this test",
            "case_sensitive": false,
            "ignoring_thinking": true,
            "messages": [{
                    "role": "system",
                    "content": "Respond only with the word Hello"
                }],
            "expected_response": "Hello"
        },
        {
            "messages": [{
                    "role": "system",
                    "content": "Respond only with the user's name"
                }],
            "expected_response": "User"
        }
    ]
}
# Here is a simple inefficient example
import llmtests
import ollama

def chatfn(messages):
    resp = ollama.chat(model='deepseek-r1:8b', messages=messages)
    return resp["message"]

def resetMemory(context_reset, memory_reset):
    if memory_reset:
        # Reset Database. E.g. wipe everything
        pass
    if context_reset:
        pass
        # Reset context of current conversation

results = llmtests.test_all(chatfn, resetMemory)
report = llmtests.test_results_as_text_report(results)
print("Score:",report["pass_count"],"/",report["test_count"])

if report["failed_report"]:
    print("Failed tests")
    print(report["failed_report"])
else:
    print("No failed tests")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmtests-0.0.16.281.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmtests-0.0.16.281-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file llmtests-0.0.16.281.tar.gz.

File metadata

  • Download URL: llmtests-0.0.16.281.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for llmtests-0.0.16.281.tar.gz
Algorithm Hash digest
SHA256 8769b6023f1d2bbfc92b587647b9f301bdd919a087baae1fc06127b28d5b46a1
MD5 75154810ff9eed1c2f2c58ea5a08cf88
BLAKE2b-256 5ada6c4a1a48800a5f4c514cd6a386684f3efd53f37fa4f92a73cb435dd56ac6

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmtests-0.0.16.281.tar.gz:

Publisher: publish-to-pypi.yml on mr-randall/llmtests

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmtests-0.0.16.281-py3-none-any.whl.

File metadata

  • Download URL: llmtests-0.0.16.281-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for llmtests-0.0.16.281-py3-none-any.whl
Algorithm Hash digest
SHA256 8cbc6e87ba37e0b26a9589ff69d9b9f6514b897f8060009626a3ff8a24d14540
MD5 368346eb34e54d06f28c0226327a9e91
BLAKE2b-256 2a6eb1b2a3f3b25b5cae1bba3b4ce351bfc0f73322e2b00b6afe6afa3a12734e

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmtests-0.0.16.281-py3-none-any.whl:

Publisher: publish-to-pypi.yml on mr-randall/llmtests

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page