File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1919 ChatCompletionToolMessageParam ,
2020 ChatCompletionUserMessageParam ,
2121)
22+ from openai .types .chat .chat_completion_content_part_param import File , FileFile
2223from openai .types .chat .chat_completion_tool_param import ChatCompletionToolParam
2324from openai .types .chat .completion_create_params import ResponseFormat
2425from openai .types .responses import (
2728 ResponseFunctionToolCall ,
2829 ResponseFunctionToolCallParam ,
2930 ResponseInputContentParam ,
31+ ResponseInputFileParam ,
3032 ResponseInputImageParam ,
3133 ResponseInputTextParam ,
3234 ResponseOutputMessage ,
@@ -251,7 +253,19 @@ def extract_all_content(
251253 )
252254 )
253255 elif isinstance (c , dict ) and c .get ("type" ) == "input_file" :
254- raise UserError (f"File uploads are not supported for chat completions { c } " )
256+ casted_file_param = cast (ResponseInputFileParam , c )
257+ if "file_data" not in casted_file_param or not casted_file_param ["file_data" ]:
258+ raise UserError (
259+ f"Only file_data is supported for input_file { casted_file_param } "
260+ )
261+ out .append (
262+ File (
263+ type = "file" ,
264+ file = FileFile (
265+ file_data = casted_file_param ["file_data" ],
266+ ),
267+ )
268+ )
255269 else :
256270 raise UserError (f"Unknown content: { c } " )
257271 return out
You can’t perform that action at this time.
0 commit comments