databao-context-engine 0.1.3__tar.gz → 0.1.4.dev1__tar.gz
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.
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/PKG-INFO +2 -2
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/pyproject.toml +2 -2
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/plugin_execution.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/cli/info.py +1 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/introspection/property_extract.py +10 -25
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/mcp/mcp_server.py +10 -7
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/base_db_plugin.py +5 -2
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/athena_introspector.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/clickhouse_introspector.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/duckdb_introspector.py +2 -4
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/mssql_introspector.py +2 -2
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/mysql_introspector.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/snowflake_introspector.py +1 -1
- databao_context_engine-0.1.4.dev1/src/databao_context_engine/plugins/duckdb_tools.py +18 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/resources/parquet_introspector.py +5 -16
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/info.py +3 -0
- databao_context_engine-0.1.3/src/databao_context_engine/mcp/all_results_tool.py +0 -5
- databao_context_engine-0.1.3/src/databao_context_engine/mcp/retrieve_tool.py +0 -14
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/README.md +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/build_runner.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/build_service.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/build_wiring.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/build_sources/export_results.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/cli/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/cli/add_datasource_config.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/cli/commands.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/cli/datasources.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/config/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/config/log_config.yaml +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/config/logging.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/databao_context_engine.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/databao_context_project_manager.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/add_config.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/check_config.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/datasource_context.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/datasource_discovery.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/datasources/types.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/event_journal/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/event_journal/writer.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/generate_configs_schemas.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/init_project.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/introspection/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/config.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/descriptions/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/descriptions/ollama.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/descriptions/provider.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/embeddings/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/embeddings/ollama.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/embeddings/provider.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/errors.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/factory.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/install.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/runtime.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/llm/service.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/main.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/mcp/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/mcp/mcp_runner.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugin_loader.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/pluginlib/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/pluginlib/build_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/pluginlib/config.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/pluginlib/plugin_utils.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/athena_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/clickhouse_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/base_introspector.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/database_chunker.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/databases_types.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/introspection_model_builder.py +1 -1
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/introspection_scope.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/introspection_scope_matcher.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/databases/postgresql_introspector.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/duckdb_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/mssql_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/mysql_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/parquet_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/plugin_loader.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/postgresql_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/resources/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/resources/parquet_chunker.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/snowflake_db_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/plugins/unstructured_files_plugin.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/init_project.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/layout.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/project_config.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/resources/examples/src/databases/example_postgres.yaml +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/resources/examples/src/files/documentation.md +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/project/resources/examples/src/files/notes.txt +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/retrieve_embeddings/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/retrieve_embeddings/export_results.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/retrieve_embeddings/retrieve_runner.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/retrieve_embeddings/retrieve_service.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/retrieve_embeddings/retrieve_wiring.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/serialization/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/serialization/yaml.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/chunk_embedding_service.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/embedding_shard_resolver.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/factories.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/models.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/persistence_service.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/services/table_name_policy.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/connection.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/exceptions/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/exceptions/exceptions.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/migrate.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/migrations/V01__init.sql +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/models.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/chunk_repository.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/embedding_model_registry_repository.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/embedding_repository.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/factories.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/repositories/vector_search_repository.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/storage/transaction.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/system/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/system/properties.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/templating/__init__.py +0 -0
- {databao_context_engine-0.1.3 → databao_context_engine-0.1.4.dev1}/src/databao_context_engine/templating/renderer.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: databao-context-engine
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.4.dev1
|
|
4
|
+
Summary: Semantic context for your LLMs — generated automatically
|
|
5
5
|
Requires-Dist: click>=8.3.0
|
|
6
6
|
Requires-Dist: duckdb>=1.4.3
|
|
7
7
|
Requires-Dist: pyyaml>=6.0.3
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "databao-context-engine"
|
|
3
|
-
version = "0.1.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.1.4.dev1"
|
|
4
|
+
description = "Semantic context for your LLMs — generated automatically"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
dependencies = [
|
|
@@ -2,13 +2,13 @@ from dataclasses import dataclass
|
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from typing import Any, cast
|
|
4
4
|
|
|
5
|
+
from databao_context_engine.datasources.types import DatasourceId, PreparedConfig, PreparedDatasource
|
|
5
6
|
from databao_context_engine.pluginlib.build_plugin import (
|
|
6
7
|
BuildDatasourcePlugin,
|
|
7
8
|
BuildFilePlugin,
|
|
8
9
|
BuildPlugin,
|
|
9
10
|
)
|
|
10
11
|
from databao_context_engine.pluginlib.plugin_utils import execute_datasource_plugin, execute_file_plugin
|
|
11
|
-
from databao_context_engine.datasources.types import PreparedConfig, PreparedDatasource, DatasourceId
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@dataclass()
|
|
@@ -15,6 +15,7 @@ def _generate_info_string(command_info: DceInfo) -> str:
|
|
|
15
15
|
info_lines = []
|
|
16
16
|
info_lines.append(f"Databao context engine version: {command_info.version}")
|
|
17
17
|
info_lines.append(f"Databao context engine storage dir: {command_info.dce_path}")
|
|
18
|
+
info_lines.append(f"Databao context engine plugins: {command_info.plugin_ids}")
|
|
18
19
|
|
|
19
20
|
info_lines.append("")
|
|
20
21
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import types
|
|
2
2
|
from dataclasses import MISSING, fields, is_dataclass
|
|
3
|
-
from typing import Annotated, Any, ForwardRef, Union, get_origin, get_type_hints
|
|
3
|
+
from typing import Annotated, Any, ForwardRef, Union, get_args, get_origin, get_type_hints
|
|
4
4
|
|
|
5
|
-
from pydantic import BaseModel
|
|
5
|
+
from pydantic import BaseModel
|
|
6
6
|
from pydantic_core import PydanticUndefinedType
|
|
7
7
|
|
|
8
8
|
from databao_context_engine.pluginlib.config import (
|
|
9
9
|
ConfigPropertyAnnotation,
|
|
10
10
|
ConfigPropertyDefinition,
|
|
11
|
-
ConfigUnionPropertyDefinition,
|
|
12
11
|
ConfigSinglePropertyDefinition,
|
|
12
|
+
ConfigUnionPropertyDefinition,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
|
|
@@ -59,18 +59,14 @@ def _get_property_list_from_dataclass(parent_type: type) -> list[ConfigPropertyD
|
|
|
59
59
|
raise ValueError(f"{parent_type} is not a dataclass")
|
|
60
60
|
|
|
61
61
|
dataclass_fields = fields(parent_type)
|
|
62
|
+
type_hints = get_type_hints(parent_type, include_extras=True)
|
|
62
63
|
|
|
63
64
|
result = []
|
|
64
65
|
for field in dataclass_fields:
|
|
65
66
|
has_field_default = field.default is not None and field.default != MISSING
|
|
66
67
|
|
|
67
|
-
if
|
|
68
|
-
|
|
69
|
-
property_type = _evaluate_type_string(field.type)
|
|
70
|
-
except Exception:
|
|
71
|
-
continue
|
|
72
|
-
else:
|
|
73
|
-
property_type = field.type
|
|
68
|
+
# Use the type hints if the field type wasn't resolved (aka. if it is a ForwardRef or a str)
|
|
69
|
+
property_type = type_hints[field.name] if isinstance(field.type, ForwardRef | str) else field.type
|
|
74
70
|
|
|
75
71
|
property_for_field = _create_property(
|
|
76
72
|
property_type=property_type,
|
|
@@ -89,6 +85,10 @@ def _get_property_list_from_pydantic_base_model(parent_type: type):
|
|
|
89
85
|
if not issubclass(parent_type, BaseModel):
|
|
90
86
|
raise ValueError(f"{parent_type} is not a Pydantic BaseModel")
|
|
91
87
|
|
|
88
|
+
if any(isinstance(field.annotation, ForwardRef) for field in parent_type.model_fields.values()):
|
|
89
|
+
# If any field's future type wasn't resolved yet, we rebuild the model to resolve them
|
|
90
|
+
parent_type.model_rebuild(force=True)
|
|
91
|
+
|
|
92
92
|
pydantic_fields = parent_type.model_fields
|
|
93
93
|
result = []
|
|
94
94
|
|
|
@@ -214,18 +214,3 @@ def compute_default_value(
|
|
|
214
214
|
return str(property_default)
|
|
215
215
|
|
|
216
216
|
return None
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
def _evaluate_type_string(property_type: str) -> type:
|
|
220
|
-
try:
|
|
221
|
-
# Using a pydantic internal function for this, to avoid having to implement type evaluation manually...
|
|
222
|
-
return _internal._typing_extra.eval_type(property_type)
|
|
223
|
-
except Exception as initial_error:
|
|
224
|
-
try:
|
|
225
|
-
# Try to convert it ourselves if Pydantic didn't work
|
|
226
|
-
return ForwardRef(property_type)._evaluate( # type: ignore[return-value]
|
|
227
|
-
globalns=globals(), localns=locals(), recursive_guard=frozenset()
|
|
228
|
-
)
|
|
229
|
-
except Exception as e:
|
|
230
|
-
# Ignore if we didn't manage to convert the str to a type
|
|
231
|
-
raise e from initial_error
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from contextlib import asynccontextmanager
|
|
3
|
+
from datetime import date
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
from typing import Literal
|
|
5
6
|
|
|
@@ -7,8 +8,6 @@ from mcp.server import FastMCP
|
|
|
7
8
|
from mcp.types import ToolAnnotations
|
|
8
9
|
|
|
9
10
|
from databao_context_engine import DatabaoContextEngine
|
|
10
|
-
from databao_context_engine.mcp.all_results_tool import run_all_results_tool
|
|
11
|
-
from databao_context_engine.mcp.retrieve_tool import run_retrieve_tool
|
|
12
11
|
|
|
13
12
|
logger = logging.getLogger(__name__)
|
|
14
13
|
|
|
@@ -41,19 +40,23 @@ class McpServer:
|
|
|
41
40
|
annotations=ToolAnnotations(readOnlyHint=True, idempotentHint=True, openWorldHint=False),
|
|
42
41
|
)
|
|
43
42
|
def all_results_tool():
|
|
44
|
-
return
|
|
43
|
+
return self._databao_context_engine.get_all_contexts_formatted()
|
|
45
44
|
|
|
46
45
|
@mcp.tool(
|
|
47
46
|
description="Retrieve the context built from various resources, including databases, dbt tools, plain and structured files, to retrieve relevant information",
|
|
48
47
|
annotations=ToolAnnotations(readOnlyHint=True, idempotentHint=True, openWorldHint=False),
|
|
49
48
|
)
|
|
50
49
|
def retrieve_tool(text: str, limit: int | None):
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
text=text,
|
|
54
|
-
limit=limit or 50,
|
|
50
|
+
retrieve_results = self._databao_context_engine.search_context(
|
|
51
|
+
retrieve_text=text, limit=limit, export_to_file=False
|
|
55
52
|
)
|
|
56
53
|
|
|
54
|
+
display_results = [context_search_result.context_result for context_search_result in retrieve_results]
|
|
55
|
+
|
|
56
|
+
display_results.append(f"\nToday's date is {date.today()}")
|
|
57
|
+
|
|
58
|
+
return "\n".join(display_results)
|
|
59
|
+
|
|
57
60
|
return mcp
|
|
58
61
|
|
|
59
62
|
def run(self, transport: McpTransport):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any, TypeVar
|
|
3
|
+
from typing import Annotated, Any, TypeVar
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, ConfigDict, Field
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ from databao_context_engine.pluginlib.build_plugin import (
|
|
|
8
8
|
BuildDatasourcePlugin,
|
|
9
9
|
EmbeddableChunk,
|
|
10
10
|
)
|
|
11
|
+
from databao_context_engine.pluginlib.config import ConfigPropertyAnnotation
|
|
11
12
|
from databao_context_engine.plugins.databases.base_introspector import BaseIntrospector
|
|
12
13
|
from databao_context_engine.plugins.databases.database_chunker import build_database_chunks
|
|
13
14
|
from databao_context_engine.plugins.databases.introspection_scope import IntrospectionScope
|
|
@@ -17,7 +18,9 @@ class BaseDatabaseConfigFile(BaseModel):
|
|
|
17
18
|
model_config = ConfigDict(populate_by_name=True)
|
|
18
19
|
name: str | None = Field(default=None)
|
|
19
20
|
type: str
|
|
20
|
-
introspection_scope:
|
|
21
|
+
introspection_scope: Annotated[
|
|
22
|
+
IntrospectionScope | None, ConfigPropertyAnnotation(ignored_for_config_wizard=True)
|
|
23
|
+
] = Field(default=None, alias="introspection-scope")
|
|
21
24
|
|
|
22
25
|
|
|
23
26
|
T = TypeVar("T", bound=BaseDatabaseConfigFile)
|
|
@@ -7,6 +7,7 @@ from databao_context_engine.plugins.base_db_plugin import BaseDatabaseConfigFile
|
|
|
7
7
|
from databao_context_engine.plugins.databases.base_introspector import BaseIntrospector, SQLQuery
|
|
8
8
|
from databao_context_engine.plugins.databases.databases_types import DatabaseSchema
|
|
9
9
|
from databao_context_engine.plugins.databases.introspection_model_builder import IntrospectionModelBuilder
|
|
10
|
+
from databao_context_engine.plugins.duckdb_tools import fetchall_dicts
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class DuckDBConfigFile(BaseDatabaseConfigFile):
|
|
@@ -319,7 +320,4 @@ class DuckDBIntrospector(BaseIntrospector[DuckDBConfigFile]):
|
|
|
319
320
|
|
|
320
321
|
def _fetchall_dicts(self, connection, sql: str, params) -> list[dict]:
|
|
321
322
|
cur = connection.cursor()
|
|
322
|
-
cur
|
|
323
|
-
columns = [desc[0].lower() for desc in cur.description] if cur.description else []
|
|
324
|
-
rows = cur.fetchall()
|
|
325
|
-
return [dict(zip(columns, row)) for row in rows]
|
|
323
|
+
return fetchall_dicts(cur, sql, params)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any, Mapping
|
|
3
|
+
from typing import Annotated, Any, Mapping
|
|
4
4
|
|
|
5
5
|
from mssql_python import connect # type: ignore[import-untyped]
|
|
6
|
-
from pydantic import
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
7
|
|
|
8
8
|
from databao_context_engine.pluginlib.config import ConfigPropertyAnnotation
|
|
9
9
|
from databao_context_engine.plugins.base_db_plugin import BaseDatabaseConfigFile
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from databao_context_engine.pluginlib.config import DuckDBSecret
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def generate_create_secret_sql(secret_name, duckdb_secret: DuckDBSecret) -> str:
|
|
7
|
+
parameters = [("type", duckdb_secret.type)] + list(duckdb_secret.properties.items())
|
|
8
|
+
return f"""CREATE SECRET {secret_name} (
|
|
9
|
+
{", ".join([f"{k} '{v}'" for (k, v) in parameters])}
|
|
10
|
+
);
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def fetchall_dicts(cur, sql: str, params=None) -> list[dict[str, Any]]:
|
|
15
|
+
cur.execute(sql, params or [])
|
|
16
|
+
columns = [desc[0].lower() for desc in cur.description] if cur.description else []
|
|
17
|
+
rows = cur.fetchall()
|
|
18
|
+
return [dict(zip(columns, row)) for row in rows]
|
|
@@ -10,6 +10,7 @@ from duckdb import DuckDBPyConnection
|
|
|
10
10
|
from pydantic import BaseModel, Field
|
|
11
11
|
|
|
12
12
|
from databao_context_engine.pluginlib.config import DuckDBSecret
|
|
13
|
+
from databao_context_engine.plugins.duckdb_tools import fetchall_dicts, generate_create_secret_sql
|
|
13
14
|
|
|
14
15
|
parquet_type = "resources/parquet"
|
|
15
16
|
|
|
@@ -49,14 +50,6 @@ class ParquetIntrospectionResult:
|
|
|
49
50
|
files: list[ParquetFile]
|
|
50
51
|
|
|
51
52
|
|
|
52
|
-
def generate_create_secret_sql(secret_name, duckdb_secret: DuckDBSecret) -> str:
|
|
53
|
-
parameters = [("type", duckdb_secret.type)] + list(duckdb_secret.properties.items())
|
|
54
|
-
return f"""CREATE SECRET {secret_name} (
|
|
55
|
-
{", ".join([f"{k} {v}" for (k, v) in parameters])}
|
|
56
|
-
);
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
|
|
60
53
|
@contextlib.contextmanager
|
|
61
54
|
def _create_secret(conn: DuckDBPyConnection, duckdb_secret: DuckDBSecret):
|
|
62
55
|
secret_name = duckdb_secret.name or "gen_secret_" + str(uuid.uuid4()).replace("-", "_")
|
|
@@ -97,10 +90,9 @@ class ParquetIntrospector:
|
|
|
97
90
|
with self._connect(file_config) as conn:
|
|
98
91
|
with conn.cursor() as cur:
|
|
99
92
|
resolved_url = _resolve_url(file_config)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
parquet_file_metadata = [dict(zip(columns, row)) for row in rows]
|
|
93
|
+
parquet_file_metadata = fetchall_dicts(
|
|
94
|
+
cur, f"SELECT * FROM parquet_file_metadata('{resolved_url}') LIMIT 1"
|
|
95
|
+
)
|
|
104
96
|
if not parquet_file_metadata:
|
|
105
97
|
raise ValueError(f"No parquet files found by url {resolved_url}")
|
|
106
98
|
if not parquet_file_metadata or not parquet_file_metadata[0]["file_name"]:
|
|
@@ -110,10 +102,7 @@ class ParquetIntrospector:
|
|
|
110
102
|
with self._connect(file_config) as conn:
|
|
111
103
|
with conn.cursor() as cur:
|
|
112
104
|
resolved_url = _resolve_url(file_config)
|
|
113
|
-
cur
|
|
114
|
-
cols = [desc[0].lower() for desc in cur.description] if cur.description else []
|
|
115
|
-
rows = cur.fetchall()
|
|
116
|
-
file_metas = [dict(zip(cols, row)) for row in rows]
|
|
105
|
+
file_metas = fetchall_dicts(cur, f"SELECT * from parquet_metadata('{resolved_url}')")
|
|
117
106
|
|
|
118
107
|
columns_per_file: dict[str, dict[int, ParquetColumn]] = defaultdict(defaultdict)
|
|
119
108
|
for file_meta in file_metas:
|
|
@@ -3,6 +3,7 @@ from importlib.metadata import version
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
|
+
from databao_context_engine.plugins.plugin_loader import load_plugins
|
|
6
7
|
from databao_context_engine.project.layout import validate_project_dir
|
|
7
8
|
from databao_context_engine.system.properties import get_dce_path
|
|
8
9
|
|
|
@@ -34,6 +35,7 @@ class DceInfo:
|
|
|
34
35
|
|
|
35
36
|
version: str
|
|
36
37
|
dce_path: Path
|
|
38
|
+
plugin_ids: list[str]
|
|
37
39
|
|
|
38
40
|
project_info: DceProjectInfo
|
|
39
41
|
|
|
@@ -50,6 +52,7 @@ def get_databao_context_engine_info(project_dir: Path) -> DceInfo:
|
|
|
50
52
|
return DceInfo(
|
|
51
53
|
version=get_dce_version(),
|
|
52
54
|
dce_path=get_dce_path(),
|
|
55
|
+
plugin_ids=[plugin.id for plugin in load_plugins().values()],
|
|
53
56
|
project_info=_get_project_info(project_dir),
|
|
54
57
|
)
|
|
55
58
|
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
from databao_context_engine import DatabaoContextEngine
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def run_retrieve_tool(*, databao_context_engine: DatabaoContextEngine, text: str, limit: int | None = None) -> str:
|
|
7
|
-
"""Execute the retrieve flow for MCP and return the matching display texts."""
|
|
8
|
-
retrieve_results = databao_context_engine.search_context(retrieve_text=text, limit=limit, export_to_file=False)
|
|
9
|
-
|
|
10
|
-
display_results = [context_search_result.context_result for context_search_result in retrieve_results]
|
|
11
|
-
|
|
12
|
-
display_results.append(f"\nToday's date is {datetime.date.today()}")
|
|
13
|
-
|
|
14
|
-
return "\n".join(display_results)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,11 +6,11 @@ from typing import Any
|
|
|
6
6
|
import click
|
|
7
7
|
|
|
8
8
|
from databao_context_engine import (
|
|
9
|
+
ConfigPropertyDefinition,
|
|
9
10
|
DatabaoContextPluginLoader,
|
|
10
11
|
DatabaoContextProjectManager,
|
|
11
12
|
DatasourceId,
|
|
12
13
|
DatasourceType,
|
|
13
|
-
ConfigPropertyDefinition,
|
|
14
14
|
)
|
|
15
15
|
from databao_context_engine.pluginlib.config import ConfigUnionPropertyDefinition
|
|
16
16
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,13 +5,13 @@ from databao_context_engine.plugins.databases.databases_types import (
|
|
|
5
5
|
CheckConstraint,
|
|
6
6
|
DatabaseColumn,
|
|
7
7
|
DatabasePartitionInfo,
|
|
8
|
+
DatabaseSchema,
|
|
8
9
|
DatabaseTable,
|
|
9
10
|
DatasetKind,
|
|
10
11
|
ForeignKey,
|
|
11
12
|
ForeignKeyColumnMap,
|
|
12
13
|
Index,
|
|
13
14
|
KeyConstraint,
|
|
14
|
-
DatabaseSchema,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|