如何使用OpenAI API(GPTs)处理PDF?含RAG场景实现疑问
关于OpenAI API接收PDF及RAG场景实现的疑问
- ChatGPT网页端支持便捷的PDF上传功能,想确认OpenAI是否提供可直接接收PDF的API?
- 已知第三方库可读取PDF内容,但考虑到PDF中包含图片等重要信息,直接将原始PDF输入GPT-4 Turbo这类模型可能效果更好。我的使用场景是RAG,此前常规做法是提取文件文本后附加在prompt末尾,手动提取PDF内容也可沿用该方式,但希望了解更直接的方案。
- 以下是一段取自OpenAI官方文档的代码,请问这是否是直接用API处理PDF的正确实现方式?
# Upload a file with an "assistants" purpose file = client.files.create( file=open("example.pdf", "rb"), purpose='assistants' ) # Create an assistant using the file ID assistant = client.beta.assistants.create( instructions="You are a personal math tutor. When asked a math question, write and run code to answer the question.", model="gpt-4-1106-preview", tools=[{"type": "code_interpreter"}], file_ids=[file.id] )
- 注意到OpenAI的文件上传端点似乎主要用于微调与助手功能,但RAG是常见场景,不想依赖助手功能来实现PDF的处理。
内容的提问来源于stack exchange,提问作者Muhammad Mubashirullah Durrani
相关产品推荐
相关产品推荐

