Skip to main content

Alternative ReAct implementation for DSPy with full conversation history

Project description

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

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

dspy_react_machina-0.1.2.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

dspy_react_machina-0.1.2-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file dspy_react_machina-0.1.2.tar.gz.

File metadata

  • Download URL: dspy_react_machina-0.1.2.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for dspy_react_machina-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7cf13741e12d87d3de4e144af4bcc1ee9ed68734912fffdd2410245c2a8c8a2f
MD5 3f89102e153878a136e68bb6e56fe144
BLAKE2b-256 e7f4b5723c8b7aa3dfe2daa9b0f6fd3ef13057a62e5657971daa04362421e5e4

See more details on using hashes here.

File details

Details for the file dspy_react_machina-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dspy_react_machina-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6cdb6eda1187d1ba01b507d3b6612500940af7ead3a0f0c066a6b742e3141631
MD5 ac721c353ce942fc00c3ca3e8e025c78
BLAKE2b-256 62f81cbd4bebf4e21d8b8ea883364df39680c8856d1732432121d42c24926701

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