cohere-ai / cohere-python

Python Library for Accessing the Cohere API
https://docs.cohere.ai
MIT License
300 stars 64 forks source link

Add PDF file support as option for documents parameter #589

Closed ai-yann closed 3 weeks ago

ai-yann commented 3 weeks ago

Describe the improvement

Add support for PDF files in the documents parameter, allowing users to provide PDFs directly.

Code snippet of expected outcome

import cohere

co = cohere.ClientV2("<<apiKey>>")

response = co.chat(
    model="command-r-plus",
    documents=[{'id': '1', 'data': {'path': '/path/to/document.pdf'}}],
    messages=[
        {
            "role": "user",
            "content": "What is this document about?"
        }
    ]
)

print(response)

Here is how much code I currently have to write to get the above going: chat_with_pdf.zip

billytrend-cohere commented 3 weeks ago

Hey @ai-yann thanks for suggestion, we won't be implementing this right now because PDF would introduce a lot of complexity with parsing etc. we would currently expect the client to manage this complexity.