Skip to main content

A lightweight library integrating LLM natively into Python

Project description

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

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

openhosta-4.3.0.tar.gz (90.5 kB view details)

Uploaded Source

Built Distribution

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

openhosta-4.3.0-py3-none-any.whl (111.4 kB view details)

Uploaded Python 3

File details

Details for the file openhosta-4.3.0.tar.gz.

File metadata

  • Download URL: openhosta-4.3.0.tar.gz
  • Upload date:
  • Size: 90.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for openhosta-4.3.0.tar.gz
Algorithm Hash digest
SHA256 eaa61e5d75b9d3c1624290f8896efd1b776f40e1e9d6ec7302d8dfe15668eefb
MD5 96780b531a5de4a9db4a45a9f66aa93d
BLAKE2b-256 2c4771a4cb33400fc6447069dff5b3cbf9dfb450b90e3999b608132f6467d30f

See more details on using hashes here.

File details

Details for the file openhosta-4.3.0-py3-none-any.whl.

File metadata

  • Download URL: openhosta-4.3.0-py3-none-any.whl
  • Upload date:
  • Size: 111.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for openhosta-4.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1bfa258a69f5c7aa9873c0099c3135793afd8cb211dbb3cca63496bffdcb6a5
MD5 05c09c3269cf1c273e76caf8dc1b8161
BLAKE2b-256 e11ded1973bfdf50da05a08b5d880f41d7b973b4e5cdf06f78d1fd4d372f49db

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