Inspecting File Search Chunks

According to the documentation available here: https://platform.openai.com/docs/assistants/tools/file-search, it is possible to retrieve and inspect the file-search chunks that were used by the Assistants API by using the include parameter when retrieving the appropriate run step:

run_step = client.beta.threads.runs.steps.retrieve(
    thread_id="thread_abc123",
    run_id="run_abc123",
    step_id="step_abc123",
    include=["step_details.tool_calls[*].file_search.results[*].content"]
)

However, I am not returning anything extra informaiton when using include. I have checked every run step for the the run, and I know that there are at least 15k tokens worth of context that were used in the last thread I tested this with (not to mention that numerous FileCitations included in the Assistant’s response).

Has anyone actually seen this work? I can’t find any examples on the web of what the response should even look like.

If it is working for other people, is there anyone who is using AzureOpenAI who has this working properly? I know they don’t necessarily always maintain feature parity with OpenAI directly.

I am also facing the same issue,where i would need to know the chunk or index of the text being used in generating the response .
Did you make it work ? @compassjeff

1 Like

@compassjeff I got it to work by modifying the code a bit (used “extra_query=” to insert the “include”):

run_step_details = sync_client.beta.threads.runs.steps.retrieve(
                thread_id="thread_abc123",
                run_id="run_abc123",
                step_id="step_abc123",
                extra_query={
                    "include": ["step_details.tool_calls[*].file_search.results[*].content"]
                }
            )

Then I looped through the steps, excluded steps where there were no chunks, and retrieved the chunks from the step that had them. Hopefully this helps!