🔧 fix(assistants): Vision minor fix & Add Docs (#2196)

* 👓 fix(assistants): Only Retrieve Assistant Data for Vision Requests if attachments exist in Host Storage

* docs: add  capability
This commit is contained in:
Danny Avila 2024-03-25 00:02:54 -04:00 committed by GitHub
parent 798e8763d0
commit f86d80de59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 25 deletions

View file

@ -363,16 +363,24 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
return;
}
/** @type {MongoFile[]} */
const attachments = await req.body.endpointOption.attachments;
if (
attachments &&
attachments.every((attachment) => attachment.source === FileSources.openai)
) {
return;
}
const assistant = await openai.beta.assistants.retrieve(assistant_id);
const visionToolIndex = assistant.tools.findIndex(
(tool) => tool.function.name === ImageVisionTool.function.name,
(tool) => tool?.function && tool?.function?.name === ImageVisionTool.function.name,
);
if (visionToolIndex === -1) {
return;
}
const attachments = await req.body.endpointOption.attachments;
let visionMessage = {
role: 'user',
content: '',