Hello everyone,
So i implemented a multi granular chunking approach that consists of chunking a document into parent chunks of fixed size and children chunks of smaller sizes, the idea is to apply a vector search on the children vector store, then find their parents and use them as a context. Now imagine I have 10 children, I have to call the file search function 10 times to find the parents (using filters parameter and a meta data called parent_id), I wonder if there is a method to use the parent_id metadata of those 10 children chunks (parent_id1, parent_id2,…,parent_id10), pass them to the file search method only once so that the file search costs only as much as a single call.
You can directly search the vector store to retrieve content.
Then you can cache the retrieved context and use it in as many requests you want.
Example
import openai
import requests
import os
vid="your_vector_store_id"
vector_store = client.vector_stores.retrieve(
vector_store_id=vid
)
print(vector_store)
# API endpoint
url = f"https://api.openai.com/v1/vector_stores/{vid}/search"
# Headers
headers = {
"Authorization": f"Bearer {your_api_key}",
"Content-Type": "application/json"
}
# JSON payload
data = {
"query": "what are strawberries",
"max_num_results": 1
}
# Make the POST request
response = requests.post(url, headers=headers, json=data)
# Output the response
print(response.status_code)
print(response.text)
1 Like