volcengine / volcengine-python-sdk

Apache License 2.0
68 stars 8 forks source link

[BUG]Doubao API fail due to potential server side issue #6

Open NickNYU opened 4 months ago

NickNYU commented 4 months ago

Feature

Doubao PRO - 32

Issue Code

def read(image_path):
    client = Ark(api_key=DOUBAO_API_KEY)
    print("----- standard request -----")
    base64_image = encode_image(image_path)
    completion = client.chat.completions.create(
        model="ep-20240618134341-vkc7n",
        user="user",
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "What’s in this image?"
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": f"data:image/jpeg;base64,{base64_image}"
                        }
                    }
                ]
            }
        ]
    )
    print(completion.choices[0].message.content)

Issue Error

Traceback (most recent call last):
  File "/Users/nick/Develop/aigc/NickBooking/main.py", line 25, in <module>
    read_doubao()
  File "/Users/nick/Develop/aigc/NickBooking/main.py", line 18, in read_doubao
    doubao_client.read(IMAGE_PATH)
  File "/Users/nick/Develop/aigc/NickBooking/doubao/doubao_client.py", line 18, in read
    completion = client.chat.completions.create(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_utils/_utils.py", line 64, in wrapper
    return func(*args, **kwargs)
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/resources/chat/completions.py", line 68, in create
    return self._post(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 555, in post
    ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 567, in request
    return self._request(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 453, in _request
    return self._retry_request(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 502, in _retry_request
    return self._request(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 453, in _request
    return self._retry_request(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 502, in _retry_request
    return self._request(
  File "/Users/nick/Develop/aigc/NickBooking/.venv/lib/python3.10/site-packages/volcenginesdkarkruntime/_base_client.py", line 468, in _request
    raise self._make_status_error_from_response(
volcenginesdkarkruntime._exceptions.ArkInternalServerError: Error code: 500 - {'error': {'code': 'InternalServiceError', 'message': 'The service encountered an unexpected internal error.', 'param': '', 'type': 'InternalServiceError'}}, request_id: 202406182215334Ynl34GqiFBsXauqeWur