Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error when sending multiple PDFs in conversation #768

Open
junuMoon opened this issue Dec 2, 2024 · 1 comment
Open

Comments

@junuMoon
Copy link

junuMoon commented Dec 2, 2024

Description

When attempting to have a conversation that includes multiple PDF documents with Claude, the API returns a 500 Internal Server Error. The error occurs specifically when trying to send a second PDF after receiving a response for the first one.

Steps to Reproduce

  1. Initialize a conversation with Claude API
  2. Send first message containing:
    • PDF document (base64 encoded)
    • Text prompt ("1줄 요약")
  3. Receive assistant's response
  4. Send second message with:
    • Different PDF document (base64 encoded)
    • Text prompt ("1줄요약")
  5. API returns 500 Internal Server Error

Code Example

message2 = client.beta.messages.create(
    model="claude-3-5-sonnet-20241022",
    betas=["pdfs-2024-09-25"],
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "document",
                    "source": {
                        "type": "base64",
                        "media_type": "application/pdf",
                        "data": base64_string
                    }
                },
                {
                    "type": "text",
                    "text": "1줄 요약"
                }
            ]
        },
        {
            "role": "assistant",
            "content": message.content[0].text
        },
        {
            "role": "user", 
            "content": [
                {
                    "type": "document",
                    "source": {
                        "type": "base64",
                        "media_type": "application/pdf",
                        "data": base64_string2
                    }
                },
                {
                    "type": "text",
                    "text": "1줄요약"
                }
            ]
        }
    ]
)

Error Message

InternalServerError: Error code: 500 - {'type': 'error', 'error': {'type': 'api_error', 'message': 'Internal server error'}}

Environment

  • Python SDK Version: (version number)
  • Claude Model: claude-3-5-sonnet-20241022
  • Beta Features: ["pdfs-2024-09-25"]

Expected Behavior

The API should handle multiple PDF documents in a conversation, allowing for sequential analysis of different documents.

Additional Context

  • The first PDF upload and response works correctly
  • The error occurs specifically when trying to send a second PDF in the conversation
  • Using the latest beta PDF feature as indicated in the betas parameter

Questions

  1. Is there a limitation on the number of PDFs that can be processed in a single conversation?
  2. Is there a specific way to handle multiple PDF documents in a conversation that I'm missing?
  3. Could this be related to the beta status of the PDF feature?
@DavidSnoble
Copy link

I am also seeing this error by calling the REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants