Hello everyone,
I’m working with the OpenAI Assistant API in a Node.js environment, and I’m encountering an issue with getting accurate reference information from files used in the file search tool. Specifically, I want the assistant to extract verbatim text from the file without hallucinating or providing inaccurate references.
Context:
- Programming Language: JavaScript/Node.js
- Current Implementation:
// Add message to thread
const createdMessage = await openai.beta.threads.messages.create(
threadId,
{
role: 'user',
content: `${message}\n\nAfter each answer where you reference files from your knowledge, you must include references in this format:\n\n
### References
[filename of file referenced]
> Extracted content of the references\n
If you don't reference any files in your answer, do not include the References section.`
}
)
What I’ve Tried:
- I included specific instructions in the message content to guide the assistant’s responses.
- I included instructions in the top of the system message, as well
- Got the idea from this community post.
Issue:
- The assistant’s responses are inconsistent.
- Sometimes it hallucinates the extracted content instead of providing verbatim text from the file.
Desired Outcome:
- The assistant should accurately extract and return verbatim text from the specified file (a good example is Google’s NotebookLM ).
- It should include references in the specified format without adding any hallucinated content.
Question:
How can I adjust my implementation to improve the assistant’s accuracy in extracting verbatim text from files? Are there best practices or additional parameters I should use with the Assistant API to prevent hallucinations and ensure consistent responses?
Any guidance or suggestions would be greatly appreciated!