Expand description
PolicyAI: A framework for turning unstructured data into structured data via composable policies.
PolicyAI provides a mechanism for writing policies that transform unstructured text into structured outputs. Policies are composable, meaning multiple policies can be applied together with configurable conflict resolution strategies.
§Core Concepts
- PolicyType: Defines the structure of data that policies will work with
- Policy: A semantic injection coupled with structured actions
- Field: A typed field in a policy with default values and conflict resolution
- Manager: Coordinates the application of multiple policies to unstructured data
- Report: The result of applying policies, including the structured output
§Example
use policyai::{PolicyType, Field, OnConflict, Manager};
let policy_type = PolicyType {
name: "EmailPolicy".to_string(),
fields: vec![
Field::Bool {
name: "unread".to_string(),
default: Some(true),
on_conflict: OnConflict::Default,
},
Field::StringEnum {
name: "priority".to_string(),
values: vec!["low".to_string(), "high".to_string()],
default: None,
on_conflict: OnConflict::LargestValue,
},
],
};Modules§
- analysis
- Analysis tools for evaluation metrics
- data
- Data structures and utilities for test data Data structures and utilities for test data generation and policy evaluation.
Structs§
- Bool
Mask - Represents a boolean field mask for policy application.
- Manager
- Manages a collection of policies and applies them to unstructured data.
- Number
Mask - Represents a numeric field mask for policy application.
- Policy
- Represents a policy with its type definition, prompt, and resulting action.
- Policy
Type - Represents a policy type definition with a name and a set of typed fields.
- Report
- Contains the result of applying policies to unstructured data.
- Report
Builder - Builder for constructing Reports from policy definitions.
- String
Array Mask - Represents a string array field mask for policy application.
- String
Enum Mask - Represents a string enumeration field mask for policy application.
- String
Mask - Represents a string field mask for policy application.
- Usage
- Usage metrics for PolicyAI operations.
- t64
- A totally-ordered 64-bit floating point number.
Enums§
- Apply
Error - Errors that can occur when applying policies to unstructured data
- Conflict
- Represents conflicts that occur when multiple policies attempt to set different values for the same field.
- Field
- Represents a field in a PolicyType with its type, default value, and conflict resolution strategy.
- OnConflict
- Defines how to resolve conflicts when multiple policies set the same field.
- Parse
Error - Errors that can occur during parsing of PolicyAI type definitions.
- Policy
Error - Errors that can occur when working with policies