HemulGM / DelphiOpenAI

OpenAI API wrapper for Delphi. Use ChatGPT, DALL-E, Whisper and other products.
MIT License
232 stars 57 forks source link

Example upload file #47

Open terralogia opened 1 month ago

terralogia commented 1 month ago

Congratulations on the library!

Could you provide an example of how to upload a PDF to the OpenAI API and get a text summary of the content of the PDF?

HemulGM commented 1 month ago

Look this https://stackoverflow.com/questions/77469097/upload-a-pdf-to-chat-gpt-using-the-api

terralogia commented 1 month ago

Good, but

Write code ...

OpenAI := TOpenAI.Create; OpenAI.Token := 'apikey'; OpenAI.BaseURL := 'https://api.openai.com/v1/';

fil := OpenAI.&File.Upload( procedure (para : TFileUploadParams) begin para.Purpose('assistants'); para.&File('file.pdf');

end

);

ast := TAssistantTool.Create; ast.Add('type', 'code_interpreter');

// Runtime error ... Any idea? asi := OpenAI.Assistants.Create(procedure(params : TAssistantParams) begin params.Instructions('Write resume file pdf'); params.Tools([ast]); params.FileIds(varArrayOf([fil.Id])); end);

HemulGM commented 1 month ago

It's abstract class image

HemulGM commented 1 month ago

I have updated this part. Pull the changes