Skip to content

Commit

Permalink
feat(api): add prompt caching beta
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and RobertCraigie committed Aug 14, 2024
1 parent 20487ea commit 3978411
Show file tree
Hide file tree
Showing 28 changed files with 3,332 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 2
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-4769b27b6e13acc458cc71fbadd8676ea8074d76f91e37b96eaa97464c4e97af.yml
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fb94a03f85580f7eacef034518becfb463502e6d74b0f7932f6153239de23a5b.yml
28 changes: 28 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,31 @@ Methods:

- <code title="post /v1/messages">client.messages.<a href="./src/anthropic/resources/messages.py">create</a>(\*\*<a href="src/anthropic/types/message_create_params.py">params</a>) -> <a href="./src/anthropic/types/message.py">Message</a></code>
- <code>client.messages.<a href="./src/anthropic/resources/messages.py">stream</a>(\*args) -> MessageStreamManager[MessageStream] | MessageStreamManager[MessageStreamT]</code>

# Beta

## PromptCaching

### Messages

Types:

```python
from anthropic.types.beta.prompt_caching import (
PromptCachingBetaCacheControlEphemeral,
PromptCachingBetaImageBlockParam,
PromptCachingBetaMessage,
PromptCachingBetaMessageParam,
PromptCachingBetaTextBlockParam,
PromptCachingBetaTool,
PromptCachingBetaToolResultBlockParam,
PromptCachingBetaToolUseBlockParam,
PromptCachingBetaUsage,
RawPromptCachingBetaMessageStartEvent,
RawPromptCachingBetaMessageStreamEvent,
)
```

Methods:

- <code title="post /v1/messages?beta=prompt_caching">client.beta.prompt_caching.messages.<a href="./src/anthropic/resources/beta/prompt_caching/messages.py">create</a>(\*\*<a href="src/anthropic/types/beta/prompt_caching/message_create_params.py">params</a>) -> <a href="./src/anthropic/types/beta/prompt_caching/prompt_caching_beta_message.py">PromptCachingBetaMessage</a></code>
8 changes: 8 additions & 0 deletions src/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
class Anthropic(SyncAPIClient):
completions: resources.Completions
messages: resources.Messages
beta: resources.Beta
with_raw_response: AnthropicWithRawResponse
with_streaming_response: AnthropicWithStreamedResponse

Expand Down Expand Up @@ -136,6 +137,7 @@ def __init__(

self.completions = resources.Completions(self)
self.messages = resources.Messages(self)
self.beta = resources.Beta(self)
self.with_raw_response = AnthropicWithRawResponse(self)
self.with_streaming_response = AnthropicWithStreamedResponse(self)

Expand Down Expand Up @@ -320,6 +322,7 @@ def _make_status_error(
class AsyncAnthropic(AsyncAPIClient):
completions: resources.AsyncCompletions
messages: resources.AsyncMessages
beta: resources.AsyncBeta
with_raw_response: AsyncAnthropicWithRawResponse
with_streaming_response: AsyncAnthropicWithStreamedResponse

Expand Down Expand Up @@ -398,6 +401,7 @@ def __init__(

self.completions = resources.AsyncCompletions(self)
self.messages = resources.AsyncMessages(self)
self.beta = resources.AsyncBeta(self)
self.with_raw_response = AsyncAnthropicWithRawResponse(self)
self.with_streaming_response = AsyncAnthropicWithStreamedResponse(self)

Expand Down Expand Up @@ -583,24 +587,28 @@ class AnthropicWithRawResponse:
def __init__(self, client: Anthropic) -> None:
self.completions = resources.CompletionsWithRawResponse(client.completions)
self.messages = resources.MessagesWithRawResponse(client.messages)
self.beta = resources.BetaWithRawResponse(client.beta)


class AsyncAnthropicWithRawResponse:
def __init__(self, client: AsyncAnthropic) -> None:
self.completions = resources.AsyncCompletionsWithRawResponse(client.completions)
self.messages = resources.AsyncMessagesWithRawResponse(client.messages)
self.beta = resources.AsyncBetaWithRawResponse(client.beta)


class AnthropicWithStreamedResponse:
def __init__(self, client: Anthropic) -> None:
self.completions = resources.CompletionsWithStreamingResponse(client.completions)
self.messages = resources.MessagesWithStreamingResponse(client.messages)
self.beta = resources.BetaWithStreamingResponse(client.beta)


class AsyncAnthropicWithStreamedResponse:
def __init__(self, client: AsyncAnthropic) -> None:
self.completions = resources.AsyncCompletionsWithStreamingResponse(client.completions)
self.messages = resources.AsyncMessagesWithStreamingResponse(client.messages)
self.beta = resources.AsyncBetaWithStreamingResponse(client.beta)


Client = Anthropic
Expand Down
14 changes: 14 additions & 0 deletions src/anthropic/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .beta import (
Beta,
AsyncBeta,
BetaWithRawResponse,
AsyncBetaWithRawResponse,
BetaWithStreamingResponse,
AsyncBetaWithStreamingResponse,
)
from .messages import (
Messages,
AsyncMessages,
Expand Down Expand Up @@ -30,4 +38,10 @@
"AsyncMessagesWithRawResponse",
"MessagesWithStreamingResponse",
"AsyncMessagesWithStreamingResponse",
"Beta",
"AsyncBeta",
"BetaWithRawResponse",
"AsyncBetaWithRawResponse",
"BetaWithStreamingResponse",
"AsyncBetaWithStreamingResponse",
]
33 changes: 33 additions & 0 deletions src/anthropic/resources/beta/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .beta import (
Beta,
AsyncBeta,
BetaWithRawResponse,
AsyncBetaWithRawResponse,
BetaWithStreamingResponse,
AsyncBetaWithStreamingResponse,
)
from .prompt_caching import (
PromptCaching,
AsyncPromptCaching,
PromptCachingWithRawResponse,
AsyncPromptCachingWithRawResponse,
PromptCachingWithStreamingResponse,
AsyncPromptCachingWithStreamingResponse,
)

__all__ = [
"PromptCaching",
"AsyncPromptCaching",
"PromptCachingWithRawResponse",
"AsyncPromptCachingWithRawResponse",
"PromptCachingWithStreamingResponse",
"AsyncPromptCachingWithStreamingResponse",
"Beta",
"AsyncBeta",
"BetaWithRawResponse",
"AsyncBetaWithRawResponse",
"BetaWithStreamingResponse",
"AsyncBetaWithStreamingResponse",
]
81 changes: 81 additions & 0 deletions src/anthropic/resources/beta/beta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from .prompt_caching import (
PromptCaching,
AsyncPromptCaching,
PromptCachingWithRawResponse,
AsyncPromptCachingWithRawResponse,
PromptCachingWithStreamingResponse,
AsyncPromptCachingWithStreamingResponse,
)
from .prompt_caching.prompt_caching import PromptCaching, AsyncPromptCaching

__all__ = ["Beta", "AsyncBeta"]


class Beta(SyncAPIResource):
@cached_property
def prompt_caching(self) -> PromptCaching:
return PromptCaching(self._client)

@cached_property
def with_raw_response(self) -> BetaWithRawResponse:
return BetaWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> BetaWithStreamingResponse:
return BetaWithStreamingResponse(self)


class AsyncBeta(AsyncAPIResource):
@cached_property
def prompt_caching(self) -> AsyncPromptCaching:
return AsyncPromptCaching(self._client)

@cached_property
def with_raw_response(self) -> AsyncBetaWithRawResponse:
return AsyncBetaWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncBetaWithStreamingResponse:
return AsyncBetaWithStreamingResponse(self)


class BetaWithRawResponse:
def __init__(self, beta: Beta) -> None:
self._beta = beta

@cached_property
def prompt_caching(self) -> PromptCachingWithRawResponse:
return PromptCachingWithRawResponse(self._beta.prompt_caching)


class AsyncBetaWithRawResponse:
def __init__(self, beta: AsyncBeta) -> None:
self._beta = beta

@cached_property
def prompt_caching(self) -> AsyncPromptCachingWithRawResponse:
return AsyncPromptCachingWithRawResponse(self._beta.prompt_caching)


class BetaWithStreamingResponse:
def __init__(self, beta: Beta) -> None:
self._beta = beta

@cached_property
def prompt_caching(self) -> PromptCachingWithStreamingResponse:
return PromptCachingWithStreamingResponse(self._beta.prompt_caching)


class AsyncBetaWithStreamingResponse:
def __init__(self, beta: AsyncBeta) -> None:
self._beta = beta

@cached_property
def prompt_caching(self) -> AsyncPromptCachingWithStreamingResponse:
return AsyncPromptCachingWithStreamingResponse(self._beta.prompt_caching)
33 changes: 33 additions & 0 deletions src/anthropic/resources/beta/prompt_caching/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .messages import (
Messages,
AsyncMessages,
MessagesWithRawResponse,
AsyncMessagesWithRawResponse,
MessagesWithStreamingResponse,
AsyncMessagesWithStreamingResponse,
)
from .prompt_caching import (
PromptCaching,
AsyncPromptCaching,
PromptCachingWithRawResponse,
AsyncPromptCachingWithRawResponse,
PromptCachingWithStreamingResponse,
AsyncPromptCachingWithStreamingResponse,
)

__all__ = [
"Messages",
"AsyncMessages",
"MessagesWithRawResponse",
"AsyncMessagesWithRawResponse",
"MessagesWithStreamingResponse",
"AsyncMessagesWithStreamingResponse",
"PromptCaching",
"AsyncPromptCaching",
"PromptCachingWithRawResponse",
"AsyncPromptCachingWithRawResponse",
"PromptCachingWithStreamingResponse",
"AsyncPromptCachingWithStreamingResponse",
]
Loading

0 comments on commit 3978411

Please sign in to comment.