Skip to main content

DSPy-ReAct-Machina

Alternative ReAct implementation for DSPy with full conversation history in a unified context.

Installation

pip install dspy-react-machina

Quick Start

import dspy
from dspy_react_machina import ReActMachina

# Configure your LM
lm = dspy.LM(model="openai/gpt-4o-mini")
dspy.configure(lm=lm)

# Define tools
def get_weather(city: str) -> str:
    """Get current weather for a city"""
    return f"Weather in {city}: 72°F, sunny"

# Create agent
agent = ReActMachina("history: dspy.History, question -> answer", tools=[get_weather])

# Chat with persistent history
history = dspy.History(messages=[])

while True:
    user_input = input("You: ").strip()
    if user_input.lower() in ["quit", "exit"]:
        break

    response = agent(question=user_input, history=history)
    print(f"Agent: {response.answer}\n")

    # Update history for next turn
    history = response.history

Documentation

Development

Setup

uv sync
uv run pre-commit install

Code Quality

uv run quality-check  # Run all checks: ruff + pyright

Testing

uv run tests                    # Run tests
uv run tests-coverage           # Run tests with coverage
uv run tests-coverage --web     # Run tests with coverage and open HTML report

Metadata

Release files for dspy-react-machina 0.1.2

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

Source distribution (sdist)

Source distribution for dspy-react-machina 0.1.2
File Size Uploaded
dspy_react_machina-0.1.2.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dspy-react-machina 0.1.2
File Interpreter ABI Platform
dspy_react_machina-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.1 kB

Release files / dspy_react_machina-0.1.2.tar.gz

Download URL dspy_react_machina-0.1.2.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7cf13741e12d87d3de4e144af4bcc1ee9ed68734912fffdd2410245c2a8c8a2f
BLAKE2b-256 checksum
How to use checksums
e7f4b5723c8b7aa3dfe2daa9b0f6fd3ef13057a62e5657971daa04362421e5e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / dspy_react_machina-0.1.2-py3-none-any.whl

Download URL dspy_react_machina-0.1.2-py3-none-any.whl
Size 26.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cdb6eda1187d1ba01b507d3b6612500940af7ead3a0f0c066a6b742e3141631
BLAKE2b-256 checksum
How to use checksums
62f81cbd4bebf4e21d8b8ea883364df39680c8856d1732432121d42c24926701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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