Skip to content

Commit

Permalink
docs: update examples to show claude-2.1 (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Dec 13, 2023
1 parent 42a94b3 commit d952e64
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ anthropic = Anthropic(
)

completion = anthropic.completions.create(
model="claude-2",
model="claude-2.1",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} how does a court case get to the Supreme Court?{AI_PROMPT}",
)
Expand All @@ -122,7 +122,7 @@ anthropic = AsyncAnthropic(

async def main():
completion = await anthropic.completions.create(
model="claude-2",
model="claude-2.1",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} how does a court case get to the Supreme Court?{AI_PROMPT}",
)
Expand All @@ -146,7 +146,7 @@ anthropic = Anthropic()
stream = anthropic.completions.create(
prompt=f"{HUMAN_PROMPT} Your prompt here{AI_PROMPT}",
max_tokens_to_sample=300,
model="claude-2",
model="claude-2.1",
stream=True,
)
for completion in stream:
Expand All @@ -163,7 +163,7 @@ anthropic = AsyncAnthropic()
stream = await anthropic.completions.create(
prompt=f"{HUMAN_PROMPT} Your prompt here{AI_PROMPT}",
max_tokens_to_sample=300,
model="claude-2",
model="claude-2.1",
stream=True,
)
async for completion in stream:
Expand Down Expand Up @@ -206,7 +206,7 @@ try:
client.completions.create(
prompt=f"{anthropic.HUMAN_PROMPT} Your prompt here{anthropic.AI_PROMPT}",
max_tokens_to_sample=300,
model="claude-2",
model="claude-2.1",
)
except anthropic.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -253,7 +253,7 @@ anthropic = Anthropic(
anthropic.with_options(max_retries=5).completions.create(
prompt=f"{HUMAN_PROMPT} Can you help me effectively ask for a raise at work?{AI_PROMPT}",
max_tokens_to_sample=300,
model="claude-2",
model="claude-2.1",
)
```

Expand All @@ -280,7 +280,7 @@ anthropic = Anthropic(
anthropic.with_options(timeout=5 * 1000).completions.create(
prompt=f"{HUMAN_PROMPT} Where can I get a good coffee in my neighbourhood?{AI_PROMPT}",
max_tokens_to_sample=300,
model="claude-2",
model="claude-2.1",
)
```

Expand Down Expand Up @@ -338,7 +338,7 @@ from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
anthropic = Anthropic()

response = anthropic.completions.with_raw_response.create(
model="claude-2",
model="claude-2.1",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} how does a court case get to the Supreme Court?{AI_PROMPT}",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async def main() -> None:
client = AsyncAnthropic()

res = await client.completions.create(
model="claude-2",
model="claude-2.1",
prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}",
max_tokens_to_sample=1000,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def main() -> None:
client = Anthropic()

res = client.completions.create(
model="claude-2",
model="claude-2.1",
prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}",
max_tokens_to_sample=1000,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def sync_stream() -> None:
stream = client.completions.create(
prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}",
model="claude-2",
model="claude-2.1",
stream=True,
max_tokens_to_sample=300,
)
Expand All @@ -29,7 +29,7 @@ def sync_stream() -> None:
async def async_stream() -> None:
stream = await async_client.completions.create(
prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}",
model="claude-2",
model="claude-2.1",
stream=True,
max_tokens_to_sample=300,
)
Expand Down
28 changes: 14 additions & 14 deletions src/anthropic/resources/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -62,7 +62,7 @@ def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -125,7 +125,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
stream: Literal[True],
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -154,7 +154,7 @@ def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -217,7 +217,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
stream: bool,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -246,7 +246,7 @@ def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -309,7 +309,7 @@ def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -361,7 +361,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -390,7 +390,7 @@ async def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -453,7 +453,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
stream: Literal[True],
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -482,7 +482,7 @@ async def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -545,7 +545,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
stream: bool,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -574,7 +574,7 @@ async def create(
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
Expand Down Expand Up @@ -637,7 +637,7 @@ async def create(
self,
*,
max_tokens_to_sample: int,
model: Union[str, Literal["claude-2", "claude-instant-1"]],
model: Union[str, Literal["claude-2.1", "claude-instant-1"]],
prompt: str,
metadata: completion_create_params.Metadata | NotGiven = NOT_GIVEN,
stop_sequences: List[str] | NotGiven = NOT_GIVEN,
Expand Down
4 changes: 2 additions & 2 deletions src/anthropic/types/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class CompletionCreateParamsBase(TypedDict, total=False):
only specifies the absolute maximum number of tokens to generate.
"""

model: Required[Union[str, Literal["claude-2", "claude-instant-1"]]]
model: Required[Union[str, Literal["claude-2.1", "claude-instant-1"]]]
"""The model that will complete your prompt.
As we improve Claude, we develop new versions of it that you can query. This
parameter controls which version of Claude answers your request. Right now we
are offering two model families: Claude, and Claude Instant. You can use them by
setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
setting `model` to `"claude-2.1"` or `"claude-instant-1"`, respectively. See
[models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
additional details.
"""
Expand Down
24 changes: 12 additions & 12 deletions tests/api_resources/test_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestCompletions:
def test_method_create_overload_1(self, client: Anthropic) -> None:
completion = client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert_matches_type(Completion, completion, path=["response"])
Expand All @@ -33,7 +33,7 @@ def test_method_create_overload_1(self, client: Anthropic) -> None:
def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> None:
completion = client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
Expand All @@ -48,7 +48,7 @@ def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> No
def test_raw_response_create_overload_1(self, client: Anthropic) -> None:
response = client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -59,7 +59,7 @@ def test_raw_response_create_overload_1(self, client: Anthropic) -> None:
def test_method_create_overload_2(self, client: Anthropic) -> None:
client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
Expand All @@ -68,7 +68,7 @@ def test_method_create_overload_2(self, client: Anthropic) -> None:
def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> None:
client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
Expand All @@ -82,7 +82,7 @@ def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> No
def test_raw_response_create_overload_2(self, client: Anthropic) -> None:
response = client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
Expand All @@ -99,7 +99,7 @@ class TestAsyncCompletions:
async def test_method_create_overload_1(self, client: AsyncAnthropic) -> None:
completion = await client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert_matches_type(Completion, completion, path=["response"])
Expand All @@ -108,7 +108,7 @@ async def test_method_create_overload_1(self, client: AsyncAnthropic) -> None:
async def test_method_create_with_all_params_overload_1(self, client: AsyncAnthropic) -> None:
completion = await client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string", "string", "string"],
Expand All @@ -123,7 +123,7 @@ async def test_method_create_with_all_params_overload_1(self, client: AsyncAnthr
async def test_raw_response_create_overload_1(self, client: AsyncAnthropic) -> None:
response = await client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -134,7 +134,7 @@ async def test_raw_response_create_overload_1(self, client: AsyncAnthropic) -> N
async def test_method_create_overload_2(self, client: AsyncAnthropic) -> None:
await client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
Expand All @@ -143,7 +143,7 @@ async def test_method_create_overload_2(self, client: AsyncAnthropic) -> None:
async def test_method_create_with_all_params_overload_2(self, client: AsyncAnthropic) -> None:
await client.completions.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
Expand All @@ -157,7 +157,7 @@ async def test_method_create_with_all_params_overload_2(self, client: AsyncAnthr
async def test_raw_response_create_overload_2(self, client: AsyncAnthropic) -> None:
response = await client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-2",
model="claude-2.1",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
Expand Down
Loading

0 comments on commit d952e64

Please sign in to comment.