Lumen Agent Framework
repository·main·Indexed 43 days ago
https://github.com/holoviz/lumenAn open-source, agent-based framework for data interaction and Retrieval Augmented Generation (RAG). Lumen enables users to chat with data to generate SQL pipelines, visualizations, and dashboards using natural language. Built on Panel, it supports various LLM providers including OpenAI, Anthropic, Google, and local models via Ollama or llama-cpp. It features a declarative data model for data transformation and allows for the creation of deterministic 'Analyses' for domain-specific calculations.
What's inside Lumen
- The AI module in Lumen provides a framework for implementing AI-powered agents, analysis tools, and orchestration logic. It is organized into several specialized submodules that allow you to build complex, multi-agent workflows using Large Language Models (LLMs).
Overview of Lumen capabilities
mainLumen is an open-source, extensible agent-based framework designed for chatting with data and Retrieval Augmented Generation (RAG). It uses a declarative data model that allows LLMs to generate data transformation pipelines, visualizations, and dashboards.
Key Features:
- SQL Generation: Create pipelines for local/remote files, SQL databases, or data lakes.
- Context & Embeddings: Provide document access to LLMs for RAG.
- Data Visualization: Generate charts, tables, and dashboards via natural language.
- Inspection & Editing: Manually inspect, validate, and refine LLM outputs.
- Summarization: Extract insights and summarize results.
- Extensibility: Build custom agents, tools, and analyses tailored to specific domains.
Lumen is built on Panel, enabling it to render diverse output types with minimal effort.
NYC Taxi Dashboard Features
mainThe NYC Taxi dashboard is designed for million-row taxi trip analysis and includes the following capabilities:
- Large dataset handling: Efficiently processes millions of taxi trips.
- Geographic maps: Visualizes pickup and dropoff locations.
- Fare analysis: Displays the distribution of trip costs.
- Time filtering: Allows users to filter data by pickup time.
Explore Wind Turbines dashboard features
mainThe Wind Turbines dashboard demonstrates several Lumen capabilities for visualizing performance metrics and geographic distribution:
- Geographic distribution: Visualizing turbine locations across the US.
- Performance metrics: Analyzing capacity and output.
- Manufacturer comparison: Comparing different turbine makers.
- Interactive filtering: Using filters for state, manufacturer, and capacity.
Explore Lumen AI Core Components
mainLumen provides a suite of core AI components designed for building LLM-powered applications. The AI functionality is organized into four primary modules:
lumen.ai.llm: Interfaces for interacting with Large Language Models (LLMs).lumen.ai.embeddings: Tools for generating and managing vector embeddings.lumen.ai.vector_store: Interfaces and implementations for storing and querying vector data.lumen.ai.utils: General utility functions supporting AI workflows.
Use these modules to orchestrate context management, model interaction, and retrieval-augmented generation (RAG) patterns within your application.
Explore the Lumen API modules
mainLumen's API is organized into several functional modules. Depending on your task, you should refer to the following module documentation:
- AI Module: For working with AI-powered agents and analysis.
- Pipeline: For building and managing data pipeline components.
- Sources: For using data source connectors to ingest data.
- Transforms: For applying data transformation utilities.
- Views: For utilizing visualization components.
Identify built-in tools in Lumen
mainLumen automatically provides several tools to agents to facilitate data discovery and searching. You do not need to configure these manually.
Automatic Tools:
MetadataLookup: Finds relevant tables in your data.SourceLookup: Finds relevant external data source actions (added when aSourceAgentis present).list_indexed_documentsandsearch_document_chunks: Used to search uploaded documents when a document vector store is present.
Manual Tool:
DbtslLookup: Queries dbt Semantic Layer metrics. This is not automatic; you must explicitly pass it via thetools=argument inExplorerUIto enable it.
Precipitation Dashboard features
mainThe Precipitation dashboard demonstrates the following capabilities of Lumen:
- Geographic visualization: Visualizing precipitation patterns across the US.
- Time series: Analyzing historical precipitation trends.
- Regional analysis: Comparing data across different geographic areas.
Map YAML sections to Python classes
mainThe Python API mirrors the YAML structure using specific classes. Use these classes to build your dashboard programmatically:
YAML Section Python Class configlumen.Configsourceslumen.sources.*classespipelineslumen.Pipelinelayoutslumen.Layoutviewslumen.views.*classesDefine dashboards using YAML specifications
mainLumen allows you to create reproducible dashboards using YAML. A specification defines
sources(data locations),pipelines(data transformations and filters), andlayouts(the visual arrangement of views).Example YAML structure:
sources: penguins: type: file tables: data: https://datasets.holoviz.org/penguins/v1/penguins.csv pipelines: filtered: source: penguins table: data filters: - type: widget field: species - type: widget field: island layouts: - title: Palmer Penguins Dashboard pipeline: filtered views: - type: hvplot kind: scatter x: bill_length_mm y: bill_depth_mm color: species - type: hvplot kind: hist y: body_mass_g - type: tableUnderstand the Results Screen and Explorations
mainThe results screen is where analysis outputs are displayed. It consists of several key components:
- Exploration sidebar: Located on the left, this allows you to navigate through your history of analyses.
- Result tabs: Located on the right, these allow you to switch between different outputs like data tables and visualizations. The Data Source tab enables exploration via Graphic Walker.
- Code editor: Allows you to review and modify the underlying SQL queries or visualization specifications. Changes made here update the views in real-time.
- Interactive views: Data tables support sorting, filtering, and pagination; visualizations support tooltips.
Exploration Model: Lumen uses an exploration model where every SQL query that returns data creates a persistent workspace:
- Top-level explorations: Independent questions/queries.
- Nested explorations: Follow-up questions that appear as children of a parent exploration.
- Exploration tree: A hierarchical view in the left panel to navigate these relationships.
Understand Explorations in Lumen
mainLumen organizes work into Explorations, which act as saved workspaces for specific datasets or analysis threads.
An Exploration automatically captures:
- Conversation history
- Generated SQL queries
- Charts and visualizations
- Resulting data tables
Behavioral Rules:
- Context Retention: Follow-up questions (e.g., "Can you make that chart show only the top 5?") stay within the same exploration.
- Automatic Separation: Asking about a different dataset or an unrelated topic triggers the creation of a new exploration.
- Persistence: Explorations can be returned to later or exported as Jupyter notebooks.