Skip to main content

A configurable, typed AI framework with swappable LLM, classifier, handlers, and optional memory

Project description

StruktX Logo
StruktX

A configurable, typed AI framework with swappable LLM, classifier, handlers, and memory for Natural Language to Action apps

Python 3.8+ License: MIT

Quick Install

Using uv (Recommended)

# Install with core dependencies only
uv pip install struktx-ai

# Install with LLM support (LangChain)
uv pip install struktx-ai[llm]

# Install with vector store support
uv pip install struktx-ai[vector]

# Install with all optional dependencies
uv pip install struktx-ai[all]

# Install for development
uv pip install struktx-ai[dev]

Using pip

# Install with core dependencies only
pip install struktx-ai

# Install with LLM support (LangChain)
pip install struktx-ai[llm]

# Install with vector store support
pip install struktx-ai[vector]

# Install with all optional dependencies
pip install struktx-ai[all]

Source

# Create virtual env
uv venv

# Activate environment
source .venv/bin/activate

# Sync and install pyproject dependencies
uv sync

# Install finall Strukt package
uv pip install struktx-ai[all]

Quick Start with LangChain

from strukt import create, StruktConfig, HandlersConfig, LLMClientConfig, ClassifierConfig
from strukt.classifiers.llm_classifier import DefaultLLMClassifier
from strukt.prompts import DEFAULT_CLASSIFIER_TEMPLATE
from strukt.examples.time_handler import TimeHandler

from langchain_openai import ChatOpenAI
from strukt.langchain_helpers import LangChainLLMClient

# Create LangChain LLM client
langchain_llm = ChatOpenAI(api_key="your-openai-api-key")
llm = LangChainLLMClient(langchain_llm)

app = create(StruktConfig(
    llm=LLMClientConfig(llm),
    classifier=ClassifierConfig(
        factory=DefaultLLMClassifier(
            llm=llm,
            prompt_template=DEFAULT_CLASSIFIER_TEMPLATE,
            allowed_types=["time_service", "weather", "general"],
            max_parts=4,
        )
    ),
    handlers=HandlersConfig(
        registry={"time_service": TimeHandler(llm)},
        default_route="general",
    ),
))

app.invoke("What is the time in Tokyo?")

What is StruktX?

StruktX is a Python framework for building AI applications with focus on natural language -> actions

  • 🔄 Swappable Components: LLM clients, classifiers, handlers, and memory engines
  • 📝 Type Safety: Full type hints and Pydantic models
  • ⚙️ Configurable: Factory-based configuration system
  • 🔌 Extensible: Easy to add custom components
  • 🧠 Memory Support: Optional conversation memory
  • 🔧 Middleware: Pre/post processing hooks

Features

  • LLM Integration: Support for any LLM via the LLMClient interface
  • Query Classification: Route requests to appropriate handlers
  • Structured Outputs: Pydantic model integration
  • Memory Engines: Conversation history and context
  • Middleware System: Pre/post processing hooks
  • LangChain Helpers: Easy integration with LangChain ecosystem

Requirements

  • Python 3.10+
  • Core: pydantic>=2.0.0, python-dotenv>=1.0.0
  • Optional: LangChain packages, vector stores, etc.

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please report any issues, bugs, improvements, or features on GitHub.

Support

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

struktx_ai-0.0.3b2.tar.gz (67.9 kB view details)

Uploaded Source

Built Distribution

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

struktx_ai-0.0.3b2-py3-none-any.whl (87.8 kB view details)

Uploaded Python 3

File details

Details for the file struktx_ai-0.0.3b2.tar.gz.

File metadata

  • Download URL: struktx_ai-0.0.3b2.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for struktx_ai-0.0.3b2.tar.gz
Algorithm Hash digest
SHA256 655f2d8a79fb0cb6b9e7386670baa95f898f63d63a04c7793997d468c6dd1bf0
MD5 0235ff9f6b98e76dc88d3c126fa4bc5e
BLAKE2b-256 af2b834b9964b6d8b5d08ae763d410da3a97675631c5ee1297516e94b064220c

See more details on using hashes here.

File details

Details for the file struktx_ai-0.0.3b2-py3-none-any.whl.

File metadata

  • Download URL: struktx_ai-0.0.3b2-py3-none-any.whl
  • Upload date:
  • Size: 87.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for struktx_ai-0.0.3b2-py3-none-any.whl
Algorithm Hash digest
SHA256 1117cebf2959fc32706d3a3f64f0713bacd27de2f73b3705a51309b19dc1f7e4
MD5 fde0defba45bf2f427b282f273ce8e7c
BLAKE2b-256 654637feac5acb1c9ac1891526721e8aae56091676c63bfed95c9f073f2f0095

See more details on using hashes here.

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