Skip to main content

llmfy llmfy llmfy python

LLMfy is a flexible and developer-friendly framework designed to streamline the creation of applications powered by large language models (LLMs). It provides essential tools and abstractions that simplify the integration, orchestration, and management of LLMs across various use cases, enabling developers to focus on building intelligent, context-aware solutions without getting bogged down in low-level model handling. With support for modular components, prompt engineering, and extensibility, LLMfy accelerates the development of AI-driven applications from prototyping to production.

See complete documentation at https://llmfy.readthedocs.io/

How to install

  • Optional Library:
    • Install anthropic to use Anthropic Claude models (native Messages API) — 🔸 optional.
    • Install openai to use OpenAI models — 🔸 optional.
    • Install boto3 to use AWS Bedrock models — 🔸 optional.
    • Install google-genai to use Google AI (Gemini) models — 🔸 optional.
    • Install numpy to use Embedding, FAISSVectorStore — 🔸 optional.
    • Install faiss-cpu to use FAISSVectorStore — 🔸 optional.
    • Install typing_extensions to use state in FlowEngine — 🔸 optional.
    • Install redis to use RedisCheckpointer — 🔸 optional.
    • Install SQLAlchemy to use SQLCheckpointer — 🔸 optional. SQLCheckpointer supports both sync and async drivers for multiple databases:
    • Install spacy to use PERSON_NAME/ADDRESS detection in PIIGuard — 🔸 optional. Also requires the xx_ent_pii_sm NER model (not on PyPI — see PII Guard below).

Using UV

uv add llmfy

Using pip

pip install llmfy

Using github

From a specific branch

# main
uv add git+https://github.com/irufano/llmfy.git@main
# or
pip install git+https://github.com/irufano/llmfy.git@main

# dev
uv add git+https://github.com/irufano/llmfy.git@dev
# or
pip install git+https://github.com/irufano/llmfy.git@dev

From a tag

# example tag version 0.4.3
uv add git+https://github.com/irufano/llmfy.git@v0.4.3
# or
pip install git+https://github.com/irufano/llmfy.git@v0.4.3

Github in requirements.txt

git+https://github.com/irufano/llmfy.git@dev

How to use

Model class names follow <Vendor><APIVariant>Model — e.g. OpenAIChatModel vs OpenAIResponsesModel for OpenAI's two APIs, GoogleAIGenerateModel for Google's generate_content API — so the class name always tells you which API it talks to.

Anthropic models

To use AnthropicMessagesModel (native Messages API), requires install "llmfy[anthropic]" and add below config to your env (or pass api_key= to the model instead):

  • ANTHROPIC_API_KEY

OpenAI models

To use OpenAIChatModel (Chat Completions) or OpenAIResponsesModel (Responses API), requires install "llmfy[openai]" and add below config to your env (or pass api_key= to the model instead):

  • OPENAI_API_KEY

AWS Bedrock models

To use BedrockConverseModel, requires install "llmfy[boto3]" and add below config to your env (or pass aws_access_key_id=, aws_secret_access_key=, aws_bedrock_region= to BedrockConverseModel instead):

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_BEDROCK_REGION

Google AI models

To use GoogleAIGenerateModel, requires install "llmfy[google-genai]" and add below config to your env (or pass api_key= to GoogleAIGenerateModel instead):

  • GOOGLE_API_KEY

PII Guard — PERSON_NAME / ADDRESS detection

To use PIIType.PERSON_NAME/PIIType.ADDRESS detection in PIIGuard, install:

# Using UV
uv add "llmfy[spacy]"
uv add https://github.com/irufano/spacy_ner_pii/releases/download/v0.1.0/xx_ent_pii_sm-0.1.0-py3-none-any.whl

# Using pip
pip install "llmfy[spacy]"
pip install https://github.com/irufano/spacy_ner_pii/releases/download/v0.1.0/xx_ent_pii_sm-0.1.0-py3-none-any.whl

xx_ent_pii_sm isn't published to PyPI, so it can't be pulled in as a normal extra — install it manually from the release wheel above.

All other PIITypes work with no extra install. Note that PIIGuard() defaults to detecting every PIIType, including these two (breaking change from earlier versions, where PIIGuard was regex-only) — pass exclude_types=[PIIType.PERSON_NAME, PIIType.ADDRESS] if you don't want this dependency.

Example

LLMfy Example

from llmfy import (
    OpenAIChatModel,
    OpenAIChatConfig,
    LLMfy,
    Message,
    Role,
    LLMfyException,
)

def sample_prompt():
    info = """Irufano adalah seorang software engineer.
    Dia berasal dari Indonesia.
    Kamu bisa mengunjungi websitenya di https:://irufano.github.io"""

    # Configuration
    config = OpenAIChatConfig(temperature=0.7)
    llm = OpenAIChatModel(model="gpt-4o-mini", config=config)

    SYSTEM_PROMPT = """Answer any user questions based solely on the data below:
    <data>
    {info}
    </data>
    
    DO NOT response outside context."""

    # Initialize framework
    framework = LLMfy(llm, system_message=SYSTEM_PROMPT, input_variables=["info"])

    try:
        messages = [Message(role=Role.USER, content="apa ibukota china")]
       
        response = framework.invoke(messages, info=info)
        print(f"\n>> {response.result.content}\n")

    except LLMfyException as e:
        print(f"{e}")


if __name__ == "__main__":
    sample_prompt()

Develop as Contributor

Commit message format

Commit subjects follow Conventional Commits:

<type>: <short summary>

[optional body]
  • type is one of: feat, fix, refactor, chore, ci, docs, test.
  • For a breaking change, prefix the subject with [breaking-changes], e.g. [breaking-changes] refactor: consolidate thinking config.
  • Keep the summary in the imperative mood (e.g. "add", not "added"/"adds").
  • The release workflow copies each commit's subject and body verbatim into the GitHub release changelog, so write both to be read standalone (see .github/workflows/release.yml).

Version bump rules (automatic tagging)

Every push to main is scanned by .github/workflows/auto-tag.yml, which tags a new release automatically — no manual git tag needed. The bump is decided per commit subject, in this precedence order (highest across all new commits wins):

Commit subject Bump
[breaking-changes] <type>: ... or <type>!: ... / <type>(scope)!: ... MAJOR
feat: ... (no breaking marker) MINOR
fix: ... (no breaking marker) PATCH
refactor:, chore:, ci:, docs:, test: alone no release (bundled into the next qualifying commit)

A breaking marker always forces MAJOR regardless of type — use it deliberately when a feat or fix must ship as a major version, e.g. [breaking-changes] feat: ... or feat!: ..., both equivalent.

Build package

uv build

Manual / backfill release

Tagging is automatic (see above). To manually cut or re-run a release, use the workflow_dispatch trigger on release.yml (GitHub Actions UI → "Release & Publish" → "Run workflow", tag input vX.Y.Z) instead of pushing a tag by hand.

After deploy on local

After CI creates or moves the tag, your local tag ref may be stale. To sync:

git fetch --tags --force

The --force flag is needed because git fetch --tags alone won't update tags that already exist locally.

Package Development on local

uv sync --group dev --group docs

or

uv sync --all-groups

Check Lints

uvx ruff check --statistics . 2>&1 | tail -60 

Mkdocs run on local

uv sync --group docs
# Serve on local
mkdocs serve

# Build docs
mkdocs build

Download files

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

Source Distribution

llmfy-0.10.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

llmfy-0.10.0-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file llmfy-0.10.0.tar.gz.

File metadata

  • Download URL: llmfy-0.10.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmfy-0.10.0.tar.gz
Algorithm Hash digest
SHA256 989bccedd15106c4d4271e41d77a3129c6a84e241b1856343608e6ccea2cf878
MD5 527420ba4d075c94fc6f50dbb7d84781
BLAKE2b-256 8bf9f414866456763583f2d427237252509943a63a80c2766a7bb769d5f1a06f

See more details on using hashes here.

File details

Details for the file llmfy-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: llmfy-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmfy-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7e2942fb0a6f4f2d3575df8600a8970aa03b68a8ffdc5b9a2af1bc8b1973d0f
MD5 d961a731ad12c6ae95135b26b9d70f7f
BLAKE2b-256 e887f86ba984a92fe99e0e560b444ee2d0e237500f1a138323198f2a601f31b0

See more details on using hashes here.

Release history Release notifications | RSS feed

0.10.1

2 files

This release

0.10.0 This release

2 files

0.9.3

2 files

0.9.1

2 files

0.9.0

2 files

0.6.3

2 files

0.6.1

2 files

0.6.0

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.4.21

2 files

0.4.20

2 files

0.4.19

2 files

0.4.18

2 files

0.4.17

2 files

0.4.16

2 files

0.4.15

2 files

0.4.14

2 files

0.4.13

2 files

0.4.12

2 files

0.4.11

2 files

0.4.10

2 files

0.4.9

2 files

0.4.8

2 files

0.4.7

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.3.1

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

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