tool
Adapted from the Griptape AI Framework documentation.
Bases:
BaseTool
Attributes
Name | Type | Description |
---|---|---|
description | str | LLM-friendly vector DB description. |
vector_store_driver | BaseVectorStoreDriver | BaseVectorStoreDriver . |
query_params | dict[str, Any] | Optional dictionary of vector store driver query parameters. |
process_query_output | Callable[[list[Entry]], BaseArtifact] | Optional lambda for processing vector store driver query output Entry s. |
Source Code in griptape/tools/vector_store/tool.py
@define(kw_only=True) class VectorStoreTool(BaseTool): """A tool for querying a vector database. Attributes: description: LLM-friendly vector DB description. vector_store_driver: `BaseVectorStoreDriver`. query_params: Optional dictionary of vector store driver query parameters. process_query_output: Optional lambda for processing vector store driver query output `Entry`s. """ DEFAULT_TOP_N = 5 description: str = field() vector_store_driver: BaseVectorStoreDriver = field() query_params: dict[str, Any] = field(factory=dict) process_query_output: Callable[[list[BaseVectorStoreDriver.Entry]], BaseArtifact] = field( default=Factory(lambda: lambda es: ListArtifact([e.to_artifact() for e in es])), ) @activity( config={ "description": "Can be used to search a database with the following description: {{ _self.description }}", "schema": Schema( { Literal( "query", description="A natural language search query to run against the vector database", ): str, }, ), }, ) def search(self, params: dict) -> BaseArtifact: query = params["values"]["query"] try: return self.process_query_output(self.vector_store_driver.query(query, **self.query_params)) except Exception as e: return ErrorArtifact(f"error querying vector store: {e}")
DEFAULT_TOP_N = 5
class-attribute instance-attributedescription = field()
class-attribute instance-attributeprocess_query_output = field(default=Factory(lambda: lambda es: ListArtifact([e.to_artifact() for e in es])))
class-attribute instance-attributequery_params = field(factory=dict)
class-attribute instance-attributevector_store_driver = field()
class-attribute instance-attribute
search(params)
Source Code in griptape/tools/vector_store/tool.py
@activity( config={ "description": "Can be used to search a database with the following description: {{ _self.description }}", "schema": Schema( { Literal( "query", description="A natural language search query to run against the vector database", ): str, }, ), }, ) def search(self, params: dict) -> BaseArtifact: query = params["values"]["query"] try: return self.process_query_output(self.vector_store_driver.query(query, **self.query_params)) except Exception as e: return ErrorArtifact(f"error querying vector store: {e}")
- On this page
- Attributes
- search(params)
Could this page be better? Report a problem or suggest an addition!