What is a Docs + Search node?

Node in Stack AI

A Docs + Search node is a knowledge base that you can use to store static documents (i.e., that don’t change). The documents that you upload are then indexed and stored in a vector data base - don’t worry, we do this for you in the background! This process is done once, so that you can later query this knowledge base and only retrieve the pieces of information that are more related to your query. It’s the most efficient way to manage a long list of documents, without having to index them everytime you run the workflow (i.e., embeddings are generated only once, when you upload the documents).

Status options for Docs + Search node

You will see a label for each document that you upload with the following meaning:

  • Loading: the document is being processed and indexed.
  • Ok: the document was successfully indexed.
  • Error: the document could not be indexed (e.g., due to a formatting issue).

How to use it?

How to connect with other nodes

To utilize the Docs + Search node, you must establish connections to both its input and output edges:

  • Input: This node necessitates a text input. Typically, you would connect the input to an LLM or Input node.
  • Output: This node outputs chunks of information. Typically, you would connect the output to an LLM or Output node.

Upload Files via API

There is also the option to add documents to an Doc+Search node using an endpoint. Below, you will find the steps to do so.

https://stack-intext.onrender.com/index_documents_api

This endpoint requires the following variables:

  1. flow_id: the id displayed on the url of your flow.
  2. node_id: the id of the node where to upload the files (e.g. docemb-0).
  3. org: your organization name.

The body of the request needs to be a list of files opened in bytes. Additionally, the request needs to be signed with your private api key. Example of usage:

import requests

# API endpoint URL
url = f"https://stack-intext.onrender.com/index_documents_api?flow_id={'FLOW_ID'}&node_id={'NODE_ID'}&org={'YOUR_ORGANIZATION'}"

# Request data
headers = {
    "Authorization": "Bearer <PRIVATE_API_KEY>",
}

# Make the API request

List_of_file_paths = ["path_to_your_file1", "path_to_your_file2", "path_to_your_file3"]

file_list = [("files", open(file_path, "rb")) for file_path in List_of_file_paths]


response = requests.post(url, files=file_list, headers=headers)

# Check the response
if response.status_code == 200:
    print("API request successful")
else:
    print("api failed")