Skip to content

Commit

Permalink
feat(api): add enum to model param for message (#371)
Browse files Browse the repository at this point in the history
also removes claude-3 from text completions enum
  • Loading branch information
stainless-bot authored Mar 6, 2024
1 parent 37c469d commit f96765f
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 25 deletions.
16 changes: 8 additions & 8 deletions src/anthropic/resources/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -149,7 +149,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
stream: Literal[True],
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -258,7 +258,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
stream: bool,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -367,7 +367,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -421,7 +421,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -530,7 +530,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
stream: Literal[True],
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -639,7 +639,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
stream: bool,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -748,7 +748,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]],
model: Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down
100 changes: 85 additions & 15 deletions src/anthropic/resources/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import List, Iterable, overload
from typing import List, Union, Iterable, overload
from functools import partial
from typing_extensions import Literal

Expand Down Expand Up @@ -50,7 +50,12 @@ def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -240,7 +245,12 @@ def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
stream: Literal[True],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -430,7 +440,12 @@ def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
stream: bool,
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -620,7 +635,12 @@ def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -666,7 +686,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand All @@ -689,7 +714,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand All @@ -712,7 +742,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -776,7 +811,12 @@ async def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -966,7 +1006,12 @@ async def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
stream: Literal[True],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1156,7 +1201,12 @@ async def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
stream: bool,
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1346,7 +1396,12 @@ async def create(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1392,7 +1447,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand All @@ -1415,7 +1475,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand All @@ -1438,7 +1503,12 @@ def stream(
*,
max_tokens: int,
messages: Iterable[MessageParam],
model: str,
model: Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
],
metadata: message_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
system: str | NotGiven = NOT_GIVEN,
Expand Down
2 changes: 1 addition & 1 deletion src/anthropic/types/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CompletionCreateParamsBase(TypedDict, total=False):
only specifies the absolute maximum number of tokens to generate.
"""

model: Required[Union[str, Literal["claude-3-opus-20240229", "claude-2.1", "claude-instant-1"]]]
model: Required[Union[str, Literal["claude-2.0", "claude-2.1", "claude-instant-1.2"]]]
"""The model that will complete your prompt.
See [models](https://docs.anthropic.com/claude/docs/models-overview) for
Expand Down
9 changes: 8 additions & 1 deletion src/anthropic/types/message_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ class MessageCreateParamsBase(TypedDict, total=False):
messages in the Messages API.
"""

model: Required[str]
model: Required[
Union[
str,
Literal[
"claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-2.1'", "claude-2.0", "claude-instant-1.2"
],
]
]
"""The model that will complete your prompt.
See [models](https://docs.anthropic.com/claude/docs/models-overview) for
Expand Down

0 comments on commit f96765f

Please sign in to comment.