|
1 | | -# 🧠 AI-Optimized Project Context: Antigravity Workspace |
| 1 | +# AI-Parrot — Architectural Context |
2 | 2 |
|
3 | | -## 1. Executive Summary & Core Mission |
| 3 | +## What is AI-Parrot |
| 4 | +Async-first Python framework for building AI Agents and Chatbots. |
| 5 | +Vendor-agnostic: supports OpenAI, Anthropic, Google GenAI, Groq, VertexAI, |
| 6 | +HuggingFace via a unified `AbstractClient` interface. |
4 | 7 |
|
5 | | -**Core Philosophy: "Cognitive-First" & "Artifact-First"** |
6 | | -The agent must not just execute tasks but *think* like a senior engineer. This is achieved through a mandatory "Think-Act-Reflect" loop. |
| 8 | +--- |
| 9 | + |
| 10 | +## Core Abstractions (always inherit from these) |
| 11 | + |
| 12 | +### AbstractClient |
| 13 | +Unified interface for all LLM providers. |
| 14 | +Location: `parrot/clients/abstract_client.py` |
| 15 | +- Never call provider SDKs directly — always go through AbstractClient |
| 16 | +- Implement `async def completion()`, `async def stream()`, `async def embed()` |
| 17 | + |
| 18 | +### AbstractBot / Chatbot / Agent |
| 19 | +Location: `parrot/bots/` |
| 20 | +- `AbstractBot` — base class for all bots |
| 21 | +- `Chatbot` — conversational, stateful, single-LLM |
| 22 | +- `Agent` — tool-using, ReAct-style reasoning loop |
| 23 | + |
| 24 | +### AbstractTool / @tool decorator |
| 25 | +Location: `parrot/tools/` |
| 26 | +- Simple functions: use `@tool` decorator |
| 27 | +- Complex collections: inherit `AbstractToolkit` |
| 28 | +- Every tool MUST have a docstring — it becomes the LLM's tool description |
| 29 | + |
| 30 | +### AgentCrew |
| 31 | +Location: `parrot/bots/orchestration/crew.py` |
| 32 | +Three execution modes: |
| 33 | +- `run_sequential()` — agents in chain, output feeds next |
| 34 | +- `run_parallel()` — agents run concurrently, results merged |
| 35 | +- `run_flow()` — DAG-based, dependencies declared via `task_flow()` |
| 36 | + |
| 37 | +### Loaders |
| 38 | +Location: `parrot/loaders/` |
| 39 | +Transform documents (PDF, HTML, DOCX, etc.) into text chunks for RAG. |
| 40 | +Inherit `BaseLoader`, implement `async def load() -> list[Document]` |
| 41 | + |
| 42 | +### Vector Stores |
| 43 | +- PgVector: `parrot/vectorstores/pgvector.py` — primary store |
| 44 | +- ArangoDB: graph-based, in development |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Key Patterns to Follow |
| 49 | + |
| 50 | +### Registering a new component |
| 51 | +New bots/tools/clients are registered via decorators: |
| 52 | +```python |
| 53 | +from parrot.registry import register_agent |
| 54 | + |
| 55 | +@register_agent("my-agent") |
| 56 | +class MyAgent(Agent): |
| 57 | + ... |
| 58 | +``` |
| 59 | + |
| 60 | +### Async everywhere |
| 61 | +```python |
| 62 | +# CORRECT |
| 63 | +async def process(self, data: str) -> Result: |
| 64 | + result = await self.client.completion(data) |
| 65 | + return result |
| 66 | + |
| 67 | +# WRONG — never block the event loop |
| 68 | +def process(self, data: str) -> Result: |
| 69 | + return requests.post(...) |
| 70 | +``` |
| 71 | + |
| 72 | +### Logging pattern |
| 73 | +```python |
| 74 | +import logging |
| 75 | + |
| 76 | +class MyComponent: |
| 77 | + def __init__(self): |
| 78 | + self.logger = logging.getLogger(__name__) |
| 79 | + |
| 80 | + async def method(self): |
| 81 | + self.logger.info("Starting operation") |
| 82 | + self.logger.debug("Detail: %s", detail) |
| 83 | +``` |
| 84 | + |
| 85 | +### Pydantic for all structured data |
| 86 | +```python |
| 87 | +from pydantic import BaseModel, Field |
| 88 | + |
| 89 | +class ToolInput(BaseModel): |
| 90 | + query: str = Field(..., description="Used as tool description for LLM") |
| 91 | + top_k: int = Field(default=5, ge=1, le=20) |
| 92 | +``` |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## What Lives Where |
| 97 | +``` |
| 98 | +parrot/ |
| 99 | +├── clients/ # LLM provider wrappers (AbstractClient subclasses) |
| 100 | +├── bots/ # Bot and Agent implementations |
| 101 | +│ └── orchestration/ # AgentCrew, DAG execution |
| 102 | +├── tools/ # Tool definitions and toolkits |
| 103 | +├── loaders/ # Document loaders for RAG |
| 104 | +├── vectorstores/ # PgVector, ArangoDB |
| 105 | +├── handlers/ # HTTP handlers (aiohttp-based) |
| 106 | +├── memory/ # Conversation memory (Redis-backed) |
| 107 | +└── integrations/ # Telegram, MS Teams, Slack, MCP |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
7 | 111 |
|
8 | | -1. **Think (Plan):** Before any complex coding, the agent MUST generate a plan in `artifacts/plan_[task_id].md`. This enforces structured thinking. |
9 | | -2. **Act (Execute):** Write clean, modular, and well-documented code following the project's strict standards. |
10 | | -3. **Reflect (Verify):** The agent is responsible for verifying its work, primarily by running `pytest` after making changes. All evidence (logs, test results) is stored in `artifacts/logs/`. |
| 112 | +## What NOT to Do |
| 113 | +- Never use `requests` or `httpx` — use `aiohttp` |
| 114 | +- Never subclass LangChain components — LangChain is removed |
| 115 | +- Never store secrets in code — use environment variables |
| 116 | +- Never add synchronous blocking code in async methods |
| 117 | +- Never modify `abstract_client.py` without discussing first — it's the foundation |
11 | 118 |
|
12 | 119 | --- |
13 | 120 |
|
14 | | -## 2. Environment, DevOps, and Project Structure |
| 121 | +## Current Active Development |
| 122 | +Branch: `finance-agents` |
| 123 | +Main: `main` |
15 | 124 |
|
16 | | -* `.agent/`: Core AI rules and persona. **(Crucial for agent behavior)**. |
17 | | - * `rules.md`: The Agent's Constitution and Directive. |
18 | | - * `rules/python-development.md`: Specific standards for Python development (uv, venv, libraries). |
19 | | -* `artifacts/`: All agent-generated outputs (plans, logs, screenshots). |
20 | | -* `tests/`: The `pytest` test suite. |
| 125 | +Active areas (check these before modifying): |
| 126 | +- `parrot/bots/orchestration/` — AgentCrew DAG execution |
| 127 | +- `parrot/memory/` — Redis-based conversation memory |
| 128 | +- `parrot/integrations/mcp/` — MCP server implementation |
| 129 | +- `parrot/tools/` — Tool definitions and toolkits |
| 130 | +- `parrot/integrations/` — Platform integrations (Whatsapp, Telegram, Slack, MS Teams) |
0 commit comments