OpenAI:
i wont analsye a pdf file like ocr demo:
if lowercase(ExtractFileExt(opendialog1.FileName))='.pdf' then begin
TMSMCPCloudAI1.Context.Clear;
TMSMCPCloudAI1.Context.Text := Me_Promt.Lines.Text;
TMSMCPCloudAI1.AddFile(fname1, aiftPDF);
end else begin
TMSMCPCloudAI1.Context.Clear;
TMSMCPCloudAI1.Context.Text := 'extract the text from the picture';
TMSMCPCloudAI1.AddFile(fname1, aiftImage);
end;
TMSMCPCloudAI1.Execute;
it don't working i think the pdf file is not uploades.
if i do this with the chatgpt web side it working .....
Please see the demo AIFiles under Demo\AIDemos that shows how to create for OpenAI an assistant and run a thread on it
this code is from your ocr demo
TMSMCPCloudAI1.Context.Text := 'extract the text from the picture';
TMSMCPCloudAI1.AddFile(fname1, aiftImage);
my test with pdf is this:
TMSMCPCloudAI1.Context.Text := 'extract the text from the pdf document';
TMSMCPCloudAI1.AddFile(fname1, aiftPDF);
Afaik, OpenAI video model doesn’t handle PDF text extraction.
OpenAI prescribes the Assistant approach for this demonstrated in the AIFiles demo
your sample dont run correct:
after upload
TMSMCPCloudAI1.Files.Count = 0
i have set a open ai key
procedure TForm1.TMSMCPCloudAI1FileUpload(Sender: TObject;
HttpStatusCode: Integer; HttpResult: string; Index: Integer);
var
li: TListItem;
begin
li := ListView1.Items.Add;
if TMSMCPCloudAI1.Files.Count>0 then begin
FileToListItem(TMSMCPCloudAI1.Files.Count-1, li);
end;
end;
i have debug and the response after upload is:
'{'#$A' "error": {'#$A' "message": "Invalid Content-Type header (application/json,multipart/form-data; boundary=AaB03x), expected multipart/form-data. (HINT: If you''re using curl, you can pass -H ''Content-Type: multipart/form-data'')",'#$A' "type": "invalid_request_error",'#$A' "param": null,'#$A' "code": null'#$A' }'#$A'}'#$A
Do you use the latest version of TMS AI Studio?
i think, i have installed on 05.09 with the new smart setup
We released an update v1.2.2.0 on Sep 12, 2025