vanna 0.7.9__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vanna/__init__.py +167 -395
- vanna/agents/__init__.py +7 -0
- vanna/capabilities/__init__.py +17 -0
- vanna/capabilities/agent_memory/__init__.py +21 -0
- vanna/capabilities/agent_memory/base.py +103 -0
- vanna/capabilities/agent_memory/models.py +53 -0
- vanna/capabilities/file_system/__init__.py +14 -0
- vanna/capabilities/file_system/base.py +71 -0
- vanna/capabilities/file_system/models.py +25 -0
- vanna/capabilities/sql_runner/__init__.py +13 -0
- vanna/capabilities/sql_runner/base.py +37 -0
- vanna/capabilities/sql_runner/models.py +13 -0
- vanna/components/__init__.py +92 -0
- vanna/components/base.py +11 -0
- vanna/components/rich/__init__.py +83 -0
- vanna/components/rich/containers/__init__.py +7 -0
- vanna/components/rich/containers/card.py +20 -0
- vanna/components/rich/data/__init__.py +9 -0
- vanna/components/rich/data/chart.py +17 -0
- vanna/components/rich/data/dataframe.py +93 -0
- vanna/components/rich/feedback/__init__.py +21 -0
- vanna/components/rich/feedback/badge.py +16 -0
- vanna/components/rich/feedback/icon_text.py +14 -0
- vanna/components/rich/feedback/log_viewer.py +41 -0
- vanna/components/rich/feedback/notification.py +19 -0
- vanna/components/rich/feedback/progress.py +37 -0
- vanna/components/rich/feedback/status_card.py +28 -0
- vanna/components/rich/feedback/status_indicator.py +14 -0
- vanna/components/rich/interactive/__init__.py +21 -0
- vanna/components/rich/interactive/button.py +95 -0
- vanna/components/rich/interactive/task_list.py +58 -0
- vanna/components/rich/interactive/ui_state.py +93 -0
- vanna/components/rich/specialized/__init__.py +7 -0
- vanna/components/rich/specialized/artifact.py +20 -0
- vanna/components/rich/text.py +16 -0
- vanna/components/simple/__init__.py +15 -0
- vanna/components/simple/image.py +15 -0
- vanna/components/simple/link.py +15 -0
- vanna/components/simple/text.py +11 -0
- vanna/core/__init__.py +193 -0
- vanna/core/_compat.py +19 -0
- vanna/core/agent/__init__.py +10 -0
- vanna/core/agent/agent.py +1407 -0
- vanna/core/agent/config.py +123 -0
- vanna/core/audit/__init__.py +28 -0
- vanna/core/audit/base.py +299 -0
- vanna/core/audit/models.py +131 -0
- vanna/core/component_manager.py +329 -0
- vanna/core/components.py +53 -0
- vanna/core/enhancer/__init__.py +11 -0
- vanna/core/enhancer/base.py +94 -0
- vanna/core/enhancer/default.py +118 -0
- vanna/core/enricher/__init__.py +10 -0
- vanna/core/enricher/base.py +59 -0
- vanna/core/errors.py +47 -0
- vanna/core/evaluation/__init__.py +81 -0
- vanna/core/evaluation/base.py +186 -0
- vanna/core/evaluation/dataset.py +254 -0
- vanna/core/evaluation/evaluators.py +376 -0
- vanna/core/evaluation/report.py +289 -0
- vanna/core/evaluation/runner.py +313 -0
- vanna/core/filter/__init__.py +10 -0
- vanna/core/filter/base.py +67 -0
- vanna/core/lifecycle/__init__.py +10 -0
- vanna/core/lifecycle/base.py +83 -0
- vanna/core/llm/__init__.py +16 -0
- vanna/core/llm/base.py +40 -0
- vanna/core/llm/models.py +61 -0
- vanna/core/middleware/__init__.py +10 -0
- vanna/core/middleware/base.py +69 -0
- vanna/core/observability/__init__.py +11 -0
- vanna/core/observability/base.py +88 -0
- vanna/core/observability/models.py +47 -0
- vanna/core/recovery/__init__.py +11 -0
- vanna/core/recovery/base.py +84 -0
- vanna/core/recovery/models.py +32 -0
- vanna/core/registry.py +278 -0
- vanna/core/rich_component.py +156 -0
- vanna/core/simple_component.py +27 -0
- vanna/core/storage/__init__.py +14 -0
- vanna/core/storage/base.py +46 -0
- vanna/core/storage/models.py +46 -0
- vanna/core/system_prompt/__init__.py +13 -0
- vanna/core/system_prompt/base.py +36 -0
- vanna/core/system_prompt/default.py +157 -0
- vanna/core/tool/__init__.py +18 -0
- vanna/core/tool/base.py +70 -0
- vanna/core/tool/models.py +84 -0
- vanna/core/user/__init__.py +17 -0
- vanna/core/user/base.py +29 -0
- vanna/core/user/models.py +25 -0
- vanna/core/user/request_context.py +70 -0
- vanna/core/user/resolver.py +42 -0
- vanna/core/validation.py +164 -0
- vanna/core/workflow/__init__.py +12 -0
- vanna/core/workflow/base.py +254 -0
- vanna/core/workflow/default.py +789 -0
- vanna/examples/__init__.py +1 -0
- vanna/examples/__main__.py +44 -0
- vanna/examples/anthropic_quickstart.py +80 -0
- vanna/examples/artifact_example.py +293 -0
- vanna/examples/claude_sqlite_example.py +236 -0
- vanna/examples/coding_agent_example.py +300 -0
- vanna/examples/custom_system_prompt_example.py +174 -0
- vanna/examples/default_workflow_handler_example.py +208 -0
- vanna/examples/email_auth_example.py +340 -0
- vanna/examples/evaluation_example.py +269 -0
- vanna/examples/extensibility_example.py +262 -0
- vanna/examples/minimal_example.py +67 -0
- vanna/examples/mock_auth_example.py +227 -0
- vanna/examples/mock_custom_tool.py +311 -0
- vanna/examples/mock_quickstart.py +79 -0
- vanna/examples/mock_quota_example.py +145 -0
- vanna/examples/mock_rich_components_demo.py +396 -0
- vanna/examples/mock_sqlite_example.py +223 -0
- vanna/examples/openai_quickstart.py +83 -0
- vanna/examples/primitive_components_demo.py +305 -0
- vanna/examples/quota_lifecycle_example.py +139 -0
- vanna/examples/visualization_example.py +251 -0
- vanna/integrations/__init__.py +17 -0
- vanna/integrations/anthropic/__init__.py +9 -0
- vanna/integrations/anthropic/llm.py +270 -0
- vanna/integrations/azureopenai/__init__.py +9 -0
- vanna/integrations/azureopenai/llm.py +329 -0
- vanna/integrations/azuresearch/__init__.py +7 -0
- vanna/integrations/azuresearch/agent_memory.py +413 -0
- vanna/integrations/bigquery/__init__.py +5 -0
- vanna/integrations/bigquery/sql_runner.py +81 -0
- vanna/integrations/chromadb/__init__.py +104 -0
- vanna/integrations/chromadb/agent_memory.py +416 -0
- vanna/integrations/clickhouse/__init__.py +5 -0
- vanna/integrations/clickhouse/sql_runner.py +82 -0
- vanna/integrations/duckdb/__init__.py +5 -0
- vanna/integrations/duckdb/sql_runner.py +65 -0
- vanna/integrations/faiss/__init__.py +7 -0
- vanna/integrations/faiss/agent_memory.py +431 -0
- vanna/integrations/google/__init__.py +9 -0
- vanna/integrations/google/gemini.py +370 -0
- vanna/integrations/hive/__init__.py +5 -0
- vanna/integrations/hive/sql_runner.py +87 -0
- vanna/integrations/local/__init__.py +17 -0
- vanna/integrations/local/agent_memory/__init__.py +7 -0
- vanna/integrations/local/agent_memory/in_memory.py +285 -0
- vanna/integrations/local/audit.py +59 -0
- vanna/integrations/local/file_system.py +242 -0
- vanna/integrations/local/file_system_conversation_store.py +255 -0
- vanna/integrations/local/storage.py +62 -0
- vanna/integrations/marqo/__init__.py +7 -0
- vanna/integrations/marqo/agent_memory.py +354 -0
- vanna/integrations/milvus/__init__.py +7 -0
- vanna/integrations/milvus/agent_memory.py +458 -0
- vanna/integrations/mock/__init__.py +9 -0
- vanna/integrations/mock/llm.py +65 -0
- vanna/integrations/mssql/__init__.py +5 -0
- vanna/integrations/mssql/sql_runner.py +66 -0
- vanna/integrations/mysql/__init__.py +5 -0
- vanna/integrations/mysql/sql_runner.py +92 -0
- vanna/integrations/ollama/__init__.py +7 -0
- vanna/integrations/ollama/llm.py +252 -0
- vanna/integrations/openai/__init__.py +10 -0
- vanna/integrations/openai/llm.py +267 -0
- vanna/integrations/openai/responses.py +163 -0
- vanna/integrations/opensearch/__init__.py +7 -0
- vanna/integrations/opensearch/agent_memory.py +411 -0
- vanna/integrations/oracle/__init__.py +5 -0
- vanna/integrations/oracle/sql_runner.py +75 -0
- vanna/integrations/pinecone/__init__.py +7 -0
- vanna/integrations/pinecone/agent_memory.py +329 -0
- vanna/integrations/plotly/__init__.py +5 -0
- vanna/integrations/plotly/chart_generator.py +313 -0
- vanna/integrations/postgres/__init__.py +9 -0
- vanna/integrations/postgres/sql_runner.py +112 -0
- vanna/integrations/premium/agent_memory/__init__.py +7 -0
- vanna/integrations/premium/agent_memory/premium.py +186 -0
- vanna/integrations/presto/__init__.py +5 -0
- vanna/integrations/presto/sql_runner.py +107 -0
- vanna/integrations/qdrant/__init__.py +7 -0
- vanna/integrations/qdrant/agent_memory.py +461 -0
- vanna/integrations/snowflake/__init__.py +5 -0
- vanna/integrations/snowflake/sql_runner.py +147 -0
- vanna/integrations/sqlite/__init__.py +9 -0
- vanna/integrations/sqlite/sql_runner.py +65 -0
- vanna/integrations/weaviate/__init__.py +7 -0
- vanna/integrations/weaviate/agent_memory.py +428 -0
- vanna/{ZhipuAI → legacy/ZhipuAI}/ZhipuAI_embeddings.py +11 -11
- vanna/legacy/__init__.py +403 -0
- vanna/legacy/adapter.py +463 -0
- vanna/{advanced → legacy/advanced}/__init__.py +3 -1
- vanna/{anthropic → legacy/anthropic}/anthropic_chat.py +9 -7
- vanna/{azuresearch → legacy/azuresearch}/azuresearch_vector.py +79 -41
- vanna/{base → legacy/base}/base.py +224 -217
- vanna/legacy/bedrock/__init__.py +1 -0
- vanna/{bedrock → legacy/bedrock}/bedrock_converse.py +13 -12
- vanna/{chromadb → legacy/chromadb}/chromadb_vector.py +3 -1
- vanna/legacy/cohere/__init__.py +2 -0
- vanna/{cohere → legacy/cohere}/cohere_chat.py +19 -14
- vanna/{cohere → legacy/cohere}/cohere_embeddings.py +25 -19
- vanna/{deepseek → legacy/deepseek}/deepseek_chat.py +5 -6
- vanna/legacy/faiss/__init__.py +1 -0
- vanna/{faiss → legacy/faiss}/faiss.py +113 -59
- vanna/{flask → legacy/flask}/__init__.py +84 -43
- vanna/{flask → legacy/flask}/assets.py +5 -5
- vanna/{flask → legacy/flask}/auth.py +5 -4
- vanna/{google → legacy/google}/bigquery_vector.py +75 -42
- vanna/{google → legacy/google}/gemini_chat.py +7 -3
- vanna/{hf → legacy/hf}/hf.py +0 -1
- vanna/{milvus → legacy/milvus}/milvus_vector.py +58 -35
- vanna/{mock → legacy/mock}/llm.py +0 -1
- vanna/legacy/mock/vectordb.py +67 -0
- vanna/legacy/ollama/ollama.py +110 -0
- vanna/{openai → legacy/openai}/openai_chat.py +2 -6
- vanna/legacy/opensearch/opensearch_vector.py +369 -0
- vanna/legacy/opensearch/opensearch_vector_semantic.py +200 -0
- vanna/legacy/oracle/oracle_vector.py +584 -0
- vanna/{pgvector → legacy/pgvector}/pgvector.py +42 -13
- vanna/{qdrant → legacy/qdrant}/qdrant.py +2 -6
- vanna/legacy/qianfan/Qianfan_Chat.py +170 -0
- vanna/legacy/qianfan/Qianfan_embeddings.py +36 -0
- vanna/legacy/qianwen/QianwenAI_chat.py +132 -0
- vanna/{remote.py → legacy/remote.py} +28 -26
- vanna/{utils.py → legacy/utils.py} +6 -11
- vanna/{vannadb → legacy/vannadb}/vannadb_vector.py +115 -46
- vanna/{vllm → legacy/vllm}/vllm.py +5 -6
- vanna/{weaviate → legacy/weaviate}/weaviate_vector.py +59 -40
- vanna/{xinference → legacy/xinference}/xinference.py +6 -6
- vanna/py.typed +0 -0
- vanna/servers/__init__.py +16 -0
- vanna/servers/__main__.py +8 -0
- vanna/servers/base/__init__.py +18 -0
- vanna/servers/base/chat_handler.py +65 -0
- vanna/servers/base/models.py +111 -0
- vanna/servers/base/rich_chat_handler.py +141 -0
- vanna/servers/base/templates.py +331 -0
- vanna/servers/cli/__init__.py +7 -0
- vanna/servers/cli/server_runner.py +204 -0
- vanna/servers/fastapi/__init__.py +7 -0
- vanna/servers/fastapi/app.py +163 -0
- vanna/servers/fastapi/routes.py +183 -0
- vanna/servers/flask/__init__.py +7 -0
- vanna/servers/flask/app.py +132 -0
- vanna/servers/flask/routes.py +137 -0
- vanna/tools/__init__.py +41 -0
- vanna/tools/agent_memory.py +322 -0
- vanna/tools/file_system.py +879 -0
- vanna/tools/python.py +222 -0
- vanna/tools/run_sql.py +165 -0
- vanna/tools/visualize_data.py +195 -0
- vanna/utils/__init__.py +0 -0
- vanna/web_components/__init__.py +44 -0
- vanna-2.0.0.dist-info/METADATA +485 -0
- vanna-2.0.0.dist-info/RECORD +289 -0
- vanna-2.0.0.dist-info/entry_points.txt +3 -0
- vanna/bedrock/__init__.py +0 -1
- vanna/cohere/__init__.py +0 -2
- vanna/faiss/__init__.py +0 -1
- vanna/mock/vectordb.py +0 -55
- vanna/ollama/ollama.py +0 -103
- vanna/opensearch/opensearch_vector.py +0 -392
- vanna/opensearch/opensearch_vector_semantic.py +0 -175
- vanna/oracle/oracle_vector.py +0 -585
- vanna/qianfan/Qianfan_Chat.py +0 -165
- vanna/qianfan/Qianfan_embeddings.py +0 -36
- vanna/qianwen/QianwenAI_chat.py +0 -133
- vanna-0.7.9.dist-info/METADATA +0 -408
- vanna-0.7.9.dist-info/RECORD +0 -79
- /vanna/{ZhipuAI → legacy/ZhipuAI}/ZhipuAI_Chat.py +0 -0
- /vanna/{ZhipuAI → legacy/ZhipuAI}/__init__.py +0 -0
- /vanna/{anthropic → legacy/anthropic}/__init__.py +0 -0
- /vanna/{azuresearch → legacy/azuresearch}/__init__.py +0 -0
- /vanna/{base → legacy/base}/__init__.py +0 -0
- /vanna/{chromadb → legacy/chromadb}/__init__.py +0 -0
- /vanna/{deepseek → legacy/deepseek}/__init__.py +0 -0
- /vanna/{exceptions → legacy/exceptions}/__init__.py +0 -0
- /vanna/{google → legacy/google}/__init__.py +0 -0
- /vanna/{hf → legacy/hf}/__init__.py +0 -0
- /vanna/{local.py → legacy/local.py} +0 -0
- /vanna/{marqo → legacy/marqo}/__init__.py +0 -0
- /vanna/{marqo → legacy/marqo}/marqo.py +0 -0
- /vanna/{milvus → legacy/milvus}/__init__.py +0 -0
- /vanna/{mistral → legacy/mistral}/__init__.py +0 -0
- /vanna/{mistral → legacy/mistral}/mistral.py +0 -0
- /vanna/{mock → legacy/mock}/__init__.py +0 -0
- /vanna/{mock → legacy/mock}/embedding.py +0 -0
- /vanna/{ollama → legacy/ollama}/__init__.py +0 -0
- /vanna/{openai → legacy/openai}/__init__.py +0 -0
- /vanna/{openai → legacy/openai}/openai_embeddings.py +0 -0
- /vanna/{opensearch → legacy/opensearch}/__init__.py +0 -0
- /vanna/{oracle → legacy/oracle}/__init__.py +0 -0
- /vanna/{pgvector → legacy/pgvector}/__init__.py +0 -0
- /vanna/{pinecone → legacy/pinecone}/__init__.py +0 -0
- /vanna/{pinecone → legacy/pinecone}/pinecone_vector.py +0 -0
- /vanna/{qdrant → legacy/qdrant}/__init__.py +0 -0
- /vanna/{qianfan → legacy/qianfan}/__init__.py +0 -0
- /vanna/{qianwen → legacy/qianwen}/QianwenAI_embeddings.py +0 -0
- /vanna/{qianwen → legacy/qianwen}/__init__.py +0 -0
- /vanna/{types → legacy/types}/__init__.py +0 -0
- /vanna/{vannadb → legacy/vannadb}/__init__.py +0 -0
- /vanna/{vllm → legacy/vllm}/__init__.py +0 -0
- /vanna/{weaviate → legacy/weaviate}/__init__.py +0 -0
- /vanna/{xinference → legacy/xinference}/__init__.py +0 -0
- {vanna-0.7.9.dist-info → vanna-2.0.0.dist-info}/WHEEL +0 -0
- {vanna-0.7.9.dist-info → vanna-2.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent memory capability interface for tool usage learning.
|
|
3
|
+
|
|
4
|
+
This module contains the abstract base class for agent memory operations,
|
|
5
|
+
following the same pattern as the FileSystem interface.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from abc import ABC, abstractmethod
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from vanna.core.tool import ToolContext
|
|
15
|
+
from .models import (
|
|
16
|
+
ToolMemorySearchResult,
|
|
17
|
+
TextMemory,
|
|
18
|
+
TextMemorySearchResult,
|
|
19
|
+
ToolMemory,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AgentMemory(ABC):
|
|
24
|
+
"""Abstract base class for agent memory operations."""
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
async def save_tool_usage(
|
|
28
|
+
self,
|
|
29
|
+
question: str,
|
|
30
|
+
tool_name: str,
|
|
31
|
+
args: Dict[str, Any],
|
|
32
|
+
context: "ToolContext",
|
|
33
|
+
success: bool = True,
|
|
34
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Save a tool usage pattern for future reference."""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
async def save_text_memory(
|
|
41
|
+
self, content: str, context: "ToolContext"
|
|
42
|
+
) -> "TextMemory":
|
|
43
|
+
"""Save a free-form text memory."""
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
async def search_similar_usage(
|
|
48
|
+
self,
|
|
49
|
+
question: str,
|
|
50
|
+
context: "ToolContext",
|
|
51
|
+
*,
|
|
52
|
+
limit: int = 10,
|
|
53
|
+
similarity_threshold: float = 0.7,
|
|
54
|
+
tool_name_filter: Optional[str] = None,
|
|
55
|
+
) -> List[ToolMemorySearchResult]:
|
|
56
|
+
"""Search for similar tool usage patterns based on a question."""
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
async def search_text_memories(
|
|
61
|
+
self,
|
|
62
|
+
query: str,
|
|
63
|
+
context: "ToolContext",
|
|
64
|
+
*,
|
|
65
|
+
limit: int = 10,
|
|
66
|
+
similarity_threshold: float = 0.7,
|
|
67
|
+
) -> List["TextMemorySearchResult"]:
|
|
68
|
+
"""Search stored text memories based on a query."""
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
async def get_recent_memories(
|
|
73
|
+
self, context: "ToolContext", limit: int = 10
|
|
74
|
+
) -> List[ToolMemory]:
|
|
75
|
+
"""Get recently added memories. Returns most recent memories first."""
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
@abstractmethod
|
|
79
|
+
async def get_recent_text_memories(
|
|
80
|
+
self, context: "ToolContext", limit: int = 10
|
|
81
|
+
) -> List["TextMemory"]:
|
|
82
|
+
"""Fetch recently stored text memories."""
|
|
83
|
+
pass
|
|
84
|
+
|
|
85
|
+
@abstractmethod
|
|
86
|
+
async def delete_by_id(self, context: "ToolContext", memory_id: str) -> bool:
|
|
87
|
+
"""Delete a memory by its ID. Returns True if deleted, False if not found."""
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
@abstractmethod
|
|
91
|
+
async def delete_text_memory(self, context: "ToolContext", memory_id: str) -> bool:
|
|
92
|
+
"""Delete a text memory by its ID. Returns True if deleted, False if not found."""
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
async def clear_memories(
|
|
97
|
+
self,
|
|
98
|
+
context: "ToolContext",
|
|
99
|
+
tool_name: Optional[str] = None,
|
|
100
|
+
before_date: Optional[str] = None,
|
|
101
|
+
) -> int:
|
|
102
|
+
"""Clear stored memories (tool or text). Returns number of memories deleted."""
|
|
103
|
+
pass
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Memory storage models and types.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ToolMemory(BaseModel):
|
|
11
|
+
"""Represents a stored tool usage memory."""
|
|
12
|
+
|
|
13
|
+
memory_id: Optional[str] = None
|
|
14
|
+
question: str
|
|
15
|
+
tool_name: str
|
|
16
|
+
args: Dict[str, Any]
|
|
17
|
+
timestamp: Optional[str] = None
|
|
18
|
+
success: bool = True
|
|
19
|
+
metadata: Optional[Dict[str, Any]] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TextMemory(BaseModel):
|
|
23
|
+
"""Represents a stored free-form text memory."""
|
|
24
|
+
|
|
25
|
+
memory_id: Optional[str] = None
|
|
26
|
+
content: str
|
|
27
|
+
timestamp: Optional[str] = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ToolMemorySearchResult(BaseModel):
|
|
31
|
+
"""Represents a search result from tool memory storage."""
|
|
32
|
+
|
|
33
|
+
memory: ToolMemory
|
|
34
|
+
similarity_score: float
|
|
35
|
+
rank: int
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TextMemorySearchResult(BaseModel):
|
|
39
|
+
"""Represents a search result from text memory storage."""
|
|
40
|
+
|
|
41
|
+
memory: TextMemory
|
|
42
|
+
similarity_score: float
|
|
43
|
+
rank: int
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class MemoryStats(BaseModel):
|
|
47
|
+
"""Memory storage statistics."""
|
|
48
|
+
|
|
49
|
+
total_memories: int
|
|
50
|
+
unique_tools: int
|
|
51
|
+
unique_questions: int
|
|
52
|
+
success_rate: float
|
|
53
|
+
most_used_tools: Dict[str, int]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File system capability.
|
|
3
|
+
|
|
4
|
+
This module provides abstractions for file system operations used by tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .base import FileSystem
|
|
8
|
+
from .models import CommandResult, FileSearchMatch
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"FileSystem",
|
|
12
|
+
"FileSearchMatch",
|
|
13
|
+
"CommandResult",
|
|
14
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File system capability interface.
|
|
3
|
+
|
|
4
|
+
This module contains the abstract base class for file system operations.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import TYPE_CHECKING, List, Optional
|
|
9
|
+
|
|
10
|
+
from .models import CommandResult, FileSearchMatch
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from vanna.core.tool import ToolContext
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FileSystem(ABC):
|
|
17
|
+
"""Abstract base class for file system operations."""
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
async def list_files(self, directory: str, context: "ToolContext") -> List[str]:
|
|
21
|
+
"""List files in a directory."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
async def read_file(self, filename: str, context: "ToolContext") -> str:
|
|
26
|
+
"""Read the contents of a file."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
async def write_file(
|
|
31
|
+
self,
|
|
32
|
+
filename: str,
|
|
33
|
+
content: str,
|
|
34
|
+
context: "ToolContext",
|
|
35
|
+
overwrite: bool = False,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Write content to a file."""
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
@abstractmethod
|
|
41
|
+
async def exists(self, path: str, context: "ToolContext") -> bool:
|
|
42
|
+
"""Check if a file or directory exists."""
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
@abstractmethod
|
|
46
|
+
async def is_directory(self, path: str, context: "ToolContext") -> bool:
|
|
47
|
+
"""Check if a path is a directory."""
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
@abstractmethod
|
|
51
|
+
async def search_files(
|
|
52
|
+
self,
|
|
53
|
+
query: str,
|
|
54
|
+
context: "ToolContext",
|
|
55
|
+
*,
|
|
56
|
+
max_results: int = 20,
|
|
57
|
+
include_content: bool = False,
|
|
58
|
+
) -> List[FileSearchMatch]:
|
|
59
|
+
"""Search for files matching a query within the accessible namespace."""
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
@abstractmethod
|
|
63
|
+
async def run_bash(
|
|
64
|
+
self,
|
|
65
|
+
command: str,
|
|
66
|
+
context: "ToolContext",
|
|
67
|
+
*,
|
|
68
|
+
timeout: Optional[float] = None,
|
|
69
|
+
) -> CommandResult:
|
|
70
|
+
"""Execute a bash command within the accessible namespace."""
|
|
71
|
+
pass
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File system capability models.
|
|
3
|
+
|
|
4
|
+
This module contains data models for file system operations.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class FileSearchMatch:
|
|
13
|
+
"""Represents a single search result within a file system."""
|
|
14
|
+
|
|
15
|
+
path: str
|
|
16
|
+
snippet: Optional[str] = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class CommandResult:
|
|
21
|
+
"""Represents the result of executing a shell command."""
|
|
22
|
+
|
|
23
|
+
stdout: str
|
|
24
|
+
stderr: str
|
|
25
|
+
returncode: int
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SQL runner capability interface.
|
|
3
|
+
|
|
4
|
+
This module contains the abstract base class for SQL execution.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
import pandas as pd
|
|
11
|
+
|
|
12
|
+
from .models import RunSqlToolArgs
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from vanna.core.tool import ToolContext
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SqlRunner(ABC):
|
|
19
|
+
"""Interface for SQL execution with different implementations."""
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
async def run_sql(
|
|
23
|
+
self, args: RunSqlToolArgs, context: "ToolContext"
|
|
24
|
+
) -> pd.DataFrame:
|
|
25
|
+
"""Execute SQL query and return results as a DataFrame.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
args: SQL query arguments
|
|
29
|
+
context: Tool execution context
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
DataFrame with query results
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
Exception: If query execution fails
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SQL runner capability models.
|
|
3
|
+
|
|
4
|
+
This module contains data models for SQL execution.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RunSqlToolArgs(BaseModel):
|
|
11
|
+
"""Arguments for run_sql tool."""
|
|
12
|
+
|
|
13
|
+
sql: str = Field(description="SQL query to execute")
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""UI Component system for Vanna Agents."""
|
|
2
|
+
|
|
3
|
+
# Base component
|
|
4
|
+
from .base import UiComponent
|
|
5
|
+
|
|
6
|
+
# Simple components
|
|
7
|
+
from .simple import (
|
|
8
|
+
SimpleComponent,
|
|
9
|
+
SimpleComponentType,
|
|
10
|
+
SimpleTextComponent,
|
|
11
|
+
SimpleImageComponent,
|
|
12
|
+
SimpleLinkComponent,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Rich components - re-export all
|
|
16
|
+
from .rich import (
|
|
17
|
+
# Base
|
|
18
|
+
RichComponent,
|
|
19
|
+
ComponentType,
|
|
20
|
+
ComponentLifecycle,
|
|
21
|
+
# Text
|
|
22
|
+
RichTextComponent,
|
|
23
|
+
# Data
|
|
24
|
+
DataFrameComponent,
|
|
25
|
+
ChartComponent,
|
|
26
|
+
# Feedback
|
|
27
|
+
NotificationComponent,
|
|
28
|
+
StatusCardComponent,
|
|
29
|
+
ProgressBarComponent,
|
|
30
|
+
ProgressDisplayComponent,
|
|
31
|
+
StatusIndicatorComponent,
|
|
32
|
+
LogViewerComponent,
|
|
33
|
+
LogEntry,
|
|
34
|
+
BadgeComponent,
|
|
35
|
+
IconTextComponent,
|
|
36
|
+
# Interactive
|
|
37
|
+
TaskListComponent,
|
|
38
|
+
Task,
|
|
39
|
+
StatusBarUpdateComponent,
|
|
40
|
+
TaskTrackerUpdateComponent,
|
|
41
|
+
ChatInputUpdateComponent,
|
|
42
|
+
TaskOperation,
|
|
43
|
+
ButtonComponent,
|
|
44
|
+
ButtonGroupComponent,
|
|
45
|
+
# Containers
|
|
46
|
+
CardComponent,
|
|
47
|
+
# Specialized
|
|
48
|
+
ArtifactComponent,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
# Base
|
|
53
|
+
"UiComponent",
|
|
54
|
+
# Simple components
|
|
55
|
+
"SimpleComponent",
|
|
56
|
+
"SimpleComponentType",
|
|
57
|
+
"SimpleTextComponent",
|
|
58
|
+
"SimpleImageComponent",
|
|
59
|
+
"SimpleLinkComponent",
|
|
60
|
+
# Rich components - Base
|
|
61
|
+
"RichComponent",
|
|
62
|
+
"ComponentType",
|
|
63
|
+
"ComponentLifecycle",
|
|
64
|
+
# Rich components - Text
|
|
65
|
+
"RichTextComponent",
|
|
66
|
+
# Rich components - Data
|
|
67
|
+
"DataFrameComponent",
|
|
68
|
+
"ChartComponent",
|
|
69
|
+
# Rich components - Feedback
|
|
70
|
+
"NotificationComponent",
|
|
71
|
+
"StatusCardComponent",
|
|
72
|
+
"ProgressBarComponent",
|
|
73
|
+
"ProgressDisplayComponent",
|
|
74
|
+
"StatusIndicatorComponent",
|
|
75
|
+
"LogViewerComponent",
|
|
76
|
+
"LogEntry",
|
|
77
|
+
"BadgeComponent",
|
|
78
|
+
"IconTextComponent",
|
|
79
|
+
# Rich components - Interactive
|
|
80
|
+
"TaskListComponent",
|
|
81
|
+
"Task",
|
|
82
|
+
"StatusBarUpdateComponent",
|
|
83
|
+
"TaskTrackerUpdateComponent",
|
|
84
|
+
"ChatInputUpdateComponent",
|
|
85
|
+
"TaskOperation",
|
|
86
|
+
"ButtonComponent",
|
|
87
|
+
"ButtonGroupComponent",
|
|
88
|
+
# Rich components - Containers
|
|
89
|
+
"CardComponent",
|
|
90
|
+
# Rich components - Specialized
|
|
91
|
+
"ArtifactComponent",
|
|
92
|
+
]
|
vanna/components/base.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
UI components base - re-exports UiComponent from core.
|
|
3
|
+
|
|
4
|
+
UiComponent lives in core/ because it's a fundamental return type for tools.
|
|
5
|
+
This module provides backward compatibility by re-exporting it here.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Re-export UiComponent from core for backward compatibility
|
|
9
|
+
from ..core.components import UiComponent
|
|
10
|
+
|
|
11
|
+
__all__ = ["UiComponent"]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Rich UI components for the Vanna Agents framework."""
|
|
2
|
+
|
|
3
|
+
# Base classes and enums - import from core
|
|
4
|
+
from ...core.rich_component import RichComponent, ComponentType, ComponentLifecycle
|
|
5
|
+
|
|
6
|
+
# Text component
|
|
7
|
+
from .text import RichTextComponent
|
|
8
|
+
|
|
9
|
+
# Data components
|
|
10
|
+
from .data import (
|
|
11
|
+
DataFrameComponent,
|
|
12
|
+
ChartComponent,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Feedback components
|
|
16
|
+
from .feedback import (
|
|
17
|
+
NotificationComponent,
|
|
18
|
+
StatusCardComponent,
|
|
19
|
+
ProgressBarComponent,
|
|
20
|
+
ProgressDisplayComponent,
|
|
21
|
+
StatusIndicatorComponent,
|
|
22
|
+
LogViewerComponent,
|
|
23
|
+
LogEntry,
|
|
24
|
+
BadgeComponent,
|
|
25
|
+
IconTextComponent,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Interactive components
|
|
29
|
+
from .interactive import (
|
|
30
|
+
TaskListComponent,
|
|
31
|
+
Task,
|
|
32
|
+
StatusBarUpdateComponent,
|
|
33
|
+
TaskTrackerUpdateComponent,
|
|
34
|
+
ChatInputUpdateComponent,
|
|
35
|
+
TaskOperation,
|
|
36
|
+
ButtonComponent,
|
|
37
|
+
ButtonGroupComponent,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Container components
|
|
41
|
+
from .containers import (
|
|
42
|
+
CardComponent,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Specialized components
|
|
46
|
+
from .specialized import (
|
|
47
|
+
ArtifactComponent,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
__all__ = [
|
|
51
|
+
# Base
|
|
52
|
+
"RichComponent",
|
|
53
|
+
"ComponentType",
|
|
54
|
+
"ComponentLifecycle",
|
|
55
|
+
# Text
|
|
56
|
+
"RichTextComponent",
|
|
57
|
+
# Data
|
|
58
|
+
"DataFrameComponent",
|
|
59
|
+
"ChartComponent",
|
|
60
|
+
# Feedback
|
|
61
|
+
"NotificationComponent",
|
|
62
|
+
"StatusCardComponent",
|
|
63
|
+
"ProgressBarComponent",
|
|
64
|
+
"ProgressDisplayComponent",
|
|
65
|
+
"StatusIndicatorComponent",
|
|
66
|
+
"LogViewerComponent",
|
|
67
|
+
"LogEntry",
|
|
68
|
+
"BadgeComponent",
|
|
69
|
+
"IconTextComponent",
|
|
70
|
+
# Interactive
|
|
71
|
+
"TaskListComponent",
|
|
72
|
+
"Task",
|
|
73
|
+
"StatusBarUpdateComponent",
|
|
74
|
+
"TaskTrackerUpdateComponent",
|
|
75
|
+
"ChatInputUpdateComponent",
|
|
76
|
+
"TaskOperation",
|
|
77
|
+
"ButtonComponent",
|
|
78
|
+
"ButtonGroupComponent",
|
|
79
|
+
# Containers
|
|
80
|
+
"CardComponent",
|
|
81
|
+
# Specialized
|
|
82
|
+
"ArtifactComponent",
|
|
83
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Card component for displaying structured information."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
from ....core.rich_component import RichComponent, ComponentType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CardComponent(RichComponent):
|
|
9
|
+
"""Card component for displaying structured information."""
|
|
10
|
+
|
|
11
|
+
type: ComponentType = ComponentType.CARD
|
|
12
|
+
title: str
|
|
13
|
+
content: str
|
|
14
|
+
subtitle: Optional[str] = None
|
|
15
|
+
icon: Optional[str] = None
|
|
16
|
+
status: Optional[str] = None # "success", "warning", "error", "info"
|
|
17
|
+
actions: List[Dict[str, Any]] = Field(default_factory=list)
|
|
18
|
+
collapsible: bool = False
|
|
19
|
+
collapsed: bool = False
|
|
20
|
+
markdown: bool = False # Whether content should be rendered as markdown
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Chart component for data visualization."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Optional, Union
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
from ....core.rich_component import RichComponent, ComponentType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ChartComponent(RichComponent):
|
|
9
|
+
"""Chart component for data visualization."""
|
|
10
|
+
|
|
11
|
+
type: ComponentType = ComponentType.CHART
|
|
12
|
+
chart_type: str # "line", "bar", "pie", "scatter", etc.
|
|
13
|
+
data: Dict[str, Any] # Chart data in format expected by frontend
|
|
14
|
+
title: Optional[str] = None
|
|
15
|
+
width: Optional[Union[str, int]] = None
|
|
16
|
+
height: Optional[Union[str, int]] = None
|
|
17
|
+
config: Dict[str, Any] = Field(default_factory=dict) # Chart-specific config
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""DataFrame component for displaying tabular data."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
from ....core.rich_component import RichComponent, ComponentType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DataFrameComponent(RichComponent):
|
|
9
|
+
"""DataFrame component specifically for displaying tabular data from SQL queries and similar sources."""
|
|
10
|
+
|
|
11
|
+
type: ComponentType = ComponentType.DATAFRAME
|
|
12
|
+
rows: List[Dict[str, Any]] = Field(default_factory=list) # List of row dictionaries
|
|
13
|
+
columns: List[str] = Field(default_factory=list) # Column names in display order
|
|
14
|
+
title: Optional[str] = None
|
|
15
|
+
description: Optional[str] = None
|
|
16
|
+
row_count: int = 0
|
|
17
|
+
column_count: int = 0
|
|
18
|
+
|
|
19
|
+
# Display options
|
|
20
|
+
max_rows_displayed: int = 100 # Limit rows shown in UI
|
|
21
|
+
searchable: bool = True
|
|
22
|
+
sortable: bool = True
|
|
23
|
+
filterable: bool = True
|
|
24
|
+
exportable: bool = True # Allow export to CSV/Excel
|
|
25
|
+
|
|
26
|
+
# Styling options
|
|
27
|
+
striped: bool = True
|
|
28
|
+
bordered: bool = True
|
|
29
|
+
compact: bool = False
|
|
30
|
+
|
|
31
|
+
# Pagination
|
|
32
|
+
paginated: bool = True
|
|
33
|
+
page_size: int = 25
|
|
34
|
+
|
|
35
|
+
# Data types for better formatting (optional)
|
|
36
|
+
column_types: Dict[str, str] = Field(
|
|
37
|
+
default_factory=dict
|
|
38
|
+
) # column_name -> "string"|"number"|"date"|"boolean"
|
|
39
|
+
|
|
40
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
41
|
+
# Set defaults before calling super().__init__
|
|
42
|
+
if "rows" not in kwargs:
|
|
43
|
+
kwargs["rows"] = []
|
|
44
|
+
if "columns" not in kwargs:
|
|
45
|
+
kwargs["columns"] = []
|
|
46
|
+
if "column_types" not in kwargs:
|
|
47
|
+
kwargs["column_types"] = {}
|
|
48
|
+
|
|
49
|
+
super().__init__(**kwargs)
|
|
50
|
+
|
|
51
|
+
# Auto-calculate counts if not provided
|
|
52
|
+
if self.rows and len(self.rows) > 0:
|
|
53
|
+
if "row_count" not in kwargs:
|
|
54
|
+
self.row_count = len(self.rows)
|
|
55
|
+
if not self.columns and self.rows:
|
|
56
|
+
self.columns = list(self.rows[0].keys())
|
|
57
|
+
if "column_count" not in kwargs:
|
|
58
|
+
self.column_count = len(self.columns)
|
|
59
|
+
else:
|
|
60
|
+
if "row_count" not in kwargs:
|
|
61
|
+
self.row_count = 0
|
|
62
|
+
if "column_count" not in kwargs:
|
|
63
|
+
self.column_count = len(self.columns) if self.columns else 0
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def from_records(
|
|
67
|
+
cls,
|
|
68
|
+
records: List[Dict[str, Any]],
|
|
69
|
+
title: Optional[str] = None,
|
|
70
|
+
description: Optional[str] = None,
|
|
71
|
+
**kwargs: Any,
|
|
72
|
+
) -> "DataFrameComponent":
|
|
73
|
+
"""Create a DataFrame component from a list of record dictionaries."""
|
|
74
|
+
columns = list(records[0].keys()) if records else []
|
|
75
|
+
|
|
76
|
+
# Ensure we pass the required arguments correctly
|
|
77
|
+
component_data = {
|
|
78
|
+
"rows": records,
|
|
79
|
+
"columns": columns,
|
|
80
|
+
"row_count": len(records),
|
|
81
|
+
"column_count": len(columns),
|
|
82
|
+
"column_types": {}, # Initialize empty dict
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if title is not None:
|
|
86
|
+
component_data["title"] = title
|
|
87
|
+
if description is not None:
|
|
88
|
+
component_data["description"] = description
|
|
89
|
+
|
|
90
|
+
# Merge with any additional kwargs
|
|
91
|
+
component_data.update(kwargs)
|
|
92
|
+
|
|
93
|
+
return cls(**component_data)
|