- Notifications
You must be signed in to change notification settings - Fork 394
Closed
Description
I install anthropic[vertex]
pip install anthropic[vertex]Then write this code:
def anthropic_transformer(message: str) -> str: from anthropic import AnthropicVertex client = AnthropicVertex(region=LOCATION, project_id=PROJECT) message = client.messages.create( max_tokens=1024, messages=[ { "role": "user", "content": message, } ], model="claude-3-5-sonnet@20240620", ) content_text = message.content[0].text if message.content else "" return content_textIt is running into the following exception:
line 7, in anthropic_transformer File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/_utils/_utils.py\", line 275, in wrapper return func(*args, **kwargs) File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/resources/messages.py\", line 888, in create return self._post( File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/_base_client.py\", line 1277, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/_base_client.py\", line 954, in request return self._request( File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/_base_client.py\", line 981, in _request self._prepare_request(request) File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/lib/vertex/_client.py\", line 159, in _prepare_request request.headers[\"Authorization\"] = f\"Bearer {self._ensure_access_token()}\" File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/lib/vertex/_client.py\", line 166, in _ensure_access_token self.credentials, project_id = load_auth(project_id=self.project_id) File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/anthropic/lib/vertex/_auth.py\", line 19, in load_auth from google.auth.transport.requests import Request # type: ignore[import-untyped] File \"/layers/google.python.pip/pip/lib/python3.10/site-packages/google/auth/transport/requests.py\", line 28, in <module> raise ImportError( ImportError: The requests library is not installed from please install the requests package to use the requests transport. "} . Looks like google-auth needs requests library:
google-auth defined "requests" extra:
But anthropic[vertex] uses plain google-auth dependency:
anthropic-sdk-python/pyproject.toml
Line 39 in a3c59fc
| vertex = ["google-auth >=2, <3"] |
vladimir-kozyrev, dhalturin, sergkondr and arslanbekov
Metadata
Metadata
Assignees
Labels
No labels