langchain4j
langchain4j copied to clipboard
Support PDF File Input for Openai
OpenAI models support PDF file inputs, but the openai integration currently does not support PDF contents. We should support this added capability. Here's an example http request from their playground following attaching a pdf.
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "get me the 3 most expensive products"
},
{
"type": "file",
"file": {
"file_data": "data:application/pdf;base64,JVBERi0x.....",
"filename": "Sears Craftsman Power and Hand Tools 1994-95_0001.pdf"
}
}
]
}
],
"response_format": {
"type": "text"
},
"temperature": 1,
"max_completion_tokens": 2048,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}'
Can open AI not customize parameters? What if the parameters of the large model are encapsulated and not supported? Cannot extract interfaces or rewrite interface classes to implement custom parameters
@smileyboy2019 check out the PR to see more details.
implemented in https://github.com/langchain4j/langchain4j/pull/3177