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
61 changes: 24 additions & 37 deletions nodes/src/nodes/store_astra/IGlobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,36 @@
# ------------------------------------------------------------------------------
# This class controls the data shared between all threads for the task
# ------------------------------------------------------------------------------
from rocketlib import OPEN_MODE
from ai.common.transform import IGlobalTransform
from typing import Any, Dict

from ai.common.store import StoreGlobalBase

class IGlobal(IGlobalTransform):
def beginGlobal(self):
# Are we in config mode or some other mode?
if self.IEndpoint.endpoint.openMode == OPEN_MODE.CONFIG:
# We are going to get a call to configureService but
# we don't actually need to load the driver for that
pass
else:
# Import store definition - even though
from .astra_db import Store

# Declare store
self.store: Store | None = None

# Get our bag
bag = self.IEndpoint.endpoint.bag
class IGlobal(StoreGlobalBase):
serverName: str = 'astra'

# Get the passed configuration
connConfig = self.getConnConfig()
def _open_store(self, logical_type: str, conn_config: Dict[str, Any], bag: Dict[str, Any]):
"""Return the driver's Store, imported lazily so config mode never loads the driver."""
from .astra_db import Store

# Get the configuration
self.store = Store(self.glb.logicalType, connConfig, bag)
collection = getattr(self.store, 'collection_name', getattr(self.store, 'collection', ''))
return Store(logical_type, conn_config, bag)

# Prefer cloud endpoint if present; otherwise fall back to host[:port]; otherwise logical type
if hasattr(self.store, 'api_endpoint') and self.store.api_endpoint:
identifier = self.store.api_endpoint.rstrip('/')
elif hasattr(self.store, 'host') and getattr(self.store, 'host', ''):
port = getattr(self.store, 'port', None)
identifier = f'{self.store.host}:{port}' if port else self.store.host
else:
identifier = self.glb.logicalType
def _sub_key(self) -> str:
"""Return the transform sub-key: endpoint-or-host/collection."""
store = self.store
collection = getattr(store, 'collection_name', getattr(store, 'collection', ''))

subKey = f'{identifier}/{collection}'
# Prefer cloud endpoint if present; otherwise fall back to host[:port]; otherwise logical type
if getattr(store, 'api_endpoint', ''):
identifier = store.api_endpoint.rstrip('/')
elif getattr(store, 'host', ''):
port = getattr(store, 'port', None)
identifier = f'{store.host}:{port}' if port else store.host
else:
identifier = self.glb.logicalType

# Call the base
super().beginGlobal(subKey)
return
return f'{identifier}/{collection}'

def endGlobal(self):
# Release the index and embeddings
self.store = None
def _probe_connection(self, config: Dict[str, Any]) -> None:
"""Astra validates the collection name inside Store.__init__; no save-time probe here."""
return
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
56 changes: 2 additions & 54 deletions nodes/src/nodes/store_astra/IInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,9 @@
# ------------------------------------------------------------------------------
# This class controls the data for each thread of the task
# ------------------------------------------------------------------------------
from rocketlib import Entry
from typing import List
from .IGlobal import IGlobal
from ai.common.schema import Doc, Question
from ai.common.transform import IInstanceTransform
from ai.common.store import StoreInstanceBase


class IInstance(IInstanceTransform):
class IInstance(StoreInstanceBase):
IGlobal: IGlobal

def writeQuestions(self, question: Question):
"""
Take a question, perform a search, and writes the results as documents.
"""
# Check if store exists
if self.IGlobal.store is None:
raise Exception('No document store')

# Dispatch to the search handler
self.IGlobal.store.dispatchSearch(self, question)

def writeDocuments(self, documents: List[Doc]):
"""
Take a list of documents and adds them to the vector store.

Any chunks in the database that have the same object id will
be removed
"""
# Check if store exists
if self.IGlobal.store is None:
raise Exception('No document store')

# Add the document chunks
self.IGlobal.store.addChunks(documents)

def renderObject(self, object: Entry):
"""
Output the document text to the writeText lane.
"""

def callback(text: str) -> None:
self.instance.sendText(text)

# Check if store exists
if self.IGlobal.store is None:
raise Exception('No document store')

# If we do not have a vectorize flag, or we have not vectorized
# it, allow the next driver to render
if not object.hasVectorBatchId or not object.vectorBatchId:
return

# Render the data on this object from the store and
# send it to the renderData function
self.IGlobal.store.render(objectId=object.objectId, callback=callback)

# Stop right here
self.preventDefault()
16 changes: 15 additions & 1 deletion nodes/src/nodes/store_astra/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# store_astra

A RocketRide store node that persists embedded documents in DataStax Astra DB and retrieves them by semantic or keyword search.
A RocketRide store node that persists embedded documents in DataStax Astra DB and retrieves them by semantic or keyword search, and exposes search/upsert/delete as agent-callable tools.

## What it does

Expand Down Expand Up @@ -78,6 +78,20 @@ Set `api_endpoint` to the database's Data API URL and `application_token` to the

---

## Agent tools

When wired to an agent, the node exposes three tools via `VectorStoreToolMixin`. Each tool is named `<serverName>.<tool>` (defaults: `astra.search`, `astra.upsert`, `astra.delete`).

| Tool | Key inputs | Description |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `search` | `query` (required); `top_k` (default 10, max 100); `filter` (optional dict, keys `objectId`/`nodeId`/`parent` are honored) | Semantic search over stored documents; returns content, metadata, and score per result. Falls back to keyword search if semantic search fails. |
| `upsert` | `documents` array, each with `content` and `object_id`; optional `metadata`, `embedding`, and `embedding_model` | Add or update documents. Embeddings are computed automatically via the bound embedding provider, or pre-computed vectors can be supplied. |
| `delete` | `object_ids` (non-empty string array) | Hard-delete documents by object ID. Returns `deleted_count`. |

Tool calls run on the control plane and do not flow through the pipeline's embedding lanes. Semantic search in the `search` tool and automatic embedding in `upsert` require an embedding provider bound to the node (the `all.embedding` block in its parameters). Without one, those calls return `{"success": false, "error": ...}`.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

---

<!-- ROCKETRIDE:GENERATED:PARAMS START -->
<!-- Generated by nodes:docs-generate. Do not edit by hand. -->

Expand Down
19 changes: 14 additions & 5 deletions nodes/src/nodes/store_astra/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// Required:
// Class type of the node - what it does
//
"classType": ["store"],
"classType": ["store", "tool"],
//
// Required:
// Capabilities are flags that change the behavior of the underlying
// engine
//
"capabilities": [],
"capabilities": ["invoke"],
//
// Optional:
// Register is either filter, endpoint or ignored if not specified. If the
Expand Down Expand Up @@ -139,14 +139,16 @@
"title": "Local test server",
"api_endpoint": "http://localhost:8080",
"application_token": "test-token",
"collection": "ROCKETRIDE"
"collection": "ROCKETRIDE",
"serverName": "astra"
},
"cloud": {
"mode": "cloud",
"title": "Astra DB cloud server",
"api_endpoint": "",
"application_token": "",
"collection": "ROCKETRIDE"
"collection": "ROCKETRIDE",
"serverName": "astra"
}
}
},
Expand All @@ -167,6 +169,13 @@
"title": "Application Token",
"description": "Enter the server API application token"
},
"astra_db.serverName": {
"type": "string",
"title": "Tool Server Name",
"description": "Namespace for agent-facing tool names, e.g. 'astra' exposes tools as astra.search / astra.upsert / astra.delete. Change this when running multiple Astra DB nodes in the same pipeline so their tool names do not collide.",
"default": "astra",
"minLength": 1
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
"astra_db.provider": {
"type": "string",
"const": "astra_db",
Expand All @@ -190,7 +199,7 @@
{
"section": "Pipe",
"title": "Astra DB Vector Store",
"properties": ["astra_db.api_endpoint", "astra_db.application_token", "vector.score", "vector.collection"]
"properties": ["astra_db.api_endpoint", "astra_db.application_token", "vector.score", "vector.collection", "astra_db.serverName"]
},
{
"section": "Transform",
Expand Down
70 changes: 23 additions & 47 deletions nodes/src/nodes/store_atlas/IGlobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,36 @@
# ------------------------------------------------------------------------------
# This class controls the data shared between all threads for the task
# ------------------------------------------------------------------------------
from rocketlib import OPEN_MODE
from ai.common.transform import IGlobalTransform
from rocketlib import warning
from ai.common.config import Config


class IGlobal(IGlobalTransform):
def beginGlobal(self):
# Are we in config mode or some other mode?
if self.IEndpoint.endpoint.openMode == OPEN_MODE.CONFIG:
# We are going to get a call to configureService but
# we don't actually need to load the driver for that
# Validate configuration only during config mode
self.validateConfig()
pass
else:
# Declare store
from . import getStore
import re
from typing import Any, Dict

# Get our bag
bag = self.IEndpoint.endpoint.bag
from ai.common.store import StoreGlobalBase
from rocketlib import warning

# Get the passed configuration
connConfig = self.getConnConfig()

# Get the configuration
Store = getStore()
self.store = Store(self.glb.logicalType, connConfig, bag)
class IGlobal(StoreGlobalBase):
serverName: str = 'atlas'

# Get the info about our store
database = self.store.database
collection = self.store.collection
host = self.store.host
def _open_store(self, logical_type: str, conn_config: Dict[str, Any], bag: Dict[str, Any]):
"""Return the driver's Store, resolved lazily via the package hook so config mode never loads the driver."""
from . import getStore

# Format it into a subKey
subKey = f'{host}/{database}/{collection}'
Store = getStore()
return Store(logical_type, conn_config, bag)

# Call the base
super().beginGlobal(subKey)
return
def _sub_key(self) -> str:
"""Return the transform sub-key: host/database/collection."""
return f'{self.store.host}/{self.store.database}/{self.store.collection}'

def validateConfig(self):
def _probe_connection(self, config: Dict[str, Any]) -> None:
"""
Validate MongoDB config at save-time with optional connection testing.
Validate MongoDB config at save-time with lightweight format checks.

Performs lightweight format validation by default.
No syntaxOnly arg per engine expectations.
Performs format validation only (no network call): API key present,
host matches the Atlas ``mongodb+srv`` URI shape, and database/collection
names respect MongoDB naming restrictions.
"""
try:
# Get config
config = Config.getNodeConfig(self.glb.logicalType, self.glb.connConfig)
host = config.get('host')
api_key = config.get('apikey')
database = config.get('database')
Expand All @@ -93,11 +72,12 @@ def validateConfig(self):
host = host.strip()

# Basic MongoDB URI format validation using regex
import re

mongodb_uri_pattern = r'^mongodb\+srv://[^:]+:[^@]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9]+\.mongodb\.net/\?.*'
if not re.match(mongodb_uri_pattern, host):
warning("Host must be a valid MongoDB URI (e.g., 'mongodb+srv://cluster.example.mongodb.net')")
warning(
'Host must be a valid MongoDB SRV URI '
"(e.g., 'mongodb+srv://user:pass@cluster.abc12.mongodb.net/?retryWrites=true')"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return

# Database name validation - format check only
Expand Down Expand Up @@ -140,7 +120,3 @@ def validateConfig(self):
except Exception as e:
msg = str(e)
warning(msg)

def endGlobal(self):
# Release the database connection
self.store = None
52 changes: 2 additions & 50 deletions nodes/src/nodes/store_atlas/IInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,9 @@
# ------------------------------------------------------------------------------
# This class controls the data for each thread of the task
# ------------------------------------------------------------------------------
from rocketlib import Entry
from typing import List
from .IGlobal import IGlobal
from ai.common.schema import Doc, Question
from ai.common.transform import IInstanceTransform
from ai.common.store import StoreInstanceBase


class IInstance(IInstanceTransform):
class IInstance(StoreInstanceBase):
IGlobal: IGlobal

def writeQuestions(self, question: Question):
"""
Take a question, perform a search, and writes the results as documents.
"""
if self.IGlobal.store is None:
raise Exception('No document store')
# Dispatch to the search handler
self.IGlobal.store.dispatchSearch(self, question)

def writeDocuments(self, documents: List[Doc]):
"""
Take a list of documents and adds them to the document store.

Any documents in the database that have the same object id will
be removed
"""
if self.IGlobal.store is None:
raise Exception('No document store')
# Add the document chunks
self.IGlobal.store.addChunks(documents)

def renderObject(self, object: Entry):
"""
Output the document text to the writeText lane.
"""

def callback(text: str) -> None:
self.instance.sendText(text)

# Check it
if self.IGlobal.store is None:
raise Exception('No document store')

# If we do not have a vectorize flag, or we have not vectorized
# it, allow the next driver to render
if not object.hasVectorBatchId or not object.vectorBatchId:
return

# Render the data on this object from the store and
# send it to the renderData function
self.IGlobal.store.render(objectId=object.objectId, callback=callback)

# Stop right here
self.preventDefault()
Loading
Loading