Skip to main content

PyTRIZ

A Python library for applying TRIZ (Theory of Inventive Problem Solving) — look up parameters, principles, and contradiction matrix results, or use LLM-powered agents to analyze engineering trade-offs.

Installation

pip install pytriz

Requires Python 3.12+.

Quick start

import asyncio
from pytriz import TRIZStore

store = TRIZStore()  # lexical (BM25) search only, zero config, no API key

# Find TRIZ principles for a contradiction
principles = store.get_principles_from_matrix(
    improving_parameters=[1, 3],
    preserving_parameters=[17, 23],
)

# Search parameters and principles by description
params = asyncio.run(store.search_parameters("improves durability", top_k=5))
principles = asyncio.run(store.search_principles("segmentation", top_k=5))

# Look up a physical-contradiction separation principle and its recommended
# inventive principles
separation = store.get_separation_by_id(1)
recommended_principles = separation.principles

TRIZStore builds the BM25 lexical index on instantiation — create it once and reuse it across your application. Passing an embed_model (see below) fuses in dense semantic search on top; embeddings are computed lazily on first search and cached from then on, or you can precompute them upfront with await store.ensure_index().

Separation principles

The store includes five separation principles for physical contradictions: separation in space, time, relation (conditions), direction, and at the system level. Each Separation includes its application guidelines and direct references to the recommended Principle objects.

separation = store.get_separation_by_name("Separation in time")
print(separation.guidelines)
print([principle.name for principle in separation.principles])

results = asyncio.run(store.search_separations("different moments in time", top_k=3))

PyTRIZ doesn't bundle an embedding runtime — it accepts any pydantic-ai Embedder, so you bring whichever backend you want.

import asyncio
from pytriz import TRIZStore, get_embedder

# Any OpenAI-compatible endpoint — Ollama, LM Studio, vLLM, etc.
embedder = get_embedder("nomic-embed-text", base_url="http://localhost:11434/v1")

# Or one of pydantic-ai's built-in providers directly
# embedder = get_embedder("openai:text-embedding-3-small")

store = TRIZStore(embed_model=embedder)
results = asyncio.run(store.search_principles("segmentation", top_k=5))

For providers pydantic-ai supports natively (OpenAI, Cohere, VoyageAI, Bedrock, Google, or local sentence-transformers), construct a pydantic_ai.Embedder yourself and pass it in the same way:

from pydantic_ai import Embedder

store = TRIZStore(embed_model=Embedder("cohere:embed-v4.0"))

LLM-powered analysis

PyTRIZ doesn't read any environment variables or config of its own — every LLM call needs an explicit llm, just like embed_model.

import asyncio
from pytriz import TRIZStore, get_model
from pytriz import contradictions

store = TRIZStore()

# Bare model name + base_url -> any OpenAI-compatible endpoint (Ollama, LM Studio, vLLM, Together, etc.)
llm = get_model("llama3", base_url="http://localhost:11434/v1")

# Or one of pydantic-ai's built-in providers directly (reads the matching API key from the environment)
# llm = get_model("anthropic:claude-sonnet-4-6")

result = asyncio.run(
    contradictions.analyze_contradiction(
        "Increasing blade thickness improves durability but increases weight.",
        store=store,
        llm=llm,
    )
)

print(result.contradiction)
print(result.improving_parameter)
print(result.preserving_parameter)

For providers pydantic-ai supports natively but get_model doesn't wrap (Cohere, Bedrock, Google, etc.), construct a pydantic_ai.models.Model yourself and pass it in the same way.

Explicit configuration

For full control — useful when building FastAPI apps, MCP servers, or any long-running service:

from pytriz import TRIZStore, get_embedder, get_model
from pydantic_ai.models.anthropic import AnthropicModel
from pydantic_ai.providers.anthropic import AnthropicProvider
from pydantic_ai.settings import ModelSettings

store = TRIZStore(
    embed_model=get_embedder("nomic-embed-text", base_url="http://my-server:11434/v1"),
)
await store.ensure_index()  # precompute embeddings at startup instead of on the first search

llm = AnthropicModel(
    "claude-sonnet-4-6",
    provider=AnthropicProvider(api_key="your-key-here"),
    settings=ModelSettings(temperature=0.2),
)

result = await contradictions.analyze_contradiction(
    "Increasing blade thickness improves durability but increases weight.",
    store=store,
    llm=llm,
)

store and llm are independent — configure each separately and pass them where needed.

Metadata

Release files for pytriz 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytriz 0.4.0
File Size Uploaded Provenance
pytriz-0.4.0.tar.gz 27.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytriz 0.4.0
File Interpreter ABI Platform
pytriz-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 60.7 kB

Release files / pytriz-0.4.0.tar.gz

Download URL pytriz-0.4.0.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
be7df12a612b026a449ad1ad9ae111f301dda08c9e63b5f2bc34ec27d1adc3e2
BLAKE2b-256 checksum
How to use checksums
71d0e291ce5d2b5ae695a2d9e4630d8d3a4524f435948ea5cab6f020e2b1e40e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / pytriz-0.4.0-py3-none-any.whl

Download URL pytriz-0.4.0-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ff8f797773fcc722d55406808bef5b2cc6d085e09ddc05b6c34c471e95fc746
BLAKE2b-256 checksum
How to use checksums
258cfe67b7c7391647f02572a750cda80217374c6e550f8acae3fd08d5dc241d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Security for pytriz 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytriz-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page