Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ uv run pytest -v -m "not apikey"
```
databao/
api.py # public entry: new_agent(...)
core/ # Agent, Pipe, Executor, Visualizer abstractions
core/ # Agent, Thread, Executor, Visualizer abstractions
agents/ # Lighthouse (default) and React-DuckDB agents
duckdb/ # DuckDB integration and tools
visualizers/ # Vega-Lite chat visualizer and utilities
Expand Down
4 changes: 2 additions & 2 deletions databao/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

from databao.api import new_agent
from databao.configs.llm import LLMConfig
from databao.core import Agent, ExecutionResult, Executor, Opa, Pipe, VisualisationResult, Visualizer
from databao.core import Agent, ExecutionResult, Executor, Opa, Thread, VisualisationResult, Visualizer

__all__ = [
"Agent",
"ExecutionResult",
"Executor",
"LLMConfig",
"Opa",
"Pipe",
"Thread",
"VisualisationResult",
"Visualizer",
"__version__",
Expand Down
4 changes: 2 additions & 2 deletions databao/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from databao.core.cache import Cache
from databao.core.executor import ExecutionResult, Executor
from databao.core.opa import Opa
from databao.core.pipe import Pipe
from databao.core.thread import Thread
from databao.core.visualizer import VisualisationResult, Visualizer

__all__ = ["Agent", "Cache", "ExecutionResult", "Executor", "Opa", "Pipe", "VisualisationResult", "Visualizer"]
__all__ = ["Agent", "Cache", "ExecutionResult", "Executor", "Opa", "Thread", "VisualisationResult", "Visualizer"]
8 changes: 4 additions & 4 deletions databao/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy import Connection, Engine

from databao.configs.llm import LLMConfig
from databao.core.pipe import Pipe
from databao.core.thread import Thread

if TYPE_CHECKING:
from databao.core.cache import Cache
Expand Down Expand Up @@ -50,7 +50,7 @@ def __init__(
self.__visualizer = visualizer
self.__cache = cache

# Pipe/thread defaults
# Thread defaults
self.__rows_limit = rows_limit
self.__lazy_threads = lazy_threads
self.__auto_output_modality = auto_output_modality
Expand Down Expand Up @@ -134,11 +134,11 @@ def thread(
stream_plot: bool | None = None,
lazy: bool | None = None,
auto_output_modality: bool | None = None,
) -> Pipe:
) -> Thread:
"""Start a new thread in this agent."""
if not self.__dbs and not self.__dfs:
raise ValueError("No databases or dataframes registered in this agent.")
return Pipe(
return Thread(
self,
rows_limit=self.__rows_limit,
stream_ask=stream_ask if stream_ask is not None else self.__stream_ask,
Expand Down
2 changes: 1 addition & 1 deletion databao/core/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OutputModalityHints(BaseModel):
# Currently, the only modality that makes sense to request outside the Executor is visualization.
# If Executor was responsible for plotting as well (instead of Visualizer), then we could fully control and
# customize rendering in ExecutionResult._repr_mimebundle_.
# But now we need hints to tell Pipe how to handle plotting.
# But now we need hints to tell Thread how to handle plotting.

should_visualize: bool = False
"""Whether the execution results can be visualized."""
Expand Down
13 changes: 6 additions & 7 deletions databao/core/pipe.py → databao/core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from databao.core.visualizer import VisualisationResult


class Pipe:
class Thread:
"""A single conversational thread within an agent.

- Maintains its own message history (isolated from other pipes).
- Materializes data and visualizations eagerly or lazily and caches results per pipe.
- Maintains its own message history (isolated from other threads).
- Materializes data and visualizations eagerly or lazily and caches results per thread.
- Exposes helpers to get the latest dataframe/text/plot/code.
"""

Expand Down Expand Up @@ -53,7 +53,6 @@ def __init__(
self._visualization_result: VisualisationResult | None = None
self._visualization_request: str | None = None

# N.B. Pipes/Threads are currently append-only and cannot be "forked".
self._opas_processed_count = 0
self._opas: list[Opa] = []
self._meta: dict[str, Any] = {}
Expand Down Expand Up @@ -119,7 +118,7 @@ def code(self) -> str | None:
return self._materialize_data(self._data_materialized_rows).code

def meta(self) -> dict[str, Any]:
"""Aggregated metadata from executor/visualizer for this pipe."""
"""Aggregated metadata from executor/visualizer for this thread."""
self._materialize_data(self._data_materialized_rows)
return self._meta

Expand All @@ -146,9 +145,9 @@ def plot(
return self._materialize_visualization(request, rows_limit if rows_limit else self._data_materialized_rows)

def ask(self, query: str, *, rows_limit: int | None = None, stream: bool | None = None) -> Self:
"""Append a new user query to this pipe.
"""Append a new user query to this thread.

Returns self to allow chaining (e.g., pipe.ask("...")).
Returns self to allow chaining (e.g., thread.ask("...")).

Setting rows_limit has no effect in lazy mode.
"""
Expand Down