Skip to main content

Ellements logo

Ellements

A Python toolkit for extreme experimentation with LLM systems.

Ellements is best understood as a continuously extended set of building blocks for LLM experimentation: model clients, prompt context, execution strategies, agent abstractions, benchmarking harnesses, and terminal UI primitives. The repository is organized into focused source roots, but ships as a single PyPI package, ellements, containing every public ellements.* subpackage.

[!WARNING] Do not treat this as a normal dependency. This repository exists to support my own projects, experiments, and tooling. Probably nobody other than me should depend on it directly.

[!NOTE] Almost all of it is created with AI assistance, and I myself understand only a fraction of it at any given time. This can produce fast-paced changes, as well as both good and bad surprises. Pull requests are unlikely to be accepted. This is published for transparency and my own reuse, not as a community-maintained library or a general-purpose package roadmap.

Why yet another LLM library?

True, there are many other similar libraries. This one, however, is mine. It exists so I can keep extending it, test ideas, change direction, delete abstractions, and rebuild APIs as I see fit: not by committee, not by roadmap, not by community consensus.

Design principles

The practical consequences are the following:

  • One install, focused internals. pip install ellements installs the full namespace: ellements.core, ellements.execution, ellements.agents, ellements.benchmarking, ellements.cli, ellements.domain_specific, ellements.reporting, ellements.standard_tools, and ellements.fslm.
  • Extension before stabilization. The point is to keep adding mechanisms as they become useful in my projects. Stability comes later, if it comes at all.
  • Async-only public API. No hidden sync wrappers. Callers keep explicit control of concurrency.
  • Explicit model selection. LLMClient(model=...) is required. There is no hidden default.
  • Explicit local caching. Pass LocalCacheConfig(directory=...) to cache exact text/Responses calls through LiteLLM and image generation/edit responses through Ellements' content-addressed disk cache. URL-only image responses are not persisted because provider URLs expire. Caching is off when omitted.
  • Structured observability. Every LLM call emits request, response, and error events. JsonlPromptLogger writes durable JSON-lines traces.
  • Composable strategy layer. Single-call, reflection, self-consistency, tree-of-thought, and collaborative editing all conform to one Strategy protocol.
  • Backend-agnostic agents. ellements.agents is an abstraction layer over external agent libraries. OpenAI Agents and Claude Agents are adapters; they are not the identity of the module.
  • Finite-state linguistic machines. ellements.fslm keeps agentic workflows bounded by explicit state graphs while still allowing natural-language guards, invariants, actions, and outputs where they are useful. The L is deliberate: language is part of the control surface, not a decorative interface.

Install

pip install ellements

Optional extras install integration-specific dependencies. They do not split the package or change which modules ship in the wheel.

pip install "ellements[agents]"        # declared agent-adapter dependencies
pip install "ellements[benchmarking]"  # lm-eval integration
pip install "ellements[cli]"           # Textual-powered terminal UI helpers
pip install "ellements[fslm]>=0.2.0"   # finite-state linguistic machines
pip install "ellements[finance]"       # Yahoo Finance asset tools
pip install "ellements[web]"           # web search, crawl, and YouTube tools
pip install "ellements[reporting]"     # chart/report export helpers
pip install "ellements[all]"           # all declared optional integrations

In particular, the agents module is not OpenAI-specific. It defines shared builder, controller, runner, and event abstractions over external agent libraries. The OpenAI adapter has declared optional dependencies; the Claude adapter is included in the wheel, but its upstream SDK is still evolving, so install it separately when using that backend.

What ships

Import package Purpose
ellements.core LLMClient, conversations, multimodal inputs, tools, prompt context, templating, observers, caching, rate limiting, budgeting, and config helpers
ellements.execution Prompting strategies: SingleCallStrategy, ReflectionStrategy, SelfConsistencyStrategy, TreeOfThoughtStrategy, CollaborativeEditingStrategy
ellements.agents Backend-agnostic layer over external agent libraries: runner, controller, fluent AgentBuilder, event surface, and OpenAI/Claude adapters
ellements.benchmarking Async benchmark harnesses, model runners, dataset adapters, and comparison helpers
ellements.cli Terminal presentation primitives, agent TUI components, and slash-command building blocks
ellements.domain_specific Domain tools, currently including finance calculators, Yahoo Finance asset data, valuation, technical indicators, and risk helpers
ellements.reporting Chart artifacts, HTML report generation, and multi-format presentation helpers
ellements.standard_tools Reusable tool surfaces for terminal execution, web search, web crawl/read, and YouTube search/transcript access
ellements.fslm Finite-state linguistic machines: explicit graphs, deterministic kernel, natural-language evaluators, persistence, observers, and fslm CLI

Quick start

import asyncio

from ellements.core import JsonlPromptLogger, LLMClient, LocalCacheConfig


async def main() -> None:
    client = LLMClient(
        model="openai/gpt-5.5",
        observers=[JsonlPromptLogger("./logs")],
        local_cache=LocalCacheConfig("./cache"),
    )

    answer = await client.complete("Explain attention in one paragraph.")
    print(answer)


asyncio.run(main())

Run a strategy

from ellements.execution import ReflectionConfig, ReflectionStrategy

strategy = ReflectionStrategy()

result = await strategy.execute(
    prompts={
        "generate": "Draft a haiku about distributed systems.",
        "critique": "Review this draft and return a CritiqueResult:\n\n{{response}}",
        "revise": (
            "Revise the draft using the issues below.\n\n"
            "Draft:\n{{response}}\n\nIssues:\n{{issues}}"
        ),
    },
    client=client,
    config=ReflectionConfig(max_rounds=3),
)

print(result.output)

Runtime strategy templates accept both Mustache placeholders such as {{response}} and PromptSpec-style placeholders such as @{response}.

Build an agent

OpenAI is shown here as one concrete adapter; the builder targets the backend-agnostic AgentBackend protocol.

from ellements.agents import AgentBuilder, OpenAIAgentsBackend

agent = (
    AgentBuilder("researcher", backend=OpenAIAgentsBackend())
    .with_model("gpt-4.1")
    .with_instructions("Research carefully, cite evidence, and be concise.")
    .with_tool("search", my_search_tool)
    .build()
)

Use finance and web tools

Finance and web tools expose canonical ToolRegistry surfaces, so LLM clients, agents, and PromptSpec examples can bind the same tools without local adapters.

pip install "ellements[finance,web]"
playwright install chromium  # required by crawl4ai-backed page crawling
from ellements.domain_specific.finance.yahoo_finance import finance_tools
from ellements.standard_tools.web.crawler import web_crawler_tools
from ellements.standard_tools.web.search import web_search_tools

tools = (
    finance_tools()
    .merge(web_search_tools())
    .merge(web_crawler_tools(max_content_tokens=4000))
)

print(sorted(tools))

Typical stock-research tools include search_asset, get_asset_quote, get_asset_profile, get_financial_metrics, search_web, search_news, and crawl_url.

Packaging model

The repo is modular at the filesystem level:

ellements-core/src/ellements/core
ellements-execution/src/ellements/execution
ellements-agents/src/ellements/agents
ellements-benchmarking/src/ellements/benchmarking
ellements-cli/src/ellements/cli
ellements-domain-specific/src/ellements/domain_specific
ellements-fslm/src/ellements/fslm
ellements-reporting/src/ellements/reporting
ellements-standard-tools/src/ellements/standard_tools

Those source roots are discovered into a single wheel, ellements-<version>-py3-none-any.whl. Users install one PyPI project and import the modules they need:

from ellements.core import LLMClient
from ellements.domain_specific.finance.yahoo_finance import finance_tools
from ellements.execution import TreeOfThoughtStrategy
from ellements.agents import AgentBuilder
from ellements.fslm import FSLMKernel
from ellements.standard_tools.web.search import web_search_tools

This gives the repo clean internal boundaries without creating multiple PyPI entries to publish, document, secure, and maintain.

Local development

pip install -e ".[dev,all]"
python -m pytest -q
python -m ruff check .
python -m mypy --strict ellements-core/src ellements-execution/src \
  ellements-agents/src ellements-benchmarking/src ellements-cli/src \
  ellements-domain-specific/src ellements-fslm/src ellements-reporting/src \
  ellements-standard-tools/src

License

MIT, with the project status and maintenance notice in LICENSE.

Download files

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

Source Distribution

ellements-0.2.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

ellements-0.2.1-py3-none-any.whl (256.6 kB view details)

Uploaded Python 3

File details

Details for the file ellements-0.2.1.tar.gz.

File metadata

  • Download URL: ellements-0.2.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ellements-0.2.1.tar.gz
Algorithm Hash digest
SHA256 51f8c3ba9d5e020773119a0f3e258e2827d98a5ab9e283e7457e0649b7d736cb
MD5 54bec0bf41318d3e8a4a2dff77124aa8
BLAKE2b-256 36fe04fd5f456485f34321e7085abe25f7352cb6ddcb99a418cb04e18b62ca98

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellements-0.2.1.tar.gz:

Publisher: release.yml on paulosalem/ellements

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

File details

Details for the file ellements-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ellements-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 256.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ellements-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d90a8dff1509e92479590c12617b5bef8cc566edcd6edfb294a62613c3583a05
MD5 fd2e55d8a94be40abb0eb8373952f0f4
BLAKE2b-256 60396f4e6d87bdcc1a8d17edaedae708fa50c081975c866eeef0a974f36e37d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellements-0.2.1-py3-none-any.whl:

Publisher: release.yml on paulosalem/ellements

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

Release history Release notifications | RSS feed

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

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