Skip to main content

A Python package for web processing and vision tasks with browser automation capabilities

Project description

DoNew: Your Composable Task Library

PyPI version PyPI - Python Version PyPI - License

What is DoNew?

DoNew is a Python package designed to empower AI agents to interact effortlessly with web content and documents through high-level, intuitive interfaces. It bridges the gap between advanced AI capabilities and real-world applications by offering robust tools for web automation, document processing, and autonomous task execution. Developers can build isolated tasks that integrate seamlessly with their favorite tools, composing them either horizontally as peers or vertically as nested workflows to orchestrate complex operations, all while keeping each task self-contained and extendable.

Quick Install

pip install donew
playwright install  # Install required browsers

Key Features

  • Task Planning & Multi-Step Operations: Organize complex workflows with clear planning and sequential execution.
  • Provision Isolation: Context is isolated from the rest of the world. Each provision is a self-contained unit during runtime.
  • Web Automation (DO.Browse): Leverage Playwright-based browser automation featuring smart element detection, visual debugging, and integrated knowledge graph extraction.
  • Knowledge Processing: Utilize multi-model entity extraction (GLiNER), relationship mapping (GLiREL), advanced text analysis with spaCy, and robust graph storage via KuzuDB.
  • Task Composition & Context Awareness: Achieve both horizontal (parallel provisions) and vertical (nested tasks) composition with comprehensive state and context management.
  • Plug-and-Play Provisions: Comes with batteries included—ready-made tools such as MCP.run tasks and Restack workflows.

Core Concepts

Terminology

  • Doer: A task executor that can be enacted. instance of DO.New
  • Provision: A tool that can be used to enact a doer.
  • Realm: The context in which a doer is enacted.
  • Envision: The expected output of a doer.
  • Enact: The act that triggers a doer to start its journey.

Goals

  1. Intuitive interface DO.New for task execution, DO.Browse for standalone web automation
  2. Provide AI-first interfaces for web and document interaction
  3. Enable autonomous decision-making and task execution
  4. Maintain high reliability and performance
  5. Ensure excellent developer experience
  6. Support both simple and complex AI agent workflows
  7. Provide batteries included provisions
  8. Hide underlying complexity from the user

Usage Guide

1. Creating a Task with DO.New

from donew import DO

# Create a new task (doer) with a model
model = LitellmModel()
doer = DO.New(model, name='example_task', purpose='demonstrate basic usage')

2. Adding Context with realm()

# Assume browser is a provision for web tasks
browser = DO.Browse(headless=False)

doer = doer.realm([browser])

3. Enforcing Output Structure with envision()

from pydantic import BaseModel, Field

class Team(BaseModel):
    members: list[str] = Field(description='List of team members')

# This enforces that the output should match the Team schema
constrained_doer = doer.envision(Team)

4. Kickstarting the Workflow with enact()

result = constrained_doer.enact('goto https://unrealists.com and find the team')

Development Setup

Requirements

  • Python 3.11+ (required for Knowledge Graph functionality)
  • uv package manager (recommended over pip)

Installation Steps

  1. Clone the repository
git clone https://github.com/DONEWio/donew.git
cd donew
  1. Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create and activate virtual environment:
uv venv -p python3.11
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:

    • For basic usage:
    uv pip install pip
    uv pip install -e ".[dev]"
    
    • For Knowledge Graph functionality:
    uv pip install pip
    uv pip install -e "."
    uv pip install -e ".[kg,dev]"
    uv run -- spacy download en_core_web_md
    
  2. Install Playwright browsers:

playwright install chromium
playwright install # or all browsers

Testing

Run the test suite:

pytest tests/ --httpbin-url=https://httpbin.org

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Knowledge Graph Component

The Knowledge Graph component (donew.see.graph) provides entity and relationship extraction from text, with persistent storage in KuzuDB. This implementation is inspired by and adapted from the GraphGeeks.org talk and strwythura.

Features

  • Named Entity Recognition using GLiNER
  • Relationship Extraction using GLiREL
  • Graph storage and querying with KuzuDB
  • Text processing and chunking with spaCy

Graph Construction

The graph is built in layers:

  1. Base Layer: Textual analysis using spaCy parse trees
  2. Entity Layer: Named entities and noun chunks from GLiNER
  3. Relationship Layer: Semantic relationships from GLiREL
  4. Storage Layer: Persistent graph storage in KuzuDB

Usage

from donew.see.graph import KnowledgeGraph

# Initialize KG (in-memory or with persistent storage)
kg = KnowledgeGraph(db_path="path/to/db")  # or None for in-memory

# Analyze text
result = kg.analyze("""
OpenAI CEO Sam Altman has partnered with Microsoft.
The collaboration was announced in San Francisco.
""")

# Query the graph
ceo_relations = kg.query("""
MATCH (p:Entity)-[r:Relation]->(o:Entity)
WHERE p.label = 'Person' AND o.label = 'Company'
AND r.type = 'FOUNDER'
RETURN p.text as Founder, o.text as Company
ORDER BY Founder;
""") 

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

donew-0.1.9.tar.gz (71.7 kB view details)

Uploaded Source

Built Distribution

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

donew-0.1.9-py3-none-any.whl (63.8 kB view details)

Uploaded Python 3

File details

Details for the file donew-0.1.9.tar.gz.

File metadata

  • Download URL: donew-0.1.9.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for donew-0.1.9.tar.gz
Algorithm Hash digest
SHA256 17d3d339cadee67162ea97423d48f91e06f15e7d489d70f9c0f993455d4d42cc
MD5 277e850d3edba7a9c94804209e583ebc
BLAKE2b-256 b13f83e14d44019ee7afec26a6ed2e694702229b3a57fa2be2b46297744d3a77

See more details on using hashes here.

Provenance

The following attestation bundles were made for donew-0.1.9.tar.gz:

Publisher: pypi-publish.yml on DONEWio/Do

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file donew-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: donew-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 63.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for donew-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1aec87fc46b3a767e393168e6434a9800737f5e13a0d2bcefd5e29d59bcf3767
MD5 a2ef01b8d56790f3605d9da0c46b92ab
BLAKE2b-256 1b03ff29ad23cba789d70fde00e5e97b54f0cc56b9ef19e662bea7720c40ba4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for donew-0.1.9-py3-none-any.whl:

Publisher: pypi-publish.yml on DONEWio/Do

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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