SemanticLayer integration
Connect to a deployed SemanticLayer service, verify metadata queries, and use the connection in plugin tools. The service is deployed separately; this repository provides the client.
With semantic configured, the Server or SDK supplies a shared client through runtime.context.semantic_client. Its creating host owns cleanup. See the Python API for methods, parameters, and lifetime rules.
Configuration
Confirm the service root URL, authentication requirements, and existing business database name, then add the connection section to your complete product YAML. Fill authentication and certificate fields as required by the deployment. Models and plugins retain their own configuration sections.
semantic:
base_url: https://semantic.example.com
username: $env{SEMANTIC_USERNAME}
password: $env{SEMANTIC_PASSWORD}
timeout_seconds: 30
semantic_scenario: business_twin
tls:
verify_server: true
ca_file: certs/ca.pem
client_cert: certs/client.pem
client_key: certs/client.keySet base_url to the service root. Requests use /api/semantic/v1/.... Supply Basic credentials through the environment. Set semantic_scenario when the deployment requires a scenario. See semantic configuration for fields, defaults, and path rules.
TLS
- Set
verify_server: truefor HTTPS to verify the server certificate. The configuration defaults tofalse; this example explicitly enables verification. - Set
ca_filefor a private CA. Otherwise, use the system's trusted CAs. - Set both
client_certandclient_keywhen the service requires mutual TLS. Certificate paths follow the selected YAML's path rules. - Set
ciphersif the service requires a cipher list. See the configuration reference for constraints and the Python API for client construction rules.
Try the interactive TUI example
The repository includes a dedicated configuration
and example plugin
for the same interactive purpose as the semantic-service test Agent in main_legacy.
They use the current product and plugin schemas to query SemanticLayer metadata through
natural-language requests. NL2SQL and de-agent are not required. These example tools do not
execute SQL or modify business databases.
Complete the source prerequisites, then create
semantic.env in the repository root:
LLM_MODEL=your-model-name
LLM_BASE_URL=https://your-model-service.example.com/v1
LLM_API_KEY=replace-with-your-key
SEMANTIC_BASE_URL=https://your-semantic-service.example.com
SEMANTIC_DATABASE=your_databaseSEMANTIC_DATABASE is an existing business database name in the service, not a local file path.
semantic configures the connection, authentication, timeout and TLS;
plugins.config.semantic-service.database scopes the business table listing and natural-language
retrieval. models.primary lets the Agent interpret questions, select tools and explain results.
plugins.paths resolves relative to the YAML file, so keep plugins/semantic-service/ alongside it
when copying the example.
For HTTP Basic, uncomment both username and password in the YAML and provide
SEMANTIC_USERNAME and SEMANTIC_PASSWORD in the environment file. The example enables server
certificate verification; configure private CAs or mutual TLS as described above. The old
SEMANTIC_LAYER section cannot be copied into the current schema.
Nonempty process environment values take precedence over --env-file. Selecting a YAML file
does not load a neighboring .env; see configuration rules.
Start the source TUI from the repository root:
npm run build:tui
npm run start:tui -- --config examples/semantic-service.yaml --env-file ./semantic.envThis starts a backend with the selected configuration. Do not also pass --runtime-url.
If another service occupies its port, stop that service or choose a different server.port
in the YAML. To use a separately installed TUI, start the backend from the source repository
and then connect:
uv run dataagent serve --config examples/semantic-service.yaml --env-file ./semantic.env
# In another terminal:
dataagent-cli --runtime-url http://127.0.0.1:8790Try the following requests:
| Request | Tools and meaning |
|---|---|
| List the semantic retrieval tables, then inspect one table's schema. | list_semantic_layer_tables, get_semantic_layer_table_schema: the service's own retrieval tables |
| List the configured business database's tables and inspect one table's columns. | list_database_tables, get_table_schema: use an actual returned db.table name |
| Find relationships between these two business tables. | get_join_relations: supply confirmed, fully qualified names |
Search metric_instance for “sales” and udf_function for “date”. |
search_semantic_entities: full-text search with a keyword, or paginated enumeration without one |
| Retrieve semantic evidence for “order amounts over the last month”. | semantic_retrieve: sends the configured database as db_name |
| Run the semantic-service DSL query I provide. | search_semantic_dsl: types and attributes must exist in the service |
Registered tool names have the semantic-service__ prefix. Retrieval table schemas and
business table schemas use different APIs. An empty response means no matches for that request;
it does not establish that the service is unreachable. Metric and UDF types depend on the
deployment. These are basic client operations; the example does not restore the legacy metric
workflow's multi-stage recall and model-based filtering.
Press Ctrl+O in the TUI to inspect tool inputs and outputs. Backend logs are in the server
Home's runtime/logs/backend.log; TUI logs are in the client's runtime/logs/tui.log.
When a graph root finishes, its local trace is written under the server Home at
runtime/users/<user>/sessions/<thread>/traces/<native-root-run-id>.json. The filename is not
the AG-UI runId. These tools return results directly and do not generate CSV artifacts by default.
See the TUI guide, troubleshooting, and
execution traces.
Call from a tool
from langchain.tools import ToolRuntime
from dataagent import AgentContext
def lookup(query: str, runtime: ToolRuntime[AgentContext]) -> str:
"""Retrieve semantic metadata for a natural-language query."""
client = runtime.context.semantic_client
if client is None:
raise RuntimeError("semantic service is not configured")
payload = client.semantic_retrieve(query)
return str(payload)This is a minimal synchronous tool. Offload the synchronous client call to a thread in an async tool; see the example implementation. See plugin integration to declare the tool. The method table, parameter contracts, scenario views, and ownership rules live in the SemanticLayer client reference.