Replies: 1 comment 2 replies
-
I am wondering the same. That's what I do now (basically the same as the example): var chatClient = app.Services.GetRequiredService<IChatClient>();
var message = new ChatMessage(ChatRole.User, $"Extract the information from this PDF file. If not specified, leave the field empty.");
message.Contents.Add(new DataContent(File.ReadAllBytes(filePath), "application/pdf"));
var documentResult = await chatClient.GetResponseAsync<DocumentResult>(message);
Console.WriteLine(documentResult.Result); But the result json is always empty. I can see the DataContent being correct If I extract the text myself or convert the PDF to a png before sending it, it works fine. I am using |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As demonstrated in https://youtu.be/qcp6ufe_XYo?si=7JeVbDOj6e8LF1jl&t=1852, Microsoft.Extensions.AI can extract informations from an image and return a response as a custom class.
What is the best approach to achieving the same with a PDF file?
For example, if my PDFs represent different invoices and I want to extract the title and invoice number, will there be a
PdfContent
type in the future? Alternatively, can I supply the PDF in another way, or is the only option to extract the text (and images) from the PDF myself before providing it to the AI?(I know there are services like https://azure.microsoft.com/en-us/products/ai-services/ai-document-intelligence)
Beta Was this translation helpful? Give feedback.
All reactions