Metadata-Version: 2.4
Name: lightmodel
Version: 0.4.1
Summary: Ultra-light autonomous AI agents for any OpenAI-compatible API
Author-email: PlimbAI <plimb.ai.contact@gmail.com>
License-Expression: MIT
Keywords: llm,ai,agent,openai,nvidia-nim,tool-calling,no-dependencies
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Provides-Extra: search
Requires-Dist: beautifulsoup4>=4.12; extra == "search"
Dynamic: license-file

# LightModel

Ultra-light **autonomous AI agents** for any OpenAI-compatible API.
No `smolagents`, no `litellm`, no `openai` — just `requests`.

## Features

- `LightModel`: HTTP client with automatic retry on transient errors
- `Agent`: autonomous tool-calling loop with parallel tools and callbacks
- Built-in tools: `web_search`, `visit_webpage`, `calculator`
- Extensible: add a tool by subclassing `Tool`
- Zero heavy dependencies

## Installation

    pip install lightmodel
    pip install lightmodel[search]   # with beautifulsoup4 for web tools

## Quick start

    from lightmodel import Agent, LightModel, SimpleDuckDuckGoSearchTool

    model = LightModel(
        model_id="meta/llama-3.3-70b-instruct",
        api_base="https://integrate.api.nvidia.com/v1",
        api_key="your_key",
    )
    agent = Agent(
        model=model,
        tools=[SimpleDuckDuckGoSearchTool()],
        system_prompt="You are a helpful research assistant.",
        max_steps=6,
        verbose=True,
    )
    print(agent.run("What are the latest AI news in 2026?"))

## Multi-turn conversation

    print(agent.chat("Tell me more about the first result."))
    print(agent.chat("Summarize in one sentence."))

## Custom tools

    from lightmodel import Tool

    class CalculatorTool(Tool):
        name = "calculator"
        description = "Evaluate arithmetic."
        inputs = {"expression": {"type": "string", "description": "e.g. 2+2"}}

        def forward(self, expression):
            return str(eval(expression, {"__builtins__": {}}, {}))

## Callbacks

    agent = Agent(
        model=model,
        tools=[SimpleDuckDuckGoSearchTool()],
        callbacks={
            "on_step": lambda step, msg: print(f"step {step}"),
            "on_tool_call": lambda name, args: print(f"→ {name}({args})"),
            "on_tool_result": lambda name, result: print(f"← {result[:80]}"),
            "on_final": lambda answer: print(f"✓ done"),
            "on_error": lambda exc: print(f"✗ {exc}"),
        },
    )

## Streaming

    for chunk in model.stream_chat([{"role": "user", "content": "Hi"}]):
        print(chunk, end="", flush=True)

## License

MIT
