I’m moving from the completions API because it’s not giving enough control over the data source results from my Azure AI Search index. I want to use the responses API.
First, I perform query rewrites and retrieve the search results from the index, passing them to the responses instructions.
The result is good, but I want to get something similar to “citations” in the completions API. A list of each citation used in the answer, and a [doc1] or indicator to match the citation within the text.
I think this must be possible somehow because the FileSearch tool will return citations as “annotations” and provide an index for where in the response the citation should go. Do I need to turn my AI Search results into some form of tool? I don’t want to just add a system instruction and rely on the LLM to insert [doc1], [doc2] etc. at the right place and in the right format.
Make your chunked references that are placed into AI context easily discernible by parts that can be cited. Make the parts themselves suggest the captured index that must be cited.
Example:
**Automatic data retrieval (not user-supplied, but knowledge for use in answering)**
- format of knowledge indexing: ⟬chunkIndex⫽lineLength⟭
- format of the citation you will add after writing sourced knowledge:
⟬chunkIndex⫽lineLocation⟭
- example AI response
"Yes, pinball machines parts can also be supplied ⟬5⫽34⟭ by the company."
(referring to chunk 5, and the information approximately at line 34.
I gave an index format similar to the citation format. You might instruct a different format or a different indexing scheme if the AI isn’t clever enough to do its own line citation.
Here is the automated search results across knowledge documents to improve your factual answering.
⟬14⫽30⟭⟬buttons.js⟭ :: 001 Enable cancel after a short delay to avoid accidental immediate cancellation
002 this._clearWaitingTimer();
003 this.waitingTimer = setTimeout(() => {
004 if (this.currentRequest) this.setSubmitButtonState('cancelable');
}, this.waitingDelayMs);
The sculpting of actual data format, its instructions, whether it is automatic or function results, and the parse sequence that the AI would write that it typically would never emit are all up to you ⁐file:rag_techniques.txt⁐chunk:13⁐. I hope that inspires you.