Store documents and text in Retool-managed Vectors
Learn how to store text in a Retool-managed vector database for use with AI models.
You can use Retool-managed Vectors to store and generate AI-related vector data for plain text or extracted text from PDF documents. Retool can then provide AI models with related information when performing AI actions.
Add a document
You cannot use the Convert document to text AI action in a workflow. You need to extract the text first and make it available for the workflow to use.
You can add documents or plain text to a vector manually or query the Retool Vectors resource in apps or workflows.
- Manually
- Using an app or workflow
- Navigate to the Resources settings and click Retool Vectors.
- Select the vector in which to add.
- Click Add document, then select either Upload file or Add plain text.
Use the Convert document to text AI action in web or mobile apps to first extract text from a PDF document. You can then reference the extracted text using {{ }}
notation, such as {{ convertDocument.data }}
.
- Set Vector action to Insert document.
- Set Document content to the desired text.3
- Specify a name for the document in the Document name field.
When run, the query adds a new document to the vector. If a document with the same name already exists, the query returns an error.
Update or upsert a document
Use the Update document action to update an existing document. You can also use the Upsert document action to update an existing document or create one if it doesn't exist.
Combine this with the List documents action in apps to enable users to select from a list of documents in a vector.
- Set Resource to Retool Vectors.
- Set Vector action to Update document or Upsert document.
- Set Document content to the desired text.
- Specify a name for the document in the Document name field.
When run, the query adds a new document to the vector. If a document with the same name already exists, the contents are updated.
Delete an existing document
Use the Delete an existing document action to remove a specified document from a vector.
Any documents you delete from a Vector are unrecoverable.
- Set Vector action to Delete document.
- Select the vector in the Vector field.
- Specify the name of the document in the Document name field.
Enable Show a confirmation modal before running in the Advanced tab to display a confirmation message and prevent accidental deletion.
List documents
Use the List documents action to retrieve a list of all documents in an existing vector.
- Set Vector action to List document.
- Set Document content to the desired text.
- Specify a name for the document in the Document name field.
Get document chunks
Use the Get document chunks action to retrieve the text for a specified document. When run, the query returns a list of text strings.
- Set Vector action to Get document chunks.
- Select the vector in the Vector field.
- Specify the name of the document in the Document name field.
Clear Vector documents
Use the Clear Vector documents action to delete all documents in the specified vector.
Any documents you delete from a Vector are unrecoverable.
- Set Vector action to Clear Vector documents.
- Select the vector in the Vector field.
Enable Show a confirmation modal before running in the Advanced tab to display a confirmation message and prevent accidental deletion.