openai/openai-dotnet

[QUESTION] Is input_file supported using ResponseItem ?

Closed this issue · 2 comments

Is input_file supported while using the following OpenAIResponseClient method?

ClientResult<OpenAIResponse> CreateResponse(
    IEnumerable<ResponseItem> inputItems, 
    ResponseCreationOptions options = null, 
    CancellationToken cancellationToken = default)

I couldn't find a FileInputResponseItem when digging a bit deeper in the library. There is a workaround to use the following method, but then the developer has to deserialize the raw response and play around with it:

ClientResult CreateResponse(
    BinaryContent content, 
    RequestOptions options = null)

I'm trying to avoid working with ClientResult and looking towards ClientResult<OpenAIResponse>.

Thank you for reaching out, @fgbjoki ! Yes, you need to create a user message item via the CreateUserMessageItem factory method of ResponseItem:

public static MessageResponseItem CreateUserMessageItem(IEnumerable<ResponseContentPart> contentParts);

You will pass the input file as a content part, which you can create using either of these methods in ResponseContentPart:

public static ResponseContentPart CreateInputFilePart(BinaryData fileBytes, string fileBytesMediaType, string filename);
public static ResponseContentPart CreateInputFilePart(string fileId);

Thanks, you are the best.