Thanks a lot for replying.. I went through your multipart implementation and it 
helped me understand what is really going to be sent to openai after the 
multipart/form-encoded request has been pieced together from procedure calls 
like multipart.addfiles, multipart[key] = val etc.

>From what I understand every multipart entry is seperated from the others by a 
>boundary(which often looks like ------random boundary ----), which must be 
>kept constant throughout for a single request.

I echoed out the final multipart being sent and this is what I saw:
    
    
    ------------------------------ 0 ------------------------------
    name="image"; filename="pic.png"
    Content-Type: image/png
    
    pic.png
    ------------------------------ 1 ------------------------------
    name="mask"; filename="pic.png"
    Content-Type: image/png
    
    pic.png
    ------------------------------ 2 ------------------------------
    name="prompt"
    
    "A Nice Tesla For Asiwaju"
    ------------------------------ 3 ------------------------------
    name="n"
    
    2
    ------------------------------ 4 ------------------------------
    name="size"
    
    "512x512"
    
    
    
    
    Run

I understand that the output from this my echo is not exact depiction of what 
open ai receives but is just a high-level overview/summary of the whole thing. 
So I echoed the multipart repr and got this:
    
    
    ref 0x7f42a199ed10 --> [content = 0x7f42a1e93230@[[name = 
0x7f42a19f3510"image",
    content = 0x7f42a19f3540"pic.png",
    truefilename = 0x7f42a19f3570"pic.png",
    contentType = 0x7f42a19f35a0"image/png",
    fileSize = 0,
    isStream = true], [name = 0x7f42a1947a50"mask",
    content = 0x7f42a1947a80"pic.png",
    truefilename = 0x7f42a1947ab0"pic.png",
    contentType = 0x7f42a1947ae0"image/png",
    fileSize = 0,
    isStream = true], [name = 0x7f42a1947ba0"prompt",
    content = 0x7f42a19486e0"\"A Nice Tesla For Asiwaju\"",
    false], [name = 0x7f42a1947c60"n",
    content = 0x7f42a1947c90"2",
    false], [name = 0x7f42a1947d80"size",
    content = 0x7f42a1947db0"\"512x512\"",
    false]]]
    
    
    
    Run

which I feel is closer to what actually got sent to the server, except that it 
didnt include the binary file contents for pic.png.

And if you look closely you will see that my "512x512" is now being presented 
as "\"512x512\"", which is why openai is complaining.

> I think you are creating a single entry for the entire json line. But each 
> field in the json needs its > own part entry.

from what I have seen/echoed so far, it doesnt seem like so...

> OpenAI api wants everything int its part.

please am sorry, I dont quite understand what you mean. The only place they 
wanted int was for the n parameter, which I provided as int, the rest where 
strings.

Reply via email to