I’m using the Responses API and the file_search tool to search within a given vector store. For some reason when I don’t specify filters against the attributes of the files things work great. If I specify filters against the attributes nothing is searched. When I retrieve the vector file record the attributes are there. Are we able to ask the responses api file_search tool to only include files based on a set of attribute filters?
What I would do: use the search endpoint alone, and see if your metadata “attributes” rules are working there.
First, make a vector store with multiple files, ones you know will be successful in extraction, and then when they are attached, you add per-file metadata attributes.
Then do your direct API call to the search endpoint, with a rule that can match a key to a desired value - see that you get only that file.
Imagine I pull out the file extension and make that a “filetype” attribute I set. I can now match that with the type of comparison for “equals”:
url = f"https://api.openai.com/v1/vector_stores/{vs_id}/search"
body = {
"query": query_string,
"max_num_results": max_out_int,
"ranking_options": {"ranker":"auto", "score_threshold": 0.3},
"filters": {"key": "filetype","type": "eq","value": "txt"}
}
For queries that would be inclusive of multiple files, you need to be clear with the rule you use - that it can limit by an integer (not string) for things like greater-than, that it has a comparison filter “in” string search that will work, and that you are specifying the right key and trying only one key if not deliberately using and-or.
This helped so much thank you! I was able to get it working great and used your examples. The attributes and filtering did in fact work including both on the file_search tool directly as well as the Responses api.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.