Git Product home page Git Product logo

multiparty's Introduction

Multiparty logo

Multiparty provides fine-grained, programmatically defined permissions to control sensitive operations performed by AI Agents, without brittle if statements.

Sign up for the waitlist to give feedback and get access.

This repository serves as a central hub for the GitHub issues, use cases, and bug reports related to Multiparty for easier tracking and communication. For additional information, visit Multiparty.ai.

Usage

Run test suite:

go test ./pkg/engine.go

Run the simulator:

cd examples/simulator
npm i
npm run wasm
npm run dev

Learn more

Feedback?

We'd love to hear from you! Feel free to open an issue about a new use case or contact our team over email.

Concepts

  • Rules prescribe expectations for a system
    • Deterministic evaluation using Google's Common Expression Language (CEL)
  • Actions run using WASM or Linux containers
  • Plans specify ways to satisfy Rules using Actions

Architecture

๐Ÿš Client

  • Lightweight language wrappers around Rust/Go core
    • Python
    • JavaScript/TypeScript
    • Swift
    • Ruby
  • Implements check and enforce commands
    • check quickly verifies assertions, e.g. don't execute if over budget
    • enforce provides async verification over longer windows, e.g. require user approval to be collected
  • Support for local/embedded or remote engine
    • Embedded engine allows check without network connection
    • Remote engine provides centralized manage and control of rules

โš™๏ธ Engine

  • Evalute Rules either locally or remote
    • Local for edge compute, testing, and single-tenant applications
    • Remote allows distributed and remote coordination
  • Perform Actions in accordance to Plans
    • Dispatches WASM or containers for execution
    • Capture results and side effects to be used by Rules
  • Durable storage for Plan and enforce calls
    • Execute Actions using either WASM or containers
  • Signed decision chains skip the guesswork on why an Action was taken
    • Audit logs satisfy compliance requirements
  • Budgets allow LLM-backed applications to deliver high quality UX with scalable costs

Frequently Asked Questions

Where does this fit into my existing Langchain, LlamaIndex, or Griptape app?
# langchain/libs/langchain/langchain/callbacks/human.py

from typing import Any, Callable, Dict, Optional
from uuid import UUID

from langchain.callbacks.base import BaseCallbackHandler
+ from multiparty.utils import async_input

def _default_approve(_input: str) -> bool:
    msg = (
        "Do you approve of the following input? "
-        "Anything except 'Y'/'Yes' (case-insensitive) will be treated as a no."
    )
    msg += "\n\n" + _input + "\n"
-   resp = input(msg)
-   return resp.lower() in ("yes", "y")
+   return async_input(msg)


def _default_true(_: Dict[str, Any]) -> bool:
    return True


class HumanRejectedException(Exception):
    """Exception to raise when a person manually review and rejects a value."""


class HumanApprovalCallbackHandler(BaseCallbackHandler):
    """Callback for manually validating values."""

    raise_error: bool = True

    def __init__(
        self,
        approve: Callable[[Any], bool] = _default_approve,
        should_check: Callable[[Dict[str, Any]], bool] = _default_true,
    ):
        self._approve = approve
        self._should_check = should_check

    def on_tool_start(
        self,
        serialized: Dict[str, Any],
        input_str: str,
        *,
        run_id: UUID,
        parent_run_id: Optional[UUID] = None,
        **kwargs: Any,
    ) -> Any:
        if self._should_check(serialized) and not self._approve(input_str):
            raise HumanRejectedException(
                f"Inputs {input_str} to tool {serialized} were rejected."
            )
How are prompts entered by users handled?

Prompt

When does Taylor's last meeting end today?

Tool function

async function getMeetingTimes(range = 'today', view = ['time']) {
  await multiparty.enforce('get_calendar')

  const { meetings } = await calendar.getEvents(range)
  return meetings.map(event => {
    const { metadata, time } = await multiparty.enforce('get_calendar_event', {
      event,
      view
        })
    return { ...metadata, ...time }
  })
  return 
}

Rules

// Time
view.contains('time') && getFields(event, ['startTime', 'endTime'])

// Attendees
view.contains('attendees') && getFields(event, ['organizer', 'attendees'])

// Metadata
getFields(event, ['id', 'etag'])
How does this compare to existing rule engines?

Rules

The Common Expression Language (CEL) is a non-Turing complete language designed for simplicity, speed, safety, and portability. CEL's C-like syntax looks nearly identical to equivalent expressions in C++, Go, Java, and TypeScript.

// Check whether a resource name starts with a group name.
resource.name.startsWith("/groups/" + auth.claims.group)
// Determine whether the request is in the permitted time window.
request.time - resource.age < duration("24h")
// Check whether all resource names in a list match a given filter.
auth.claims.email_verified && resources.all(r, r.startsWith(auth.claims.email))

A CEL "program" is a single expression. The examples have been tagged as java, go, and typescript within the markdown to showcase the commonality of the syntax.

Actions

Calling external functions works out-of-the-box with multiple languages (Python, JavaScript, etc) with built-in caching. Read or write from any HTTP source.

Tests

Deploy automated systems with confidence that common sense controls are correctly implemented and easily tested.

multiparty's People

Contributors

ethernetdan avatar fouad avatar

Stargazers

Tim Hudson avatar Rick Branson avatar Achille avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.