Skip to content

Commit

Permalink
feat(api): add new claude-3-5-sonnet-20240620 model (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Jun 20, 2024
1 parent 3c2b75f commit 5ea6b18
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .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-4f6df1026ffeed840bbfada906ac51144508d1e1b099084c593aa9bac97a3362.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-70873642f89316fbc45ceaccd3583971d0eb59d433f7864ca2fa8c321a320b4c.yml
31 changes: 21 additions & 10 deletions src/anthropic/resources/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from ..types.message import Message
from ..types.tool_param import ToolParam
from ..types.message_param import MessageParam
from ..types.text_block_param import TextBlockParam
from ..types.raw_message_stream_event import RawMessageStreamEvent

__all__ = ["Messages", "AsyncMessages"]
Expand All @@ -50,6 +51,7 @@ def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -61,7 +63,7 @@ def create(
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -324,6 +326,7 @@ def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -335,7 +338,7 @@ def create(
stream: Literal[True],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -598,6 +601,7 @@ def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -609,7 +613,7 @@ def create(
stream: bool,
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -872,6 +876,7 @@ def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -883,7 +888,7 @@ def create(
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -931,6 +936,7 @@ def stream(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -941,7 +947,7 @@ def stream(
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1007,6 +1013,7 @@ async def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -1018,7 +1025,7 @@ async def create(
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1281,6 +1288,7 @@ async def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -1292,7 +1300,7 @@ async def create(
stream: Literal[True],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1555,6 +1563,7 @@ async def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -1566,7 +1575,7 @@ async def create(
stream: bool,
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1829,6 +1838,7 @@ async def create(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -1840,7 +1850,7 @@ async def create(
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
tool_choice: message_create_params.ToolChoice | NotGiven = NOT_GIVEN,
tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1888,6 +1898,7 @@ def stream(
model: Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand All @@ -1898,7 +1909,7 @@ def stream(
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_k: int | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
Expand Down
4 changes: 3 additions & 1 deletion src/anthropic/types/message_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .tool_param import ToolParam
from .message_param import MessageParam
from .text_block_param import TextBlockParam

__all__ = [
"MessageCreateParamsBase",
Expand Down Expand Up @@ -123,6 +124,7 @@ class MessageCreateParamsBase(TypedDict, total=False):
Union[
str,
Literal[
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
Expand Down Expand Up @@ -153,7 +155,7 @@ class MessageCreateParamsBase(TypedDict, total=False):
and the response `stop_sequence` value will contain the matched stop sequence.
"""

system: str
system: Union[str, Iterable[TextBlockParam]]
"""System prompt.
A system prompt is a way of providing context and instructions to Claude, such
Expand Down
60 changes: 40 additions & 20 deletions tests/api_resources/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_method_create_overload_1(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
)
assert_matches_type(Message, message, path=["response"])

Expand All @@ -41,11 +41,16 @@ def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> No
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
stream=False,
system="Today's date is 2024-01-01.",
system=[
{
"type": "text",
"text": "Today's date is 2024-06-01.",
}
],
temperature=1,
tool_choice={"type": "auto"},
tools=[
Expand Down Expand Up @@ -116,7 +121,7 @@ def test_raw_response_create_overload_1(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
)

assert response.is_closed is True
Expand All @@ -134,7 +139,7 @@ def test_streaming_response_create_overload_1(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -154,7 +159,7 @@ def test_method_create_overload_2(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
)
message_stream.response.close()
Expand All @@ -169,11 +174,16 @@ def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> No
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
system="Today's date is 2024-01-01.",
system=[
{
"type": "text",
"text": "Today's date is 2024-06-01.",
}
],
temperature=1,
tool_choice={"type": "auto"},
tools=[
Expand Down Expand Up @@ -244,7 +254,7 @@ def test_raw_response_create_overload_2(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
)

Expand All @@ -262,7 +272,7 @@ def test_streaming_response_create_overload_2(self, client: Anthropic) -> None:
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
) as response:
assert not response.is_closed
Expand All @@ -287,7 +297,7 @@ async def test_method_create_overload_1(self, async_client: AsyncAnthropic) -> N
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
)
assert_matches_type(Message, message, path=["response"])

Expand All @@ -301,11 +311,16 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
stream=False,
system="Today's date is 2024-01-01.",
system=[
{
"type": "text",
"text": "Today's date is 2024-06-01.",
}
],
temperature=1,
tool_choice={"type": "auto"},
tools=[
Expand Down Expand Up @@ -376,7 +391,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncAnthropic
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
)

assert response.is_closed is True
Expand All @@ -394,7 +409,7 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncAnt
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -414,7 +429,7 @@ async def test_method_create_overload_2(self, async_client: AsyncAnthropic) -> N
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
)
await message_stream.response.aclose()
Expand All @@ -429,11 +444,16 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
system="Today's date is 2024-01-01.",
system=[
{
"type": "text",
"text": "Today's date is 2024-06-01.",
}
],
temperature=1,
tool_choice={"type": "auto"},
tools=[
Expand Down Expand Up @@ -504,7 +524,7 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncAnthropic
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
)

Expand All @@ -522,7 +542,7 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncAnt
"content": "Hello, world",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-20240620",
stream=True,
) as response:
assert not response.is_closed
Expand Down

0 comments on commit 5ea6b18

Please sign in to comment.