query-vector-db
Last updated
Last updated
This agent enables submitting queries to a vector datasource (like or ) and outputting the results.
Follow the to create your Pinecone API key, environment, vector index name, and project name, and add them to your secrets.yaml file. These values are required.
Specify a datasource in configuration.yaml:
Reference the "vector-database" datasource and submit a query using input message values in pipeline.yaml:
Please refer to the documentation of the vector database you are using for more information on how to write queries:
In the example below we use the 'loop-over' capability to query the database for each document in the list of documents to retrieve.
When you use "loop-over", the agent executes for each element in a list instead of operating on the whole message. Use "record.xxx" to refer to the current element in the list.
The snippet above computes the embeddings for each element in the list "documents_to_retrieve". The list is expected to be a struct like this:
The agent then adds all the results to a new field named "retrieved_documents" in the message.
After running the agent the contents of the list are:
datasource
string
A reference to the datasource name declared in resources.datasources of the configuration.yaml manifest.
query
string
The query statement to run. Each placeholder “?” will be replaced with fields value in order.
Example:
fields
string[]
A collection of field values. Each value will be used in order to replace placeholders in the query (do not include mustache brackets, this is not a templated value).
Example collection:
“value.embeddings”
output-field
string
The name of an additional field to be added to message data containing query result (do not include mustache brackets, this is not a templated value).
Provide in the form: “value.<field-name>”
The query language depends on the underlying vector database. For example, Pinecone uses a JSON query language. See the for more information.
It is possible to perform the same computation over a list of inputs - for example, a list of questions. You can take the as an example.
Structured and unstructured text
Implicit topic
Structured text
Implicit topic
For more on vector databases, see .
For more on the datasource resource, see .