Skip to main content

OpenHosta Logo

OpenHosta

The semantic layer for Python.
Write what you mean. Python does the rest.

PyPI Version Python Versions License CI Status


OpenHosta integrates Large Language Models directly into Python as native functions. Define a function with type hints and a docstring — OpenHosta uses AI to implement it. No DSL, no wrappers, just Python.

from OpenHosta import emulate

def translate(text: str, language: str) -> str:
    """Translates the text into the specified language."""
    return emulate()

print(translate("Hello World!", "French"))
# 'Bonjour le monde !'

OpenHosta also enables semantic testing — evaluate conditions that require cultural knowledge or fuzzy logic, something traditional assert statements can never do:

from OpenHosta import test

sentence = "You are an nice person."

if test(f"this contains an insult: {sentence}"):
    print("The sentence is considered an insult.")
else:
    print("The sentence is not considered an insult.")
# The sentence is not considered an insult.

Why OpenHosta?

  • Zero DSL — Pure Python syntax. Your functions stay readable, testable, and IDE-friendly.
  • Type-safe — Guarded types validate LLM output against your annotations (int, dict, Enum, Pydantic, Callable…).
  • Model-agnostic — Works with OpenAI, Ollama, Azure, vLLM — any OpenAI-compatible endpoint.
  • Runs offline — Full local execution with Ollama. Your data stays private.
  • Production-ready — Uncertainty tracking, cost tracking, audit mode, and async support built-in.

Installation

pip install OpenHosta

We recommend using a virtual environment (python -m venv .venv). See the full installation guide for local model setup, optional dependencies, and troubleshooting.

Quick Start

Option A: Local Execution (Ollama)

Ensure you have Ollama installed and run ollama run qwen3.5:4b in your terminal.

from OpenHosta import emulate, OpenAICompatibleModel, config

# 1. Point OpenHosta to your local Ollama instance
local_model = OpenAICompatibleModel(
    model_name="qwen3.5:4b",
    base_url="http://localhost:11434/v1",
    api_key="none"  # Ollama does not require a key
)
config.DefaultModel = local_model

# 2. Define and call your function
def translate(text: str, language: str) -> str:
    """Translates the text into the specified language."""
    return emulate()

print(translate("Hello World!", "French"))
# 'Bonjour le monde !'

Option B: Remote API (OpenAI)

Create a .env file in your project directory:

OPENHOSTA_DEFAULT_MODEL_NAME="gpt-4.1"
OPENHOSTA_DEFAULT_MODEL_API_KEY="your-api-key-here"
from OpenHosta import emulate

def translate(text: str, language: str) -> str:
    """Translates the text into the specified language."""
    return emulate()

print(translate("Hello World!", "French"))
# 'Bonjour le monde !'

What Can You Do?

Feature Description
emulate AI-implemented functions from docstrings
emulate_async Non-blocking async variant for concurrency
emulate_variants Streaming results via lazy generators
closure Semantic lambda functions
test Fuzzy logic / semantic boolean tests
Types & Pydantic int, dict, Enum, dataclass, Pydantic, Callable…
Safe Context Uncertainty tracking & error handling
Image input Pass PIL.Image directly to functions

📖 Full Documentation · 📝 Changelog · 🧪 Examples

Contributing

We warmly welcome contributions! Please refer to our Contribution Guide and Code of Conduct.

Browse existing issues to find contribution ideas.

License

MIT License — see LICENSE for details.

Authors

  • Emmanuel Batt — Manager and Coordinator, Founder of Hand-e
  • William Jolivet — DevOps, SysAdmin
  • Léandre Ramos — AI Developer
  • Merlin Devillard — UX Designer, Product Owner

GitHub: https://github.com/hand-e-fr/OpenHosta


The future of development is human. — The OpenHosta Team

Metadata

Release files for OpenHosta 4.3.1

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

Source distribution (sdist)

Source distribution for OpenHosta 4.3.1
File Size Uploaded
openhosta-4.3.1.tar.gz 90.5 kB Details

Built distribution (wheel)

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

Total release size: 201.9 kB

Release files / openhosta-4.3.1.tar.gz

Download URL openhosta-4.3.1.tar.gz
Size 90.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5836e55dc0ba4783bded838de536522c823474733408a638f0f947b4f49d510d
BLAKE2b-256 checksum
How to use checksums
9b6f5b305f82abaa6d86afc7c949c72494a0df61f7c784f22874c0831e39f6f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / openhosta-4.3.1-py3-none-any.whl

Download URL openhosta-4.3.1-py3-none-any.whl
Size 111.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d018410d944ffd94ced6b3590bf46af8a5893697fef9b80a8e5122f7559e09b7
BLAKE2b-256 checksum
How to use checksums
36b540b7bdf427691bb04558d80105b124d4e0be9f76794575088206ac2d89af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

4.3.1 This release

2 release files

4.3.0

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.6

2 release files

4.0.5

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release 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