From 24dbb498685d5acd6ee15f37212fba225059334a Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Thu, 23 Jan 2025 16:48:19 +0000 Subject: [PATCH] feat(api): add citations --- .stats.yml | 2 +- api.md | 26 ++++++++ .../resources/beta/messages/batches.py | 16 ++--- src/anthropic/resources/messages/batches.py | 16 ++--- src/anthropic/types/__init__.py | 15 +++++ src/anthropic/types/beta/__init__.py | 17 ++++++ .../types/beta/beta_base64_pdf_block_param.py | 19 ++++-- .../types/beta/beta_citation_char_location.py | 22 +++++++ .../beta/beta_citation_char_location_param.py | 22 +++++++ .../beta_citation_content_block_location.py | 22 +++++++ ...a_citation_content_block_location_param.py | 22 +++++++ .../types/beta/beta_citation_page_location.py | 22 +++++++ .../beta/beta_citation_page_location_param.py | 22 +++++++ .../types/beta/beta_citations_config_param.py | 11 ++++ .../types/beta/beta_citations_delta.py | 23 +++++++ ...beta_content_block_source_content_param.py | 13 ++++ .../beta/beta_content_block_source_param.py | 16 +++++ .../beta/beta_plain_text_source_param.py | 15 +++++ .../beta_raw_content_block_delta_event.py | 8 ++- src/anthropic/types/beta/beta_text_block.py | 10 ++++ .../types/beta/beta_text_block_param.py | 5 +- .../types/beta/beta_text_citation.py | 16 +++++ .../types/beta/beta_text_citation_param.py | 16 +++++ src/anthropic/types/citation_char_location.py | 22 +++++++ .../types/citation_char_location_param.py | 22 +++++++ .../types/citation_content_block_location.py | 22 +++++++ .../citation_content_block_location_param.py | 22 +++++++ src/anthropic/types/citation_page_location.py | 22 +++++++ .../types/citation_page_location_param.py | 22 +++++++ src/anthropic/types/citations_config_param.py | 11 ++++ src/anthropic/types/citations_delta.py | 22 +++++++ .../content_block_source_content_param.py | 13 ++++ .../types/content_block_source_param.py | 16 +++++ src/anthropic/types/document_block_param.py | 19 ++++-- .../types/plain_text_source_param.py | 15 +++++ .../types/raw_content_block_delta_event.py | 6 +- src/anthropic/types/text_block.py | 10 ++++ src/anthropic/types/text_block_param.py | 5 +- src/anthropic/types/text_citation.py | 15 +++++ src/anthropic/types/text_citation_param.py | 16 +++++ .../beta/messages/test_batches.py | 20 +++++++ tests/api_resources/beta/test_messages.py | 60 +++++++++++++++++++ tests/api_resources/test_messages.py | 60 +++++++++++++++++++ 43 files changed, 765 insertions(+), 31 deletions(-) create mode 100644 src/anthropic/types/beta/beta_citation_char_location.py create mode 100644 src/anthropic/types/beta/beta_citation_char_location_param.py create mode 100644 src/anthropic/types/beta/beta_citation_content_block_location.py create mode 100644 src/anthropic/types/beta/beta_citation_content_block_location_param.py create mode 100644 src/anthropic/types/beta/beta_citation_page_location.py create mode 100644 src/anthropic/types/beta/beta_citation_page_location_param.py create mode 100644 src/anthropic/types/beta/beta_citations_config_param.py create mode 100644 src/anthropic/types/beta/beta_citations_delta.py create mode 100644 src/anthropic/types/beta/beta_content_block_source_content_param.py create mode 100644 src/anthropic/types/beta/beta_content_block_source_param.py create mode 100644 src/anthropic/types/beta/beta_plain_text_source_param.py create mode 100644 src/anthropic/types/beta/beta_text_citation.py create mode 100644 src/anthropic/types/beta/beta_text_citation_param.py create mode 100644 src/anthropic/types/citation_char_location.py create mode 100644 src/anthropic/types/citation_char_location_param.py create mode 100644 src/anthropic/types/citation_content_block_location.py create mode 100644 src/anthropic/types/citation_content_block_location_param.py create mode 100644 src/anthropic/types/citation_page_location.py create mode 100644 src/anthropic/types/citation_page_location_param.py create mode 100644 src/anthropic/types/citations_config_param.py create mode 100644 src/anthropic/types/citations_delta.py create mode 100644 src/anthropic/types/content_block_source_content_param.py create mode 100644 src/anthropic/types/content_block_source_param.py create mode 100644 src/anthropic/types/plain_text_source_param.py create mode 100644 src/anthropic/types/text_citation.py create mode 100644 src/anthropic/types/text_citation_param.py diff --git a/.stats.yml b/.stats.yml index c809f63..e7d0669 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 21 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-75f0573c3d6d79650bcbd8b1b4fcf93ce146d567afeb1061cd4afccf8d1d6799.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-7270ee0a79d885681ee507414608229f61c27f47c40f355dcd210b38aa7cddf1.yml diff --git a/api.md b/api.md index 86fbe0d..6cc3d20 100644 --- a/api.md +++ b/api.md @@ -24,9 +24,19 @@ Types: from anthropic.types import ( Base64PDFSource, CacheControlEphemeral, + CitationCharLocation, + CitationCharLocationParam, + CitationContentBlockLocation, + CitationContentBlockLocationParam, + CitationPageLocation, + CitationPageLocationParam, + CitationsConfigParam, + CitationsDelta, ContentBlock, ContentBlockDeltaEvent, ContentBlockParam, + ContentBlockSource, + ContentBlockSourceContent, ContentBlockStartEvent, ContentBlockStopEvent, DocumentBlockParam, @@ -42,6 +52,7 @@ from anthropic.types import ( MessageTokensCount, Metadata, Model, + PlainTextSource, RawContentBlockDeltaEvent, RawContentBlockStartEvent, RawContentBlockStopEvent, @@ -51,6 +62,8 @@ from anthropic.types import ( RawMessageStreamEvent, TextBlock, TextBlockParam, + TextCitation, + TextCitationParam, TextDelta, Tool, ToolChoice, @@ -152,8 +165,18 @@ from anthropic.types.beta import ( BetaBase64PDFBlock, BetaBase64PDFSource, BetaCacheControlEphemeral, + BetaCitationCharLocation, + BetaCitationCharLocationParam, + BetaCitationContentBlockLocation, + BetaCitationContentBlockLocationParam, + BetaCitationPageLocation, + BetaCitationPageLocationParam, + BetaCitationsConfigParam, + BetaCitationsDelta, BetaContentBlock, BetaContentBlockParam, + BetaContentBlockSource, + BetaContentBlockSourceContent, BetaImageBlockParam, BetaInputJSONDelta, BetaMessage, @@ -161,6 +184,7 @@ from anthropic.types.beta import ( BetaMessageParam, BetaMessageTokensCount, BetaMetadata, + BetaPlainTextSource, BetaRawContentBlockDeltaEvent, BetaRawContentBlockStartEvent, BetaRawContentBlockStopEvent, @@ -170,6 +194,8 @@ from anthropic.types.beta import ( BetaRawMessageStreamEvent, BetaTextBlock, BetaTextBlockParam, + BetaTextCitation, + BetaTextCitationParam, BetaTextDelta, BetaTool, BetaToolBash20241022, diff --git a/src/anthropic/resources/beta/messages/batches.py b/src/anthropic/resources/beta/messages/batches.py index 7b5c9e2..fb8cc12 100644 --- a/src/anthropic/resources/beta/messages/batches.py +++ b/src/anthropic/resources/beta/messages/batches.py @@ -238,11 +238,11 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> BetaDeletedMessageBatch: - """This endpoint is idempotent and can be used to poll for Message Batch - completion. + """ + Delete a Message Batch. - To access the results of a Message Batch, make a request to the - `results_url` field in the response. + Message Batches can only be deleted once they've finished processing. If you'd + like to delete an in-progress batch, you must first cancel it. Args: message_batch_id: ID of the Message Batch. @@ -600,11 +600,11 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> BetaDeletedMessageBatch: - """This endpoint is idempotent and can be used to poll for Message Batch - completion. + """ + Delete a Message Batch. - To access the results of a Message Batch, make a request to the - `results_url` field in the response. + Message Batches can only be deleted once they've finished processing. If you'd + like to delete an in-progress batch, you must first cancel it. Args: message_batch_id: ID of the Message Batch. diff --git a/src/anthropic/resources/messages/batches.py b/src/anthropic/resources/messages/batches.py index 90a40d5..de1dd7d 100644 --- a/src/anthropic/resources/messages/batches.py +++ b/src/anthropic/resources/messages/batches.py @@ -191,11 +191,11 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> DeletedMessageBatch: - """This endpoint is idempotent and can be used to poll for Message Batch - completion. + """ + Delete a Message Batch. - To access the results of a Message Batch, make a request to the - `results_url` field in the response. + Message Batches can only be deleted once they've finished processing. If you'd + like to delete an in-progress batch, you must first cancel it. Args: message_batch_id: ID of the Message Batch. @@ -469,11 +469,11 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> DeletedMessageBatch: - """This endpoint is idempotent and can be used to poll for Message Batch - completion. + """ + Delete a Message Batch. - To access the results of a Message Batch, make a request to the - `results_url` field in the response. + Message Batches can only be deleted once they've finished processing. If you'd + like to delete an in-progress batch, you must first cancel it. Args: message_batch_id: ID of the Message Batch. diff --git a/src/anthropic/types/__init__.py b/src/anthropic/types/__init__.py index a880b82..5d7d3d7 100644 --- a/src/anthropic/types/__init__.py +++ b/src/anthropic/types/__init__.py @@ -27,9 +27,11 @@ from .model_param import ModelParam as ModelParam from .content_block import ContentBlock as ContentBlock from .message_param import MessageParam as MessageParam +from .text_citation import TextCitation as TextCitation from .beta_api_error import BetaAPIError as BetaAPIError from .metadata_param import MetadataParam as MetadataParam from .tool_use_block import ToolUseBlock as ToolUseBlock +from .citations_delta import CitationsDelta as CitationsDelta from .input_json_delta import InputJSONDelta as InputJSONDelta from .text_block_param import TextBlockParam as TextBlockParam from .image_block_param import ImageBlockParam as ImageBlockParam @@ -42,6 +44,7 @@ from .message_delta_event import MessageDeltaEvent as MessageDeltaEvent from .message_delta_usage import MessageDeltaUsage as MessageDeltaUsage from .message_start_event import MessageStartEvent as MessageStartEvent +from .text_citation_param import TextCitationParam as TextCitationParam from .anthropic_beta_param import AnthropicBetaParam as AnthropicBetaParam from .beta_not_found_error import BetaNotFoundError as BetaNotFoundError from .document_block_param import DocumentBlockParam as DocumentBlockParam @@ -53,10 +56,14 @@ from .beta_rate_limit_error import BetaRateLimitError as BetaRateLimitError from .message_create_params import MessageCreateParams as MessageCreateParams from .tool_choice_any_param import ToolChoiceAnyParam as ToolChoiceAnyParam +from .citation_char_location import CitationCharLocation as CitationCharLocation +from .citation_page_location import CitationPageLocation as CitationPageLocation +from .citations_config_param import CitationsConfigParam as CitationsConfigParam from .raw_message_stop_event import RawMessageStopEvent as RawMessageStopEvent from .tool_choice_auto_param import ToolChoiceAutoParam as ToolChoiceAutoParam from .tool_choice_tool_param import ToolChoiceToolParam as ToolChoiceToolParam from .base64_pdf_source_param import Base64PDFSourceParam as Base64PDFSourceParam +from .plain_text_source_param import PlainTextSourceParam as PlainTextSourceParam from .raw_message_delta_event import RawMessageDeltaEvent as RawMessageDeltaEvent from .raw_message_start_event import RawMessageStartEvent as RawMessageStartEvent from .tool_result_block_param import ToolResultBlockParam as ToolResultBlockParam @@ -68,8 +75,16 @@ from .content_block_start_event import ContentBlockStartEvent as ContentBlockStartEvent from .beta_gateway_timeout_error import BetaGatewayTimeoutError as BetaGatewayTimeoutError from .beta_invalid_request_error import BetaInvalidRequestError as BetaInvalidRequestError +from .content_block_source_param import ContentBlockSourceParam as ContentBlockSourceParam from .message_count_tokens_params import MessageCountTokensParams as MessageCountTokensParams +from .citation_char_location_param import CitationCharLocationParam as CitationCharLocationParam +from .citation_page_location_param import CitationPageLocationParam as CitationPageLocationParam from .raw_content_block_stop_event import RawContentBlockStopEvent as RawContentBlockStopEvent from .cache_control_ephemeral_param import CacheControlEphemeralParam as CacheControlEphemeralParam from .raw_content_block_delta_event import RawContentBlockDeltaEvent as RawContentBlockDeltaEvent from .raw_content_block_start_event import RawContentBlockStartEvent as RawContentBlockStartEvent +from .citation_content_block_location import CitationContentBlockLocation as CitationContentBlockLocation +from .content_block_source_content_param import ContentBlockSourceContentParam as ContentBlockSourceContentParam +from .citation_content_block_location_param import ( + CitationContentBlockLocationParam as CitationContentBlockLocationParam, +) diff --git a/src/anthropic/types/beta/__init__.py b/src/anthropic/types/beta/__init__.py index c233d9c..142f24a 100644 --- a/src/anthropic/types/beta/__init__.py +++ b/src/anthropic/types/beta/__init__.py @@ -11,8 +11,10 @@ from .model_list_params import ModelListParams as ModelListParams from .beta_content_block import BetaContentBlock as BetaContentBlock from .beta_message_param import BetaMessageParam as BetaMessageParam +from .beta_text_citation import BetaTextCitation as BetaTextCitation from .beta_metadata_param import BetaMetadataParam as BetaMetadataParam from .beta_tool_use_block import BetaToolUseBlock as BetaToolUseBlock +from .beta_citations_delta import BetaCitationsDelta as BetaCitationsDelta from .beta_input_json_delta import BetaInputJSONDelta as BetaInputJSONDelta from .beta_text_block_param import BetaTextBlockParam as BetaTextBlockParam from .beta_tool_union_param import BetaToolUnionParam as BetaToolUnionParam @@ -21,23 +23,38 @@ from .beta_tool_choice_param import BetaToolChoiceParam as BetaToolChoiceParam from .beta_content_block_param import BetaContentBlockParam as BetaContentBlockParam from .beta_message_delta_usage import BetaMessageDeltaUsage as BetaMessageDeltaUsage +from .beta_text_citation_param import BetaTextCitationParam as BetaTextCitationParam from .beta_message_tokens_count import BetaMessageTokensCount as BetaMessageTokensCount from .beta_tool_use_block_param import BetaToolUseBlockParam as BetaToolUseBlockParam from .beta_tool_choice_any_param import BetaToolChoiceAnyParam as BetaToolChoiceAnyParam from .beta_base64_pdf_block_param import BetaBase64PDFBlockParam as BetaBase64PDFBlockParam +from .beta_citation_char_location import BetaCitationCharLocation as BetaCitationCharLocation +from .beta_citation_page_location import BetaCitationPageLocation as BetaCitationPageLocation +from .beta_citations_config_param import BetaCitationsConfigParam as BetaCitationsConfigParam from .beta_raw_message_stop_event import BetaRawMessageStopEvent as BetaRawMessageStopEvent from .beta_tool_choice_auto_param import BetaToolChoiceAutoParam as BetaToolChoiceAutoParam from .beta_tool_choice_tool_param import BetaToolChoiceToolParam as BetaToolChoiceToolParam from .message_count_tokens_params import MessageCountTokensParams as MessageCountTokensParams from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam as BetaBase64PDFSourceParam +from .beta_plain_text_source_param import BetaPlainTextSourceParam as BetaPlainTextSourceParam from .beta_raw_message_delta_event import BetaRawMessageDeltaEvent as BetaRawMessageDeltaEvent from .beta_raw_message_start_event import BetaRawMessageStartEvent as BetaRawMessageStartEvent from .beta_tool_result_block_param import BetaToolResultBlockParam as BetaToolResultBlockParam from .beta_raw_message_stream_event import BetaRawMessageStreamEvent as BetaRawMessageStreamEvent from .beta_tool_bash_20241022_param import BetaToolBash20241022Param as BetaToolBash20241022Param +from .beta_content_block_source_param import BetaContentBlockSourceParam as BetaContentBlockSourceParam +from .beta_citation_char_location_param import BetaCitationCharLocationParam as BetaCitationCharLocationParam +from .beta_citation_page_location_param import BetaCitationPageLocationParam as BetaCitationPageLocationParam from .beta_raw_content_block_stop_event import BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam as BetaCacheControlEphemeralParam from .beta_raw_content_block_delta_event import BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent from .beta_raw_content_block_start_event import BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent +from .beta_citation_content_block_location import BetaCitationContentBlockLocation as BetaCitationContentBlockLocation from .beta_tool_text_editor_20241022_param import BetaToolTextEditor20241022Param as BetaToolTextEditor20241022Param from .beta_tool_computer_use_20241022_param import BetaToolComputerUse20241022Param as BetaToolComputerUse20241022Param +from .beta_content_block_source_content_param import ( + BetaContentBlockSourceContentParam as BetaContentBlockSourceContentParam, +) +from .beta_citation_content_block_location_param import ( + BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam, +) diff --git a/src/anthropic/types/beta/beta_base64_pdf_block_param.py b/src/anthropic/types/beta/beta_base64_pdf_block_param.py index 43a2132..dba8317 100644 --- a/src/anthropic/types/beta/beta_base64_pdf_block_param.py +++ b/src/anthropic/types/beta/beta_base64_pdf_block_param.py @@ -2,18 +2,29 @@ from __future__ import annotations -from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing import Union, Optional +from typing_extensions import Literal, Required, TypeAlias, TypedDict +from .beta_citations_config_param import BetaCitationsConfigParam from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam +from .beta_plain_text_source_param import BetaPlainTextSourceParam +from .beta_content_block_source_param import BetaContentBlockSourceParam from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam -__all__ = ["BetaBase64PDFBlockParam"] +__all__ = ["BetaBase64PDFBlockParam", "Source"] + +Source: TypeAlias = Union[BetaBase64PDFSourceParam, BetaPlainTextSourceParam, BetaContentBlockSourceParam] class BetaBase64PDFBlockParam(TypedDict, total=False): - source: Required[BetaBase64PDFSourceParam] + source: Required[Source] type: Required[Literal["document"]] cache_control: Optional[BetaCacheControlEphemeralParam] + + citations: BetaCitationsConfigParam + + context: Optional[str] + + title: Optional[str] diff --git a/src/anthropic/types/beta/beta_citation_char_location.py b/src/anthropic/types/beta/beta_citation_char_location.py new file mode 100644 index 0000000..2109949 --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_char_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["BetaCitationCharLocation"] + + +class BetaCitationCharLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_char_index: int + + start_char_index: int + + type: Literal["char_location"] diff --git a/src/anthropic/types/beta/beta_citation_char_location_param.py b/src/anthropic/types/beta/beta_citation_char_location_param.py new file mode 100644 index 0000000..8c09f5a --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_char_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["BetaCitationCharLocationParam"] + + +class BetaCitationCharLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_char_index: Required[int] + + start_char_index: Required[int] + + type: Required[Literal["char_location"]] diff --git a/src/anthropic/types/beta/beta_citation_content_block_location.py b/src/anthropic/types/beta/beta_citation_content_block_location.py new file mode 100644 index 0000000..8fde76f --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_content_block_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["BetaCitationContentBlockLocation"] + + +class BetaCitationContentBlockLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_block_index: int + + start_block_index: int + + type: Literal["content_block_location"] diff --git a/src/anthropic/types/beta/beta_citation_content_block_location_param.py b/src/anthropic/types/beta/beta_citation_content_block_location_param.py new file mode 100644 index 0000000..9e378a7 --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_content_block_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["BetaCitationContentBlockLocationParam"] + + +class BetaCitationContentBlockLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_block_index: Required[int] + + start_block_index: Required[int] + + type: Required[Literal["content_block_location"]] diff --git a/src/anthropic/types/beta/beta_citation_page_location.py b/src/anthropic/types/beta/beta_citation_page_location.py new file mode 100644 index 0000000..9e6f60d --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_page_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["BetaCitationPageLocation"] + + +class BetaCitationPageLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_page_number: int + + start_page_number: int + + type: Literal["page_location"] diff --git a/src/anthropic/types/beta/beta_citation_page_location_param.py b/src/anthropic/types/beta/beta_citation_page_location_param.py new file mode 100644 index 0000000..60e5b1c --- /dev/null +++ b/src/anthropic/types/beta/beta_citation_page_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["BetaCitationPageLocationParam"] + + +class BetaCitationPageLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_page_number: Required[int] + + start_page_number: Required[int] + + type: Required[Literal["page_location"]] diff --git a/src/anthropic/types/beta/beta_citations_config_param.py b/src/anthropic/types/beta/beta_citations_config_param.py new file mode 100644 index 0000000..409cfde --- /dev/null +++ b/src/anthropic/types/beta/beta_citations_config_param.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["BetaCitationsConfigParam"] + + +class BetaCitationsConfigParam(TypedDict, total=False): + enabled: bool diff --git a/src/anthropic/types/beta/beta_citations_delta.py b/src/anthropic/types/beta/beta_citations_delta.py new file mode 100644 index 0000000..2c6c02b --- /dev/null +++ b/src/anthropic/types/beta/beta_citations_delta.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel +from .beta_citation_char_location import BetaCitationCharLocation +from .beta_citation_page_location import BetaCitationPageLocation +from .beta_citation_content_block_location import BetaCitationContentBlockLocation + +__all__ = ["BetaCitationsDelta", "Citation"] + +Citation: TypeAlias = Annotated[ + Union[BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation], + PropertyInfo(discriminator="type"), +] + + +class BetaCitationsDelta(BaseModel): + citation: Citation + + type: Literal["citations_delta"] diff --git a/src/anthropic/types/beta/beta_content_block_source_content_param.py b/src/anthropic/types/beta/beta_content_block_source_content_param.py new file mode 100644 index 0000000..bc13b14 --- /dev/null +++ b/src/anthropic/types/beta/beta_content_block_source_content_param.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import TypeAlias + +from .beta_text_block_param import BetaTextBlockParam +from .beta_image_block_param import BetaImageBlockParam + +__all__ = ["BetaContentBlockSourceContentParam"] + +BetaContentBlockSourceContentParam: TypeAlias = Union[BetaTextBlockParam, BetaImageBlockParam] diff --git a/src/anthropic/types/beta/beta_content_block_source_param.py b/src/anthropic/types/beta/beta_content_block_source_param.py new file mode 100644 index 0000000..512cf0d --- /dev/null +++ b/src/anthropic/types/beta/beta_content_block_source_param.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +from .beta_content_block_source_content_param import BetaContentBlockSourceContentParam + +__all__ = ["BetaContentBlockSourceParam"] + + +class BetaContentBlockSourceParam(TypedDict, total=False): + content: Required[Union[str, Iterable[BetaContentBlockSourceContentParam]]] + + type: Required[Literal["content"]] diff --git a/src/anthropic/types/beta/beta_plain_text_source_param.py b/src/anthropic/types/beta/beta_plain_text_source_param.py new file mode 100644 index 0000000..187a238 --- /dev/null +++ b/src/anthropic/types/beta/beta_plain_text_source_param.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["BetaPlainTextSourceParam"] + + +class BetaPlainTextSourceParam(TypedDict, total=False): + data: Required[str] + + media_type: Required[Literal["text/plain"]] + + type: Required[Literal["text"]] diff --git a/src/anthropic/types/beta/beta_raw_content_block_delta_event.py b/src/anthropic/types/beta/beta_raw_content_block_delta_event.py index 03ce655..cfe0a3b 100644 --- a/src/anthropic/types/beta/beta_raw_content_block_delta_event.py +++ b/src/anthropic/types/beta/beta_raw_content_block_delta_event.py @@ -1,15 +1,19 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from ..._utils import PropertyInfo from ..._models import BaseModel from .beta_text_delta import BetaTextDelta +from .beta_citations_delta import BetaCitationsDelta from .beta_input_json_delta import BetaInputJSONDelta __all__ = ["BetaRawContentBlockDeltaEvent", "Delta"] -Delta: TypeAlias = Union[BetaTextDelta, BetaInputJSONDelta] +Delta: TypeAlias = Annotated[ + Union[BetaTextDelta, BetaInputJSONDelta, BetaCitationsDelta], PropertyInfo(discriminator="type") +] class BetaRawContentBlockDeltaEvent(BaseModel): diff --git a/src/anthropic/types/beta/beta_text_block.py b/src/anthropic/types/beta/beta_text_block.py index 8c95d7a..f6374b4 100644 --- a/src/anthropic/types/beta/beta_text_block.py +++ b/src/anthropic/types/beta/beta_text_block.py @@ -1,13 +1,23 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import List, Optional from typing_extensions import Literal from ..._models import BaseModel +from .beta_text_citation import BetaTextCitation __all__ = ["BetaTextBlock"] class BetaTextBlock(BaseModel): + citations: Optional[List[BetaTextCitation]] = None + """Citations supporting the text block. + + The type of citation returned will depend on the type of document being cited. + Citing a PDF results in `page_location`, plain text results in `char_location`, + and content document results in `content_block_location`. + """ + text: str type: Literal["text"] diff --git a/src/anthropic/types/beta/beta_text_block_param.py b/src/anthropic/types/beta/beta_text_block_param.py index 4dea557..e40b03a 100644 --- a/src/anthropic/types/beta/beta_text_block_param.py +++ b/src/anthropic/types/beta/beta_text_block_param.py @@ -2,9 +2,10 @@ from __future__ import annotations -from typing import Optional +from typing import Iterable, Optional from typing_extensions import Literal, Required, TypedDict +from .beta_text_citation_param import BetaTextCitationParam from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam __all__ = ["BetaTextBlockParam"] @@ -16,3 +17,5 @@ class BetaTextBlockParam(TypedDict, total=False): type: Required[Literal["text"]] cache_control: Optional[BetaCacheControlEphemeralParam] + + citations: Optional[Iterable[BetaTextCitationParam]] diff --git a/src/anthropic/types/beta/beta_text_citation.py b/src/anthropic/types/beta/beta_text_citation.py new file mode 100644 index 0000000..538878b --- /dev/null +++ b/src/anthropic/types/beta/beta_text_citation.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Annotated, TypeAlias + +from ..._utils import PropertyInfo +from .beta_citation_char_location import BetaCitationCharLocation +from .beta_citation_page_location import BetaCitationPageLocation +from .beta_citation_content_block_location import BetaCitationContentBlockLocation + +__all__ = ["BetaTextCitation"] + +BetaTextCitation: TypeAlias = Annotated[ + Union[BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation], + PropertyInfo(discriminator="type"), +] diff --git a/src/anthropic/types/beta/beta_text_citation_param.py b/src/anthropic/types/beta/beta_text_citation_param.py new file mode 100644 index 0000000..b04c330 --- /dev/null +++ b/src/anthropic/types/beta/beta_text_citation_param.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import TypeAlias + +from .beta_citation_char_location_param import BetaCitationCharLocationParam +from .beta_citation_page_location_param import BetaCitationPageLocationParam +from .beta_citation_content_block_location_param import BetaCitationContentBlockLocationParam + +__all__ = ["BetaTextCitationParam"] + +BetaTextCitationParam: TypeAlias = Union[ + BetaCitationCharLocationParam, BetaCitationPageLocationParam, BetaCitationContentBlockLocationParam +] diff --git a/src/anthropic/types/citation_char_location.py b/src/anthropic/types/citation_char_location.py new file mode 100644 index 0000000..011b106 --- /dev/null +++ b/src/anthropic/types/citation_char_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["CitationCharLocation"] + + +class CitationCharLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_char_index: int + + start_char_index: int + + type: Literal["char_location"] diff --git a/src/anthropic/types/citation_char_location_param.py b/src/anthropic/types/citation_char_location_param.py new file mode 100644 index 0000000..1cc1dfb --- /dev/null +++ b/src/anthropic/types/citation_char_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["CitationCharLocationParam"] + + +class CitationCharLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_char_index: Required[int] + + start_char_index: Required[int] + + type: Required[Literal["char_location"]] diff --git a/src/anthropic/types/citation_content_block_location.py b/src/anthropic/types/citation_content_block_location.py new file mode 100644 index 0000000..0df0ce5 --- /dev/null +++ b/src/anthropic/types/citation_content_block_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["CitationContentBlockLocation"] + + +class CitationContentBlockLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_block_index: int + + start_block_index: int + + type: Literal["content_block_location"] diff --git a/src/anthropic/types/citation_content_block_location_param.py b/src/anthropic/types/citation_content_block_location_param.py new file mode 100644 index 0000000..ee0a6a2 --- /dev/null +++ b/src/anthropic/types/citation_content_block_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["CitationContentBlockLocationParam"] + + +class CitationContentBlockLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_block_index: Required[int] + + start_block_index: Required[int] + + type: Required[Literal["content_block_location"]] diff --git a/src/anthropic/types/citation_page_location.py b/src/anthropic/types/citation_page_location.py new file mode 100644 index 0000000..94c4d50 --- /dev/null +++ b/src/anthropic/types/citation_page_location.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["CitationPageLocation"] + + +class CitationPageLocation(BaseModel): + cited_text: str + + document_index: int + + document_title: Optional[str] = None + + end_page_number: int + + start_page_number: int + + type: Literal["page_location"] diff --git a/src/anthropic/types/citation_page_location_param.py b/src/anthropic/types/citation_page_location_param.py new file mode 100644 index 0000000..483837b --- /dev/null +++ b/src/anthropic/types/citation_page_location_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["CitationPageLocationParam"] + + +class CitationPageLocationParam(TypedDict, total=False): + cited_text: Required[str] + + document_index: Required[int] + + document_title: Required[Optional[str]] + + end_page_number: Required[int] + + start_page_number: Required[int] + + type: Required[Literal["page_location"]] diff --git a/src/anthropic/types/citations_config_param.py b/src/anthropic/types/citations_config_param.py new file mode 100644 index 0000000..817397f --- /dev/null +++ b/src/anthropic/types/citations_config_param.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["CitationsConfigParam"] + + +class CitationsConfigParam(TypedDict, total=False): + enabled: bool diff --git a/src/anthropic/types/citations_delta.py b/src/anthropic/types/citations_delta.py new file mode 100644 index 0000000..3eab03d --- /dev/null +++ b/src/anthropic/types/citations_delta.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Literal, Annotated, TypeAlias + +from .._utils import PropertyInfo +from .._models import BaseModel +from .citation_char_location import CitationCharLocation +from .citation_page_location import CitationPageLocation +from .citation_content_block_location import CitationContentBlockLocation + +__all__ = ["CitationsDelta", "Citation"] + +Citation: TypeAlias = Annotated[ + Union[CitationCharLocation, CitationPageLocation, CitationContentBlockLocation], PropertyInfo(discriminator="type") +] + + +class CitationsDelta(BaseModel): + citation: Citation + + type: Literal["citations_delta"] diff --git a/src/anthropic/types/content_block_source_content_param.py b/src/anthropic/types/content_block_source_content_param.py new file mode 100644 index 0000000..0e70cd2 --- /dev/null +++ b/src/anthropic/types/content_block_source_content_param.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import TypeAlias + +from .text_block_param import TextBlockParam +from .image_block_param import ImageBlockParam + +__all__ = ["ContentBlockSourceContentParam"] + +ContentBlockSourceContentParam: TypeAlias = Union[TextBlockParam, ImageBlockParam] diff --git a/src/anthropic/types/content_block_source_param.py b/src/anthropic/types/content_block_source_param.py new file mode 100644 index 0000000..8050f3e --- /dev/null +++ b/src/anthropic/types/content_block_source_param.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +from .content_block_source_content_param import ContentBlockSourceContentParam + +__all__ = ["ContentBlockSourceParam"] + + +class ContentBlockSourceParam(TypedDict, total=False): + content: Required[Union[str, Iterable[ContentBlockSourceContentParam]]] + + type: Required[Literal["content"]] diff --git a/src/anthropic/types/document_block_param.py b/src/anthropic/types/document_block_param.py index 57522e9..e116fa7 100644 --- a/src/anthropic/types/document_block_param.py +++ b/src/anthropic/types/document_block_param.py @@ -2,18 +2,29 @@ from __future__ import annotations -from typing import Optional -from typing_extensions import Literal, Required, TypedDict +from typing import Union, Optional +from typing_extensions import Literal, Required, TypeAlias, TypedDict +from .citations_config_param import CitationsConfigParam from .base64_pdf_source_param import Base64PDFSourceParam +from .plain_text_source_param import PlainTextSourceParam +from .content_block_source_param import ContentBlockSourceParam from .cache_control_ephemeral_param import CacheControlEphemeralParam -__all__ = ["DocumentBlockParam"] +__all__ = ["DocumentBlockParam", "Source"] + +Source: TypeAlias = Union[Base64PDFSourceParam, PlainTextSourceParam, ContentBlockSourceParam] class DocumentBlockParam(TypedDict, total=False): - source: Required[Base64PDFSourceParam] + source: Required[Source] type: Required[Literal["document"]] cache_control: Optional[CacheControlEphemeralParam] + + citations: CitationsConfigParam + + context: Optional[str] + + title: Optional[str] diff --git a/src/anthropic/types/plain_text_source_param.py b/src/anthropic/types/plain_text_source_param.py new file mode 100644 index 0000000..a2a3b8d --- /dev/null +++ b/src/anthropic/types/plain_text_source_param.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["PlainTextSourceParam"] + + +class PlainTextSourceParam(TypedDict, total=False): + data: Required[str] + + media_type: Required[Literal["text/plain"]] + + type: Required[Literal["text"]] diff --git a/src/anthropic/types/raw_content_block_delta_event.py b/src/anthropic/types/raw_content_block_delta_event.py index 8785197..b8e7b81 100644 --- a/src/anthropic/types/raw_content_block_delta_event.py +++ b/src/anthropic/types/raw_content_block_delta_event.py @@ -1,15 +1,17 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Union -from typing_extensions import Literal, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias +from .._utils import PropertyInfo from .._models import BaseModel from .text_delta import TextDelta +from .citations_delta import CitationsDelta from .input_json_delta import InputJSONDelta __all__ = ["RawContentBlockDeltaEvent", "Delta"] -Delta: TypeAlias = Union[TextDelta, InputJSONDelta] +Delta: TypeAlias = Annotated[Union[TextDelta, InputJSONDelta, CitationsDelta], PropertyInfo(discriminator="type")] class RawContentBlockDeltaEvent(BaseModel): diff --git a/src/anthropic/types/text_block.py b/src/anthropic/types/text_block.py index f06083d..ecdddb6 100644 --- a/src/anthropic/types/text_block.py +++ b/src/anthropic/types/text_block.py @@ -1,13 +1,23 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import List, Optional from typing_extensions import Literal from .._models import BaseModel +from .text_citation import TextCitation __all__ = ["TextBlock"] class TextBlock(BaseModel): + citations: Optional[List[TextCitation]] = None + """Citations supporting the text block. + + The type of citation returned will depend on the type of document being cited. + Citing a PDF results in `page_location`, plain text results in `char_location`, + and content document results in `content_block_location`. + """ + text: str type: Literal["text"] diff --git a/src/anthropic/types/text_block_param.py b/src/anthropic/types/text_block_param.py index 0b27ee2..9215173 100644 --- a/src/anthropic/types/text_block_param.py +++ b/src/anthropic/types/text_block_param.py @@ -2,9 +2,10 @@ from __future__ import annotations -from typing import Optional +from typing import Iterable, Optional from typing_extensions import Literal, Required, TypedDict +from .text_citation_param import TextCitationParam from .cache_control_ephemeral_param import CacheControlEphemeralParam __all__ = ["TextBlockParam"] @@ -16,3 +17,5 @@ class TextBlockParam(TypedDict, total=False): type: Required[Literal["text"]] cache_control: Optional[CacheControlEphemeralParam] + + citations: Optional[Iterable[TextCitationParam]] diff --git a/src/anthropic/types/text_citation.py b/src/anthropic/types/text_citation.py new file mode 100644 index 0000000..159771a --- /dev/null +++ b/src/anthropic/types/text_citation.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Annotated, TypeAlias + +from .._utils import PropertyInfo +from .citation_char_location import CitationCharLocation +from .citation_page_location import CitationPageLocation +from .citation_content_block_location import CitationContentBlockLocation + +__all__ = ["TextCitation"] + +TextCitation: TypeAlias = Annotated[ + Union[CitationCharLocation, CitationPageLocation, CitationContentBlockLocation], PropertyInfo(discriminator="type") +] diff --git a/src/anthropic/types/text_citation_param.py b/src/anthropic/types/text_citation_param.py new file mode 100644 index 0000000..8e98814 --- /dev/null +++ b/src/anthropic/types/text_citation_param.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import TypeAlias + +from .citation_char_location_param import CitationCharLocationParam +from .citation_page_location_param import CitationPageLocationParam +from .citation_content_block_location_param import CitationContentBlockLocationParam + +__all__ = ["TextCitationParam"] + +TextCitationParam: TypeAlias = Union[ + CitationCharLocationParam, CitationPageLocationParam, CitationContentBlockLocationParam +] diff --git a/tests/api_resources/beta/messages/test_batches.py b/tests/api_resources/beta/messages/test_batches.py index 67cd66c..6e532e9 100644 --- a/tests/api_resources/beta/messages/test_batches.py +++ b/tests/api_resources/beta/messages/test_batches.py @@ -67,6 +67,16 @@ def test_method_create_with_all_params(self, client: Anthropic) -> None: "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], "temperature": 1, @@ -428,6 +438,16 @@ async def test_method_create_with_all_params(self, async_client: AsyncAnthropic) "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], "temperature": 1, diff --git a/tests/api_resources/beta/test_messages.py b/tests/api_resources/beta/test_messages.py index e203f74..1d6fae2 100644 --- a/tests/api_resources/beta/test_messages.py +++ b/tests/api_resources/beta/test_messages.py @@ -53,6 +53,16 @@ def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> No "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -159,6 +169,16 @@ def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> No "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -260,6 +280,16 @@ def test_method_count_tokens_with_all_params(self, client: Anthropic) -> None: "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], tool_choice={ @@ -364,6 +394,16 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -470,6 +510,16 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -571,6 +621,16 @@ async def test_method_count_tokens_with_all_params(self, async_client: AsyncAnth "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], tool_choice={ diff --git a/tests/api_resources/test_messages.py b/tests/api_resources/test_messages.py index da36cf7..06eea7e 100644 --- a/tests/api_resources/test_messages.py +++ b/tests/api_resources/test_messages.py @@ -53,6 +53,16 @@ def test_method_create_with_all_params_overload_1(self, client: Anthropic) -> No "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -157,6 +167,16 @@ def test_method_create_with_all_params_overload_2(self, client: Anthropic) -> No "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -256,6 +276,16 @@ def test_method_count_tokens_with_all_params(self, client: Anthropic) -> None: "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], tool_choice={ @@ -358,6 +388,16 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -462,6 +502,16 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], temperature=1, @@ -561,6 +611,16 @@ async def test_method_count_tokens_with_all_params(self, async_client: AsyncAnth "text": "Today's date is 2024-06-01.", "type": "text", "cache_control": {"type": "ephemeral"}, + "citations": [ + { + "cited_text": "cited_text", + "document_index": 0, + "document_title": "x", + "end_char_index": 0, + "start_char_index": 0, + "type": "char_location", + } + ], } ], tool_choice={