Skip to content

Commit

Permalink
Fix gptcmd-anthropic on anthropic SDK 0.42.0+
Browse files Browse the repository at this point in the history
Use the standard `messages.create` method since prompt caching is now generally available.

Addresses #1
  • Loading branch information
codeofdusk committed Jan 11, 2025
1 parent 99800a7 commit dcde3f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ classifiers = [
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: OS Independent",
]
dependencies = ["gptcmd>=2.0.0", "anthropic>=0.39.0, <1.0.0"]
dependencies = ["gptcmd>=2.0.0", "anthropic>=0.42.0, <1.0.0"]

[project.urls]
"Homepage" = "https://github.com/codeofdusk/gptcmd-anthropic"
Expand Down
6 changes: 2 additions & 4 deletions src/gptcmd_anthropic/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def _collapse(content1, content2):
]

try:
resp = self._anthropic.beta.prompt_caching.messages.create(
**kwargs
)
resp = self._anthropic.messages.create(**kwargs)
except anthropic.APIError as e:
raise CompletionError(str(e)) from e

Expand Down Expand Up @@ -251,7 +249,7 @@ def validate_api_params(self, params):
valid_opts = (
frozenset(
inspect.signature(
self._anthropic.beta.prompt_caching.messages.create
self._anthropic.messages.create
).parameters.keys()
)
- SPECIAL_OPTS
Expand Down

0 comments on commit dcde3f6

Please sign in to comment.