Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
spring-ai provides a method for file upload.
Current Behavior
AI is already capable of parsing files such as PDF, Word, and TXT, and it provides a method for uploading. However, I couldn't find a standard upload method in spring-ai.
openai api:https://platform.openai.com/docs/api-reference/files/create
The official implementation involves uploading a file first, and then including the file ID during the conversation. However, our current Media does not support the construction of file IDs.
{
"action": "next",
"messages": [
{
"id": "aaa203bb-f47f-45b7-858c-4756adbd26f5",
"author": {
"role": "user"
},
"content": {
"content_type": "text",
"parts": [
"这个文件是干啥的"
]
},
"metadata": {
"attachments": [
{
"id": "file-LhE0IzIeapRNGOiKlPXeJgou",
"size": 108341,
"name": "a.txt",
"mime_type": "text/plain",
"file_token_size": 154590
}
]
},
"create_time": 1724399178.736
}
],
"parent_message_id": "aaa1647f-1c2a-4831-93dc-ece299d25a53",
"model": "auto",
"timezone_offset_min": -480,
"suggestions": [],
"history_and_training_disabled": false,
"conversation_mode": {
"kind": "primary_assistant"
},
"force_paragen": false,
"force_paragen_model_slug": "",
"force_nulligen": false,
"force_rate_limit": false,
"reset_rate_limits": false,
"websocket_request_id": "795b1bad-1966-4560-a931-0b739f04e512",
"system_hints": [],
"force_use_sse": true,
"conversation_origin": null
}
Comment From: markpollack
I'd say yes, implement this for now. I'd be interested to see how this works with the completions endpoint, the docs didn't seem that clear. Eventually, we will expand out to provide APIs across the entire openai model ecosystem, but that will be post 1.0 GA.