Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/wiki.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# PapiAI Project Wiki

## Project Overview
PapiAI Core is a professional, type-safe PHP library designed for building robust AI agents. It decouples the agent logic from specific LLM providers, allowing developers to switch between Anthropic (Claude), Google (Gemini), and others with ease. It focuses on developer experience with strict typing (PHP 8.2+), intuitive interfaces for tool calling, and structured data extraction.

## Architecture
The library is built around a few key components:
- **Agent**: The main orchestrator that manages context, instructions, and the conversation loop.
- **Provider**: An interface for LLM backends (e.g., `AnthropicProvider`, `GoogleProvider`).
- **Tool**: Encapsulates capabilities the agent can use, definable via closures or class attributes.
- **Schema**: A fluent builder for defining structured output expectations (Zod-like).

## Roadmap

### Phase 1: Foundation (Current)
- Core architecture (Agent, Provider, Tool, Schema).
- Support for Anthropic Claude and Google Gemini.
- Event-driven streaming and observability hooks.

### Phase 2: Expansion (Next)
- **OpenAI Integration**: Add support for GPT-4o and o1 models.
- **Memory Systems**: Abstract persistence layers for conversation history (Redis, SQL).
- **RAG Support**: Simple interfaces for vector store retrieval.

### Phase 3: Advanced Capabilities
- **Multi-Agent Systems**: Patterns for agent delegation and collaboration.
- **Framework Integrations**: Dedicated packages for Laravel and Symfony.
- **Local LLM Support**: Adapters for Ollama/Llama.cpp.
63 changes: 63 additions & 0 deletions papi-core/docs/WIKI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# PapiAI Project Wiki

## 1. Project Overview

**PapiAI** is a modern, framework-agnostic PHP library designed for building robust AI agents. It provides a unified interface to interact with various Large Language Models (LLMs) like Anthropic Claude and Google Gemini, making it easy to integrate AI capabilities into any PHP application (Laravel, Symfony, or standalone).

### Key Philosophy
- **Simplicity**: Clean, intuitive API for creating agents.
- **Type Safety**: Built on PHP 8.2+ with strict typing.
- **Modularity**: Core logic is separated from specific provider implementations.

## 2. Architecture

The project is structured around a few key abstractions:

### Core Components (`papi-ai/papi-core`)
- **Agent**: The main entry point. It orchestrates interactions between the user, the LLM provider, and available tools.
- **ProviderInterface**: The contract that all LLM providers must implement. It standardizes:
- `chat()`: Standard request/response.
- `stream()`: Real-time streaming responses.
- Capabilities: `supportsTool()`, `supportsVision()`, `supportsStructuredOutput()`.
- **Tool**: encapsulations of functions or class methods that the AI can "call" to perform actions (e.g., fetching weather, querying a database).
- **Schema**: A fluent builder (Zod-like) for defining structured output requirements, ensuring the AI returns data in a predictable format.

### Providers
Specific implementations are handled in separate packages to keep the core lightweight:
- `papi-ai/anthropic`: Adapter for Anthropic's Claude models.
- `papi-ai/google`: Adapter for Google's Gemini models.
- `papi-ai/openai`: (Planned/In-progress) Adapter for OpenAI.

## 3. Getting Started

### Installation
Install the core package and your desired provider:

```bash
composer require papi-ai/core
composer require papi-ai/anthropic
```

### Basic Usage
Here is how to create a simple agent using Claude:

```php
use PapiAI\Core\Agent;
use PapiAI\Anthropic\AnthropicProvider;

$agent = new Agent(
provider: new AnthropicProvider(apiKey: $_ENV['ANTHROPIC_API_KEY']),
model: 'claude-3-5-sonnet-20240620',
instructions: 'You are a helpful coding assistant.'
);

$response = $agent->run('Refactor this class for me...');
echo $response->text;
```

## 4. Advanced Features

- **Tool Calling**: Define PHP functions or class methods as tools. The Agent handles the LLM's request to execute them.
- **Structured Output**: Enforce JSON schemas on responses for reliable data extraction.
- **Streaming**: Subscribe to event streams for real-time UI updates.
- **Observability**: Hooks available for logging and monitoring agent performance.
Loading