Share feedback, ideas and get community help

Updated last year

Removing Citation Annotations from Open AI Assistant Responses

At a glance

The community member is impressed with the implementation of the Open AI Assistants API in an application, but has an issue with the citations that get printed in the responses, such as "【9†source】". This is a problem when the response is passed to a TTS block, as the AI ends up speaking the citation itself. The community member is looking for a way to remove the citations or have them work as something the user can click instead of displaying on screen.

In the comments, another community member has found a solution using JavaScript to remove the citations by replacing them with an empty string. The code is provided as a potential solution for others with a similar issue.

Another community member thanks the original poster for the feedback and mentions that they did not know the assistant automatically appends the annotations to the message.

There is no explicitly marked answer, but the solution provided in the comments can be considered the answer to the original issue.

Useful resources
First of all, this is perhaps the BEST implementation of Open AI Assistants API I've seen in an application. Thank you.

My issue is with the citations that get printed in responses such as 【9†source】. They're particularly a problem when I pass the response to a TTS block as the AI ends up speaking the citation itself ("nine plus source").

Is there a way to remove the citation? Or get it to work as something the user can click instead of displaying on screen (I'm not a developer, but saw something about this in the docs here: https://platform.openai.com/docs/assistants/how-it-works/message-annotations).
J
B
3 comments
[SOLVED] I'm not a coder but ChatGPT helped me with this and I found a way to remove the citations by setting a variable with Javascript. In case anyone else might have a similar need, the code is below:

const inputText = {{Assistant Message}};

const regex = /【\d+†source】/g;

const outputText = inputText.replace(regex, '');

return outputText;
Thanks for the feedback I did not know the assistant automatically append the annotations to the message.
Add a reply
Sign up and join the conversation on Discord