Skip to content

About

Embed natural-language blocks in Python functions and execute them with LLMs.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PyPI PyPI Stats license issue resolution

Nighthawk

nighthawk-logo

Nighthawk is a Python library that makes natural-language judgment composable with ordinary Python functions.

Use Natural blocks for interpretation, classification, and other judgments; combine actions, constraints, and verification through Python functions and existing libraries. Python owns the surrounding control flow, state, and recovery. The same typed boundaries support provider-backed LLM calls and coding-agent executions.

Installation

Prerequisites: Python 3.13+

pip install nighthawk-python pydantic-ai-slim[openai]

For other providers, see Pydantic AI providers.

Example

import nighthawk as nh


def python_average(numbers: list[float]) -> float:
    return sum(numbers) / len(numbers)


step_executor = nh.AgentStepExecutor.from_configuration(configuration=nh.StepExecutorConfiguration(model="openai-responses:gpt-5.6-luna"))

with nh.run(step_executor):

    @nh.natural_function
    def calculate_average(numbers: list[object]) -> float:
        result: float = 0.0
        """natural
        Map each element of <numbers> to the number it represents,
        then compute <:result> by calling <python_average> with the mapped list.
        """
        return result

    print(calculate_average([1, "2", "three", "cuatro"]))  # 2.5

Natural interprets the mixed representations, python_average performs the deterministic calculation, and the output binding validates result as a float before Python resumes. Type validation constrains the result's shape; it does not prove the interpretation is correct.

See the Quickstart for setup details, credentials, and troubleshooting.

Embedding in an application

Hosts can admit whole function calls, select models without losing scoped controls, and observe block outcomes and model usage. See Runtime configuration for usage and execution boundaries for the guarantees. The runtime configuration guide includes executable host-integration examples that run without credentials.

Documentation

Development & Contributing

See CONTRIBUTING.md for setup, development commands, and contribution guidelines.

Inspired by Nightjar.

About

Embed natural-language blocks in Python functions and execute them with LLMs.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages