Skip to main content

A Python package for TRIZ (Theory of Inventive Problem Solving) tools and techniques.

Project description

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

from pytriz import TRIZStore

store = TRIZStore()  # uses default embedding model, reads config from env

# 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 = store.search_parameters("improves durability", top_k=5)
principles = store.search_principles("segmentation", top_k=5)

TRIZStore builds the indexed corpus on instantiation — create it once and reuse it across your application. Semantic search uses a local embedding model by default, no API key needed.

LLM-powered analysis

import asyncio
from pytriz import TRIZStore
from pytriz import contradictions

store = TRIZStore()

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

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

Set your LLM provider in a .env file:

DEFAULT_PROVIDER=openrouter    # openai | anthropic | mistral | openrouter | ollama | together
DEFAULT_MODEL=qwen/qwen3.6-35b-a3b
OPENROUTER_API_KEY=your-key-here

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, ModelSettings

store = TRIZStore(
    embed_model=get_embedder(provider="ollama", model="nomic-embed-text", url="http://my-server:11434"),
)
llm = get_model(
    provider="anthropic",
    model_name="claude-sonnet-4-6",
    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.

Embedding providers

PyTRIZ supports three embedding backends, configured via EMBEDDING_PROVIDER:

HuggingFace (default)

Downloads and runs the model locally using sentence-transformers. No API key needed for public models.

EMBEDDING_PROVIDER=huggingface
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2

For gated models (e.g. google/embeddinggemma-300m), set your HuggingFace token:

HF_TOKEN=your-token-here
EMBEDDING_MODEL=google/embeddinggemma-300m

Ollama

Runs embeddings locally via a running Ollama instance.

EMBEDDING_PROVIDER=ollama
EMBEDDING_MODEL=nomic-embed-text
OLLAMA_BASE_URL=http://localhost:11434   # optional, this is the default

OpenAI

EMBEDDING_PROVIDER=openai
EMBEDDING_MODEL=text-embedding-3-small
OPENAI_API_KEY=your-key-here

LLM providers

Provider DEFAULT_PROVIDER Required env var
OpenAI openai OPENAI_API_KEY
Anthropic anthropic ANTHROPIC_API_KEY
Mistral mistral MISTRAL_API_KEY
OpenRouter openrouter OPENROUTER_API_KEY
Together together TOGETHER_API_KEY
Ollama ollama — (uses OLLAMA_BASE_URL)

Environment variables reference

Variable Default Description
DEFAULT_PROVIDER openrouter LLM provider
DEFAULT_MODEL qwen/qwen3.6-35b-a3b LLM model name
EMBEDDING_PROVIDER huggingface Embedding backend
EMBEDDING_MODEL sentence-transformers/all-MiniLM-L6-v2 Embedding model name
OLLAMA_BASE_URL http://localhost:11434 Ollama host (used for both LLM and embeddings)
OPENAI_API_KEY OpenAI API key
ANTHROPIC_API_KEY Anthropic API key
MISTRAL_API_KEY Mistral API key
OPENROUTER_API_KEY OpenRouter API key
TOGETHER_API_KEY Together AI API key
HF_TOKEN HuggingFace token (for gated models)

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

pytriz-0.2.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

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

pytriz-0.2.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file pytriz-0.2.0.tar.gz.

File metadata

  • Download URL: pytriz-0.2.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytriz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a7e9df4e127e9d3a0ba75afe9fc01e12e82a3a21d249a8b2b7267243a01085ab
MD5 9b45c40ed35abd18aeb375156fd6dec6
BLAKE2b-256 f57093f83f80252ec5e20ca43826c553fd087ce64e49abed3ac957406d2b5d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytriz-0.2.0.tar.gz:

Publisher: publish.yml on mmysior/pytriz

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

File details

Details for the file pytriz-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pytriz-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytriz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0174c4502f7aea5de609016b72f9c42c5245890000d55b70439502521c77a044
MD5 e2c08763ae937160a2580e3b2a5b648d
BLAKE2b-256 a90bbae17de55fe8ca288fe6eec22beb17350b20af40bb480207b04bbc0dfbc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytriz-0.2.0-py3-none-any.whl:

Publisher: publish.yml on mmysior/pytriz

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