$ show weaviate/elysia
Elysia is an open-source agentic platform that uses a decision tree architecture to dynamically select and execute tools for searching and reasoning over vector databases (Weaviate). The core is a `Tree` class that maintains conversation history, an environment of retrieved objects, and a decision loop: at each step, an LLM (via DSPy) chooses which tool to call based on the current state and user goal. Built-in tools include hybrid/semantic query, aggregate, summarization, visualisation, and linear regression; custom tools can be added via a `@tool` decorator or by subclassing `Tool`. The system preprocesses Weaviate collections to generate LLM-created summaries, field mappings, and statistics, enabling adaptive query formulation. The platform includes a full-stack web application: a FastAPI backend with WebSocket endpoints for real-time query execution, and a built Next.js frontend (served as static files) offering a UI for conversations, collection management, tree visualisation (React Flow), and feedback collection. The backend manages multi-user and multi-conversation state via `UserManager`/`TreeManager`, persists trees to Weaviate, encrypts API keys, and supports feedback-driven few-shot learning. A CLI entry point (`elysia start`) launches the API server.
The LLM identified 4 files worth highlighting for reuse:
Defines the `Tool` base class with `ToolMeta` metaclass that automatically extracts metadata (name, description, inputs, end_actions) by parsing the `__init__` source via AST. Also provides the `@tool` decorator that converts async generator functions into Tool instances with immediate input signature extraction. This is a self-contained pattern for building extensible tool frameworks.
Custom DSPy `Module` (`ElysiaChainOfThought`) that injects the full tree state (user prompt, conversation history, environment, previous errors, collection schemas, completed tasks) into arbitrary DSPy signatures. Supports optional `impossible`, `message_update`, and `reasoning` outputs. This is a reusable pattern for providing rich context to LLM calls without modifying signatures.
`ClientManager` manages synchronous and asynchronous Weaviate clients with connection pooling, timeout-based restart logic, and thread/async lock protection. Provides context managers (`get_client`, `get_async_client`) that safely yield connected clients. This pattern is extractable for any database client that needs robust lifecycle management.
`Environment` class provides a structured key-value store for tool results with deduplication via `_REF_ID`. Supports `add`, `remove`, `replace`, and `find` operations, and auto-inserts `Result` objects when yielded. This is a generic state container pattern useful for any multi-step agent system.