How codingwithanish/parlant works
Project Type and Purpose
• Parlant is a full-stack, open-source conversation modeling engine with two main surfaces:
• A Python‐based backend (Parlant REST API + core engine) that orchestrates guideline matching, tool calling, and message composition.
• A TypeScript/React “sandbox” UI (chat SPA) served by the backend for interactive testing.
• It also provides CLI binaries (parlant-server, parlant-client) and SDKs for Python and TypeScript.
Top-Level Architecture Layers
• Presentation Layer
• Browser / Developer CLI → React SPA + WebSocket console for real‐time logs.
• API Layer
• src/parlant/api/app.py uses FastAPI (or similar) to expose REST endpoints and WebSocket streams.
• Controllers under src/parlant/api/*.py (sessions, agents, guidelines, logs, etc.).
• Core Engine Layer
• src/parlant/core/application.py and sub-packages implement:
– Guideline matching (guideline_matcher)
– Tool invocation (tool_caller)
– Message composition / self-critique
– Event emission (buffer + publisher)
• Uses hexagonal (ports & adapters) pattern—core logic depends on abstract interfaces.
• Adapter Layer
• Database adapters (adapters/db/*): MongoDB, JSON file, in-memory.
• Vector DB adapters (adapters/vector_db/*): Chroma, in-memory.
• NLP service adapters (adapters/nlp/*): OpenAI, Azure, Anthropic, Gemini, HuggingFace, etc.
• Logger adapter (adapters/loggers/*): WebSocket, file.
• Persistence Layer
• Document store (Mongo or JSON) for sessions, guidelines, glossary, etc.
• Vector store (Chroma) for embeddings.
• External Services
• LLM providers via REST
• OpenAPI‐driven tools (plugin framework)
• Third‐party services invoked through tool adapters.