diff --git a/pyproject.toml b/pyproject.toml index 5ea398af6..6606377f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "cohere" [tool.poetry] name = "cohere" -version = "5.13.8" +version = "6.0.0" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index fc916c9dc..de8fb6edf 100644 --- a/reference.md +++ b/reference.md @@ -11,8 +11,7 @@
-Generates a streamed text response to a user message. - +Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
@@ -28,17 +27,14 @@ To learn how to use the Chat API and RAG follow our [Text Generation guides](htt
```python -from cohere import Client, ToolMessage +from cohere import Client client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) response = client.chat_stream( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + message="hello world!", ) for chunk in response: yield chunk @@ -365,28 +361,6 @@ Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments -
- - -
-
- -**raw_prompting:** `typing.Optional[bool]` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - -
-
- -
-
- -**return_prompt:** `typing.Optional[bool]` — The prompt is returned in the `prompt` response field when this is enabled. -
@@ -517,17 +491,38 @@ To learn how to use the Chat API and RAG follow our [Text Generation guides](htt
```python -from cohere import Client, ToolMessage +from cohere import Client, Tool, ToolParameterDefinitionsValue client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.chat( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + message="Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?", + tools=[ + Tool( + name="query_daily_sales_report", + description="Connects to a database to retrieve overall sales volumes and sales information for a given day.", + parameter_definitions={ + "day": ToolParameterDefinitionsValue( + description="Retrieves sales data for this day, formatted as YYYY-MM-DD.", + type="str", + required=True, + ) + }, + ), + Tool( + name="query_product_catalog", + description="Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", + parameter_definitions={ + "category": ToolParameterDefinitionsValue( + description="Retrieves product information data for all products in this category.", + type="str", + required=True, + ) + }, + ), + ], ) ``` @@ -852,28 +847,6 @@ Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments -
- - -
-
- -**raw_prompting:** `typing.Optional[bool]` - -When enabled, the user's prompt will be sent to the model without -any pre-processing. - -Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - -
-
- -
-
- -**return_prompt:** `typing.Optional[bool]` — The prompt is returned in the `prompt` response field when this is enabled. -
@@ -1013,7 +986,22 @@ client = Client( token="YOUR_TOKEN", ) response = client.generate_stream( - prompt="Please explain to me how LLMs work", + prompt="string", + model="string", + num_generations=1, + max_tokens=1, + truncate="NONE", + temperature=1.1, + seed=1, + preset="string", + end_sequences=["string"], + stop_sequences=["string"], + k=1, + p=1.1, + frequency_penalty=1.1, + presence_penalty=1.1, + return_likelihoods="GENERATION", + raw_prompting=True, ) for chunk in response: yield chunk @@ -1527,7 +1515,11 @@ client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) -client.embed() +client.embed( + texts=["hello", "goodbye"], + model="embed-english-v3.0", + input_type="classification", +) ``` @@ -1670,8 +1662,26 @@ client = Client( token="YOUR_TOKEN", ) client.rerank( - query="query", - documents=["documents"], + documents=[ + { + "text": "Carson City is the capital city of the American state of Nevada." + }, + { + "text": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + }, + { + "text": "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages." + }, + { + "text": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + }, + { + "text": "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + }, + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) ``` @@ -1794,14 +1804,56 @@ Note: [Fine-tuned models](https://docs.cohere.com/docs/classify-fine-tuning) tra
```python -from cohere import Client +from cohere import ClassifyExample, Client client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.classify( - inputs=["inputs"], + examples=[ + ClassifyExample( + text="Dermatologists don't like her!", + label="Spam", + ), + ClassifyExample( + text="'Hello, open to this?'", + label="Spam", + ), + ClassifyExample( + text="I need help please wire me $1000 right now", + label="Spam", + ), + ClassifyExample( + text="Nice to know you ;)", + label="Spam", + ), + ClassifyExample( + text="Please help me?", + label="Spam", + ), + ClassifyExample( + text="Your parcel will be delivered today", + label="Not spam", + ), + ClassifyExample( + text="Review changes to our Terms and Conditions", + label="Not spam", + ), + ClassifyExample( + text="Weekly sync notes", + label="Not spam", + ), + ClassifyExample( + text="'Re: Follow up from today's meeting'", + label="Not spam", + ), + ClassifyExample( + text="Pre-read for tomorrow", + label="Not spam", + ), + ], + inputs=["Confirm your email address", "hey i need u to send some $"], ) ``` @@ -1918,7 +1970,7 @@ client = Client( token="YOUR_TOKEN", ) client.summarize( - text="text", + text='Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name "ice cream" varies from one country to another. In some countries, such as the United States, "ice cream" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled "frozen dairy dessert" instead. In other countries, such as Italy and Argentina, one word is used fo\r all variants. Analogues made from dairy alternatives, such as goat\'s or sheep\'s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan.', ) ``` @@ -2117,8 +2169,8 @@ client = Client( token="YOUR_TOKEN", ) client.detokenize( - tokens=[1], - model="model", + tokens=[10002, 2261, 2012, 8, 2792, 43], + model="command", ) ``` @@ -2237,7 +2289,7 @@ client.check_api_key()
-Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). +Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.
@@ -2254,18 +2306,17 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
```python -from cohere import Client, ToolChatMessageV2 +from cohere import Client, UserChatMessageV2 client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) response = client.v2.chat_stream( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Hello!", ) ], ) @@ -2464,14 +2515,6 @@ Ensures that only the most likely tokens, with total probability mass of `p`, ar Defaults to `0.75`. min value of `0.01`, max value of `0.99`. -
-
- -
-
- -**return_prompt:** `typing.Optional[bool]` — Whether to return the prompt in the response. -
@@ -2545,20 +2588,53 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
```python -from cohere import Client, ToolChatMessageV2 +from cohere import Client, ToolV2, ToolV2Function, UserChatMessageV2 client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.v2.chat( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Tell me about LLMs", ) ], + tools=[ + ToolV2( + function=ToolV2Function( + name="query_daily_sales_report", + description="Connects to a database to retrieve overall sales volumes and sales information for a given day.", + parameters={ + "type": "object", + "properties": { + "day": { + "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.", + "type": "str", + } + }, + "required": ["day"], + }, + ), + ), + ToolV2( + function=ToolV2Function( + name="query_product_catalog", + description="Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.", + parameters={ + "type": "object", + "properties": { + "category": { + "description": "Retrieves product information data for all products in this category.", + "type": "str", + } + }, + "required": ["category"], + }, + ), + ), + ], ) ``` @@ -2753,14 +2829,6 @@ Ensures that only the most likely tokens, with total probability mass of `p`, ar Defaults to `0.75`. min value of `0.01`, max value of `0.99`. -
- - -
-
- -**return_prompt:** `typing.Optional[bool]` — Whether to return the prompt in the response. -
@@ -2843,8 +2911,9 @@ client = Client( token="YOUR_TOKEN", ) client.v2.embed( - model="model", - input_type="search_document", + texts=["hello", "goodbye"], + model="embed-english-v3.0", + input_type="classification", embedding_types=["float"], ) @@ -2989,9 +3058,16 @@ client = Client( token="YOUR_TOKEN", ) client.v2.rerank( - model="model", - query="query", - documents=["documents"], + documents=[ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) ``` @@ -3047,17 +3123,6 @@ For optimal performance we recommend against sending more than 1,000 documents i
-**return_documents:** `typing.Optional[bool]` - -- If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request. -- If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request. - -
-
- -
-
- **max_tokens_per_doc:** `typing.Optional[int]` — Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens.
@@ -3654,14 +3719,6 @@ core.File` — See core.File for more documentation
-**dry_run:** `typing.Optional[bool]` — flag to enable dry_run mode - -
-
- -
-
- **eval_data:** `from __future__ import annotations typing.Optional[core.File]` — See core.File for more documentation @@ -4374,7 +4431,7 @@ client.connectors.update(
-Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information. +Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information.
@@ -4645,10 +4702,7 @@ client.finetuning.list_finetuned_models()
-**page_size:** `typing.Optional[int]` - -Maximum number of results to be returned by the server. If 0, defaults to -50. +**page_size:** `typing.Optional[int]` — Maximum number of results to be returned by the server. If 0, defaults to 50.
@@ -4671,7 +4725,8 @@ sorting order is ascending. To specify descending order for a field, append " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + +- created_at (default)
@@ -5053,10 +5108,7 @@ client.finetuning.list_events(
-**page_size:** `typing.Optional[int]` - -Maximum number of results to be returned by the server. If 0, defaults to -50. +**page_size:** `typing.Optional[int]` — Maximum number of results to be returned by the server. If 0, defaults to 50.
@@ -5079,7 +5131,8 @@ sorting order is ascending. To specify descending order for a field, append " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + +- created_at (default)
@@ -5144,10 +5197,7 @@ client.finetuning.list_training_step_metrics(
-**page_size:** `typing.Optional[int]` - -Maximum number of results to be returned by the server. If 0, defaults to -50. +**page_size:** `typing.Optional[int]` — Maximum number of results to be returned by the server. If 0, defaults to 50.
diff --git a/src/cohere/__init__.py b/src/cohere/__init__.py index 220ee83af..ef371a14e 100644 --- a/src/cohere/__init__.py +++ b/src/cohere/__init__.py @@ -37,10 +37,8 @@ ChatMessageV2, ChatMessages, ChatRequestCitationQuality, - ChatRequestConnectorsSearchOptions, ChatRequestPromptTruncation, ChatRequestSafetyMode, - ChatResponse, ChatSearchQueriesGenerationEvent, ChatSearchQuery, ChatSearchResult, @@ -51,7 +49,6 @@ ChatStreamEvent, ChatStreamEventType, ChatStreamRequestCitationQuality, - ChatStreamRequestConnectorsSearchOptions, ChatStreamRequestPromptTruncation, ChatStreamRequestSafetyMode, ChatStreamStartEvent, @@ -74,14 +71,12 @@ CheckApiKeyResponse, Citation, CitationEndEvent, - CitationEndStreamedChatResponseV2, CitationGenerationStreamedChatResponse, CitationOptions, CitationOptionsMode, CitationStartEvent, CitationStartEventDelta, CitationStartEventDeltaMessage, - CitationStartStreamedChatResponseV2, ClassifyDataMetrics, ClassifyExample, ClassifyRequestTruncate, @@ -89,14 +84,12 @@ ClassifyResponseClassificationsItem, ClassifyResponseClassificationsItemClassificationType, ClassifyResponseClassificationsItemLabelsValue, + ClientClosedRequestErrorBody, CompatibleEndpoint, Connector, ConnectorAuthStatus, ConnectorOAuth, Content, - ContentDeltaStreamedChatResponseV2, - ContentEndStreamedChatResponseV2, - ContentStartStreamedChatResponseV2, CreateConnectorOAuth, CreateConnectorResponse, CreateConnectorServiceAuth, @@ -106,7 +99,6 @@ DatasetType, DatasetValidationStatus, DebugStreamedChatResponse, - DebugStreamedChatResponseV2, DeleteConnectorResponse, DetokenizeResponse, Document, @@ -127,6 +119,7 @@ EmbeddingsFloatsEmbedResponse, FinetuneDatasetMetrics, FinishReason, + GatewayTimeoutErrorBody, GenerateRequestReturnLikelihoods, GenerateRequestTruncate, GenerateStreamEnd, @@ -151,12 +144,9 @@ ListModelsResponse, LogprobItem, Message, - MessageEndStreamedChatResponseV2, - MessageStartStreamedChatResponseV2, Metrics, - MetricsEmbedData, - MetricsEmbedDataFieldsItem, NonStreamedChatResponse, + NotImplementedErrorBody, OAuthAuthorizeResponse, ParseInfo, RerankDocument, @@ -178,7 +168,6 @@ StreamErrorGenerateStreamedResponse, StreamStartStreamedChatResponse, StreamedChatResponse, - StreamedChatResponseV2, SummarizeRequestExtractiveness, SummarizeRequestFormat, SummarizeRequestLength, @@ -197,12 +186,10 @@ TextSystemMessageContentItem, TextToolContent, TokenizeResponse, + TooManyRequestsErrorBody, Tool, ToolCall, ToolCallDelta, - ToolCallDeltaStreamedChatResponseV2, - ToolCallEndStreamedChatResponseV2, - ToolCallStartStreamedChatResponseV2, ToolCallV2, ToolCallV2Function, ToolCallsChunkStreamedChatResponse, @@ -213,11 +200,11 @@ ToolMessageV2, ToolMessageV2Content, ToolParameterDefinitionsValue, - ToolPlanDeltaStreamedChatResponseV2, ToolResult, ToolSource, ToolV2, ToolV2Function, + UnprocessableEntityErrorBody, UpdateConnectorResponse, Usage, UsageBilledUnits, @@ -232,7 +219,6 @@ ForbiddenError, GatewayTimeoutError, InternalServerError, - InvalidTokenError, NotFoundError, NotImplementedError, ServiceUnavailableError, @@ -245,27 +231,34 @@ from .bedrock_client import BedrockClient, BedrockClientV2 from .client import AsyncClient, Client from .client_v2 import AsyncClientV2, ClientV2 -from .datasets import ( - DatasetsCreateResponse, - DatasetsCreateResponseDatasetPartsItem, - DatasetsGetResponse, - DatasetsGetUsageResponse, - DatasetsListResponse, -) +from .datasets import DatasetsCreateResponse, DatasetsGetResponse, DatasetsGetUsageResponse, DatasetsListResponse from .embed_jobs import CreateEmbedJobRequestTruncate from .environment import ClientEnvironment from .sagemaker_client import SagemakerClient, SagemakerClientV2 from .v2 import ( + CitationEndV2ChatStreamResponse, + CitationStartV2ChatStreamResponse, + ContentDeltaV2ChatStreamResponse, + ContentEndV2ChatStreamResponse, + ContentStartV2ChatStreamResponse, + DebugV2ChatStreamResponse, + MessageEndV2ChatStreamResponse, + MessageStartV2ChatStreamResponse, + ToolCallDeltaV2ChatStreamResponse, + ToolCallEndV2ChatStreamResponse, + ToolCallStartV2ChatStreamResponse, + ToolPlanDeltaV2ChatStreamResponse, V2ChatRequestDocumentsItem, V2ChatRequestSafetyMode, V2ChatRequestToolChoice, + V2ChatResponse, V2ChatStreamRequestDocumentsItem, V2ChatStreamRequestSafetyMode, V2ChatStreamRequestToolChoice, + V2ChatStreamResponse, V2EmbedRequestTruncate, V2RerankResponse, V2RerankResponseResultsItem, - V2RerankResponseResultsItemDocument, ) from .version import __version__ @@ -312,10 +305,8 @@ "ChatMessageV2", "ChatMessages", "ChatRequestCitationQuality", - "ChatRequestConnectorsSearchOptions", "ChatRequestPromptTruncation", "ChatRequestSafetyMode", - "ChatResponse", "ChatSearchQueriesGenerationEvent", "ChatSearchQuery", "ChatSearchResult", @@ -326,7 +317,6 @@ "ChatStreamEvent", "ChatStreamEventType", "ChatStreamRequestCitationQuality", - "ChatStreamRequestConnectorsSearchOptions", "ChatStreamRequestPromptTruncation", "ChatStreamRequestSafetyMode", "ChatStreamStartEvent", @@ -349,14 +339,14 @@ "CheckApiKeyResponse", "Citation", "CitationEndEvent", - "CitationEndStreamedChatResponseV2", + "CitationEndV2ChatStreamResponse", "CitationGenerationStreamedChatResponse", "CitationOptions", "CitationOptionsMode", "CitationStartEvent", "CitationStartEventDelta", "CitationStartEventDeltaMessage", - "CitationStartStreamedChatResponseV2", + "CitationStartV2ChatStreamResponse", "ClassifyDataMetrics", "ClassifyExample", "ClassifyRequestTruncate", @@ -366,6 +356,7 @@ "ClassifyResponseClassificationsItemLabelsValue", "Client", "ClientClosedRequestError", + "ClientClosedRequestErrorBody", "ClientEnvironment", "ClientV2", "CompatibleEndpoint", @@ -373,9 +364,9 @@ "ConnectorAuthStatus", "ConnectorOAuth", "Content", - "ContentDeltaStreamedChatResponseV2", - "ContentEndStreamedChatResponseV2", - "ContentStartStreamedChatResponseV2", + "ContentDeltaV2ChatStreamResponse", + "ContentEndV2ChatStreamResponse", + "ContentStartV2ChatStreamResponse", "CreateConnectorOAuth", "CreateConnectorResponse", "CreateConnectorServiceAuth", @@ -386,12 +377,11 @@ "DatasetType", "DatasetValidationStatus", "DatasetsCreateResponse", - "DatasetsCreateResponseDatasetPartsItem", "DatasetsGetResponse", "DatasetsGetUsageResponse", "DatasetsListResponse", "DebugStreamedChatResponse", - "DebugStreamedChatResponseV2", + "DebugV2ChatStreamResponse", "DeleteConnectorResponse", "DetokenizeResponse", "Document", @@ -414,6 +404,7 @@ "FinishReason", "ForbiddenError", "GatewayTimeoutError", + "GatewayTimeoutErrorBody", "GenerateRequestReturnLikelihoods", "GenerateRequestTruncate", "GenerateStreamEnd", @@ -429,7 +420,6 @@ "GetModelResponse", "Image", "InternalServerError", - "InvalidTokenError", "JsonObjectResponseFormat", "JsonObjectResponseFormatV2", "JsonResponseFormat", @@ -440,14 +430,13 @@ "ListModelsResponse", "LogprobItem", "Message", - "MessageEndStreamedChatResponseV2", - "MessageStartStreamedChatResponseV2", + "MessageEndV2ChatStreamResponse", + "MessageStartV2ChatStreamResponse", "Metrics", - "MetricsEmbedData", - "MetricsEmbedDataFieldsItem", "NonStreamedChatResponse", "NotFoundError", "NotImplementedError", + "NotImplementedErrorBody", "OAuthAuthorizeResponse", "ParseInfo", "RerankDocument", @@ -472,7 +461,6 @@ "StreamErrorGenerateStreamedResponse", "StreamStartStreamedChatResponse", "StreamedChatResponse", - "StreamedChatResponseV2", "SummarizeRequestExtractiveness", "SummarizeRequestFormat", "SummarizeRequestLength", @@ -492,12 +480,13 @@ "TextToolContent", "TokenizeResponse", "TooManyRequestsError", + "TooManyRequestsErrorBody", "Tool", "ToolCall", "ToolCallDelta", - "ToolCallDeltaStreamedChatResponseV2", - "ToolCallEndStreamedChatResponseV2", - "ToolCallStartStreamedChatResponseV2", + "ToolCallDeltaV2ChatStreamResponse", + "ToolCallEndV2ChatStreamResponse", + "ToolCallStartV2ChatStreamResponse", "ToolCallV2", "ToolCallV2Function", "ToolCallsChunkStreamedChatResponse", @@ -508,13 +497,14 @@ "ToolMessageV2", "ToolMessageV2Content", "ToolParameterDefinitionsValue", - "ToolPlanDeltaStreamedChatResponseV2", + "ToolPlanDeltaV2ChatStreamResponse", "ToolResult", "ToolSource", "ToolV2", "ToolV2Function", "UnauthorizedError", "UnprocessableEntityError", + "UnprocessableEntityErrorBody", "UpdateConnectorResponse", "Usage", "UsageBilledUnits", @@ -525,13 +515,14 @@ "V2ChatRequestDocumentsItem", "V2ChatRequestSafetyMode", "V2ChatRequestToolChoice", + "V2ChatResponse", "V2ChatStreamRequestDocumentsItem", "V2ChatStreamRequestSafetyMode", "V2ChatStreamRequestToolChoice", + "V2ChatStreamResponse", "V2EmbedRequestTruncate", "V2RerankResponse", "V2RerankResponseResultsItem", - "V2RerankResponseResultsItemDocument", "__version__", "connectors", "datasets", diff --git a/src/cohere/base_client.py b/src/cohere/base_client.py index 278de29f4..90c13c45d 100644 --- a/src/cohere/base_client.py +++ b/src/cohere/base_client.py @@ -31,13 +31,17 @@ from .errors.forbidden_error import ForbiddenError from .errors.not_found_error import NotFoundError from .errors.unprocessable_entity_error import UnprocessableEntityError +from .types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from .errors.too_many_requests_error import TooManyRequestsError -from .errors.invalid_token_error import InvalidTokenError +from .types.too_many_requests_error_body import TooManyRequestsErrorBody from .errors.client_closed_request_error import ClientClosedRequestError +from .types.client_closed_request_error_body import ClientClosedRequestErrorBody from .errors.internal_server_error import InternalServerError from .errors.not_implemented_error import NotImplementedError +from .types.not_implemented_error_body import NotImplementedErrorBody from .errors.service_unavailable_error import ServiceUnavailableError from .errors.gateway_timeout_error import GatewayTimeoutError +from .types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from .types.chat_request_prompt_truncation import ChatRequestPromptTruncation from .types.chat_request_citation_quality import ChatRequestCitationQuality @@ -171,8 +175,6 @@ def chat_stream( stop_sequences: typing.Optional[typing.Sequence[str]] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, - raw_prompting: typing.Optional[bool] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, tools: typing.Optional[typing.Sequence[Tool]] = OMIT, tool_results: typing.Optional[typing.Sequence[ToolResult]] = OMIT, force_single_step: typing.Optional[bool] = OMIT, @@ -181,8 +183,7 @@ def chat_stream( request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[StreamedChatResponse]: """ - Generates a streamed text response to a user message. - + Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api). Parameters @@ -363,16 +364,6 @@ def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - raw_prompting : typing.Optional[bool] - When enabled, the user's prompt will be sent to the model without - any pre-processing. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - - return_prompt : typing.Optional[bool] - The prompt is returned in the `prompt` response field when this is enabled. - tools : typing.Optional[typing.Sequence[Tool]] A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -435,17 +426,14 @@ def chat_stream( Examples -------- - from cohere import Client, ToolMessage + from cohere import Client client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) response = client.chat_stream( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + message="hello world!", ) for chunk in response: yield chunk @@ -477,8 +465,6 @@ def chat_stream( "stop_sequences": stop_sequences, "frequency_penalty": frequency_penalty, "presence_penalty": presence_penalty, - "raw_prompting": raw_prompting, - "return_prompt": return_prompt, "tools": convert_and_respect_annotation_metadata( object_=tools, annotation=typing.Sequence[Tool], direction="write" ), @@ -493,7 +479,6 @@ def chat_stream( "stream": True, }, headers={ - "content-type": "application/json", "Accepts": str(accepts) if accepts is not None else None, }, request_options=request_options, @@ -559,9 +544,9 @@ def chat_stream( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -569,19 +554,9 @@ def chat_stream( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -589,9 +564,9 @@ def chat_stream( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -609,9 +584,9 @@ def chat_stream( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -629,9 +604,9 @@ def chat_stream( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -664,8 +639,6 @@ def chat( stop_sequences: typing.Optional[typing.Sequence[str]] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, - raw_prompting: typing.Optional[bool] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, tools: typing.Optional[typing.Sequence[Tool]] = OMIT, tool_results: typing.Optional[typing.Sequence[ToolResult]] = OMIT, force_single_step: typing.Optional[bool] = OMIT, @@ -855,16 +828,6 @@ def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - raw_prompting : typing.Optional[bool] - When enabled, the user's prompt will be sent to the model without - any pre-processing. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - - return_prompt : typing.Optional[bool] - The prompt is returned in the `prompt` response field when this is enabled. - tools : typing.Optional[typing.Sequence[Tool]] A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -927,17 +890,27 @@ def chat( Examples -------- - from cohere import Client, ToolMessage + from cohere import ChatbotMessage, ChatConnector, Client, UserMessage client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.chat( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + chat_history=[ + UserMessage( + message="Who discovered gravity?", + ), + ChatbotMessage( + message="The man who is widely credited with discovering gravity is Sir Isaac Newton", + ), + ], + message="What year was he born?", + connectors=[ + ChatConnector( + id="web-search", + ) + ], ) """ _response = self._client_wrapper.httpx_client.request( @@ -967,8 +940,6 @@ def chat( "stop_sequences": stop_sequences, "frequency_penalty": frequency_penalty, "presence_penalty": presence_penalty, - "raw_prompting": raw_prompting, - "return_prompt": return_prompt, "tools": convert_and_respect_annotation_metadata( object_=tools, annotation=typing.Sequence[Tool], direction="write" ), @@ -983,7 +954,6 @@ def chat( "stream": False, }, headers={ - "content-type": "application/json", "Accepts": str(accepts) if accepts is not None else None, }, request_options=request_options, @@ -1041,9 +1011,9 @@ def chat( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1051,19 +1021,9 @@ def chat( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1071,9 +1031,9 @@ def chat( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1091,9 +1051,9 @@ def chat( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1111,9 +1071,9 @@ def chat( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1255,7 +1215,22 @@ def generate_stream( token="YOUR_TOKEN", ) response = client.generate_stream( - prompt="Please explain to me how LLMs work", + prompt="string", + model="string", + num_generations=1, + max_tokens=1, + truncate="NONE", + temperature=1.1, + seed=1, + preset="string", + end_sequences=["string"], + stop_sequences=["string"], + k=1, + p=1.1, + frequency_penalty=1.1, + presence_penalty=1.1, + return_likelihoods="GENERATION", + raw_prompting=True, ) for chunk in response: yield chunk @@ -1282,9 +1257,6 @@ def generate_stream( "raw_prompting": raw_prompting, "stream": True, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) as _response: @@ -1348,9 +1320,9 @@ def generate_stream( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1358,19 +1330,9 @@ def generate_stream( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1378,9 +1340,9 @@ def generate_stream( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1398,9 +1360,9 @@ def generate_stream( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1418,9 +1380,9 @@ def generate_stream( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1587,9 +1549,6 @@ def generate( "raw_prompting": raw_prompting, "stream": False, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1645,9 +1604,9 @@ def generate( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1655,19 +1614,9 @@ def generate( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1675,9 +1624,9 @@ def generate( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1695,9 +1644,9 @@ def generate( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1715,9 +1664,9 @@ def generate( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1805,7 +1754,14 @@ def embed( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) - client.embed() + client.embed( + model="embed-english-v3.0", + input_type="image", + embedding_types=["float"], + images=[ + "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gAfQ29tcHJlc3NlZCBieSBqcGVnLXJlY29tcHJlc3P/2wCEAAQEBAQEBAQEBAQGBgUGBggHBwcHCAwJCQkJCQwTDA4MDA4MExEUEA8QFBEeFxUVFx4iHRsdIiolJSo0MjRERFwBBAQEBAQEBAQEBAYGBQYGCAcHBwcIDAkJCQkJDBMMDgwMDgwTERQQDxAUER4XFRUXHiIdGx0iKiUlKjQyNEREXP/CABEIAZABkAMBIgACEQEDEQH/xAAdAAEAAQQDAQAAAAAAAAAAAAAABwEFBggCAwQJ/9oACAEBAAAAAN/gAAAAAAAAAAAAAAAAAAAAAAAAAAHTg9j6agAAp23/ADjsAAAPFrlAUYeagAAArdZ12uzcAAKax6jWUAAAAO/bna+oAC1a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A6y9GVw/mAdjohEEwK2I4u0jH/Lb6exgXljL2tEwP9pq0GdzF69bfHO4fyAGx0ScPgVpl9JkB/yO309cG6w9O0ROeZq3bQnib/UOsJyBJqV9ZI7952Ogl8DDdYezfEra1B5HcdvpTfC+xicoc44QIl/t4/z7LaUTRK3bwPr1d9PoJqlPxN/A2cOvpsNvIbyA/Eh3jvHaDWHYjbYnapdWzgg/qHap7js9JseTDLZreBwbuVSAB9AP1GiSSSeJ9ltcGB8/pPEUjq6hlOYPU3FykC97dgp3aRi7HMnaw3FbzCptdaSZeJDvVh5isO6aYdcqq3gNvJ25705ikxXDJAGS/gI/5FqfHMIt10pb+H0DBjyGdYr03XRaLCojnw1sg/6FTTSzyPNNIXkc5szHMnYhuJIDmh3doPCo7+F9z5oaE0R4SrzrWR/cXnWsj+4vOtZH9xeYrWx/cXmKe6gTjID6b6lxAnMQrl5mmYsSzEkn92//2Q==" + ], + ) """ _response = self._client_wrapper.httpx_client.request( "v1/embed", @@ -1818,9 +1774,6 @@ def embed( "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1876,9 +1829,9 @@ def embed( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1886,19 +1839,9 @@ def embed( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1906,9 +1849,9 @@ def embed( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1926,9 +1869,9 @@ def embed( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1946,9 +1889,9 @@ def embed( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2019,8 +1962,26 @@ def rerank( token="YOUR_TOKEN", ) client.rerank( - query="query", - documents=["documents"], + documents=[ + { + "text": "Carson City is the capital city of the American state of Nevada." + }, + { + "text": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + }, + { + "text": "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages." + }, + { + "text": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + }, + { + "text": "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + }, + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) """ _response = self._client_wrapper.httpx_client.request( @@ -2037,9 +1998,6 @@ def rerank( "return_documents": return_documents, "max_chunks_per_doc": max_chunks_per_doc, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2095,9 +2053,9 @@ def rerank( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2105,19 +2063,9 @@ def rerank( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2125,9 +2073,9 @@ def rerank( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2145,9 +2093,9 @@ def rerank( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2165,9 +2113,9 @@ def rerank( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2223,14 +2171,56 @@ def classify( Examples -------- - from cohere import Client + from cohere import ClassifyExample, Client client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.classify( - inputs=["inputs"], + examples=[ + ClassifyExample( + text="Dermatologists don't like her!", + label="Spam", + ), + ClassifyExample( + text="'Hello, open to this?'", + label="Spam", + ), + ClassifyExample( + text="I need help please wire me $1000 right now", + label="Spam", + ), + ClassifyExample( + text="Nice to know you ;)", + label="Spam", + ), + ClassifyExample( + text="Please help me?", + label="Spam", + ), + ClassifyExample( + text="Your parcel will be delivered today", + label="Not spam", + ), + ClassifyExample( + text="Review changes to our Terms and Conditions", + label="Not spam", + ), + ClassifyExample( + text="Weekly sync notes", + label="Not spam", + ), + ClassifyExample( + text="'Re: Follow up from today's meeting'", + label="Not spam", + ), + ClassifyExample( + text="Pre-read for tomorrow", + label="Not spam", + ), + ], + inputs=["Confirm your email address", "hey i need u to send some $"], ) """ _response = self._client_wrapper.httpx_client.request( @@ -2245,9 +2235,6 @@ def classify( "preset": preset, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2303,9 +2290,9 @@ def classify( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2313,19 +2300,9 @@ def classify( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2333,9 +2310,9 @@ def classify( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2353,9 +2330,9 @@ def classify( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2373,9 +2350,9 @@ def classify( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2443,7 +2420,7 @@ def summarize( token="YOUR_TOKEN", ) client.summarize( - text="text", + text='Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name "ice cream" varies from one country to another. In some countries, such as the United States, "ice cream" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled "frozen dairy dessert" instead. In other countries, such as Italy and Argentina, one word is used fo\r all variants. Analogues made from dairy alternatives, such as goat\'s or sheep\'s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan.', ) """ _response = self._client_wrapper.httpx_client.request( @@ -2458,9 +2435,6 @@ def summarize( "temperature": temperature, "additional_command": additional_command, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2516,9 +2490,9 @@ def summarize( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2526,19 +2500,9 @@ def summarize( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2546,9 +2510,9 @@ def summarize( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2566,9 +2530,9 @@ def summarize( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2586,9 +2550,9 @@ def summarize( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2640,9 +2604,6 @@ def tokenize( "text": text, "model": model, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2698,9 +2659,9 @@ def tokenize( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2708,19 +2669,9 @@ def tokenize( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2728,9 +2679,9 @@ def tokenize( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2748,9 +2699,9 @@ def tokenize( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2768,9 +2719,9 @@ def tokenize( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2811,8 +2762,8 @@ def detokenize( token="YOUR_TOKEN", ) client.detokenize( - tokens=[1], - model="model", + tokens=[10002, 2261, 2012, 8, 2792, 43], + model="command", ) """ _response = self._client_wrapper.httpx_client.request( @@ -2822,9 +2773,6 @@ def detokenize( "tokens": tokens, "model": model, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2880,9 +2828,9 @@ def detokenize( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2890,19 +2838,9 @@ def detokenize( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2910,9 +2848,9 @@ def detokenize( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2930,9 +2868,9 @@ def detokenize( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2950,9 +2888,9 @@ def detokenize( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3043,9 +2981,9 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3053,19 +2991,9 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3073,9 +3001,9 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3093,9 +3021,9 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3113,9 +3041,9 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3220,8 +3148,6 @@ async def chat_stream( stop_sequences: typing.Optional[typing.Sequence[str]] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, - raw_prompting: typing.Optional[bool] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, tools: typing.Optional[typing.Sequence[Tool]] = OMIT, tool_results: typing.Optional[typing.Sequence[ToolResult]] = OMIT, force_single_step: typing.Optional[bool] = OMIT, @@ -3230,8 +3156,7 @@ async def chat_stream( request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[StreamedChatResponse]: """ - Generates a streamed text response to a user message. - + Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api). Parameters @@ -3412,16 +3337,6 @@ async def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - raw_prompting : typing.Optional[bool] - When enabled, the user's prompt will be sent to the model without - any pre-processing. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - - return_prompt : typing.Optional[bool] - The prompt is returned in the `prompt` response field when this is enabled. - tools : typing.Optional[typing.Sequence[Tool]] A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -3486,7 +3401,7 @@ async def chat_stream( -------- import asyncio - from cohere import AsyncClient, ToolMessage + from cohere import AsyncClient client = AsyncClient( client_name="YOUR_CLIENT_NAME", @@ -3496,10 +3411,7 @@ async def chat_stream( async def main() -> None: response = await client.chat_stream( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + message="hello world!", ) async for chunk in response: yield chunk @@ -3534,8 +3446,6 @@ async def main() -> None: "stop_sequences": stop_sequences, "frequency_penalty": frequency_penalty, "presence_penalty": presence_penalty, - "raw_prompting": raw_prompting, - "return_prompt": return_prompt, "tools": convert_and_respect_annotation_metadata( object_=tools, annotation=typing.Sequence[Tool], direction="write" ), @@ -3550,7 +3460,6 @@ async def main() -> None: "stream": True, }, headers={ - "content-type": "application/json", "Accepts": str(accepts) if accepts is not None else None, }, request_options=request_options, @@ -3616,9 +3525,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3626,19 +3535,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3646,9 +3545,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3666,9 +3565,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3686,9 +3585,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -3721,8 +3620,6 @@ async def chat( stop_sequences: typing.Optional[typing.Sequence[str]] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, - raw_prompting: typing.Optional[bool] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, tools: typing.Optional[typing.Sequence[Tool]] = OMIT, tool_results: typing.Optional[typing.Sequence[ToolResult]] = OMIT, force_single_step: typing.Optional[bool] = OMIT, @@ -3912,16 +3809,6 @@ async def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - raw_prompting : typing.Optional[bool] - When enabled, the user's prompt will be sent to the model without - any pre-processing. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - - - return_prompt : typing.Optional[bool] - The prompt is returned in the `prompt` response field when this is enabled. - tools : typing.Optional[typing.Sequence[Tool]] A list of available tools (functions) that the model may suggest invoking before producing a text response. @@ -3986,7 +3873,7 @@ async def chat( -------- import asyncio - from cohere import AsyncClient, ToolMessage + from cohere import AsyncClient, ChatbotMessage, ChatConnector, UserMessage client = AsyncClient( client_name="YOUR_CLIENT_NAME", @@ -3996,10 +3883,20 @@ async def chat( async def main() -> None: await client.chat( - message="Can you give me a global market overview of solar panels?", - chat_history=[ToolMessage(), ToolMessage()], - prompt_truncation="OFF", - temperature=0.3, + chat_history=[ + UserMessage( + message="Who discovered gravity?", + ), + ChatbotMessage( + message="The man who is widely credited with discovering gravity is Sir Isaac Newton", + ), + ], + message="What year was he born?", + connectors=[ + ChatConnector( + id="web-search", + ) + ], ) @@ -4032,8 +3929,6 @@ async def main() -> None: "stop_sequences": stop_sequences, "frequency_penalty": frequency_penalty, "presence_penalty": presence_penalty, - "raw_prompting": raw_prompting, - "return_prompt": return_prompt, "tools": convert_and_respect_annotation_metadata( object_=tools, annotation=typing.Sequence[Tool], direction="write" ), @@ -4048,7 +3943,6 @@ async def main() -> None: "stream": False, }, headers={ - "content-type": "application/json", "Accepts": str(accepts) if accepts is not None else None, }, request_options=request_options, @@ -4106,9 +4000,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4116,19 +4010,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4136,9 +4020,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4156,9 +4040,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4176,9 +4060,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4325,7 +4209,22 @@ async def generate_stream( async def main() -> None: response = await client.generate_stream( - prompt="Please explain to me how LLMs work", + prompt="string", + model="string", + num_generations=1, + max_tokens=1, + truncate="NONE", + temperature=1.1, + seed=1, + preset="string", + end_sequences=["string"], + stop_sequences=["string"], + k=1, + p=1.1, + frequency_penalty=1.1, + presence_penalty=1.1, + return_likelihoods="GENERATION", + raw_prompting=True, ) async for chunk in response: yield chunk @@ -4355,9 +4254,6 @@ async def main() -> None: "raw_prompting": raw_prompting, "stream": True, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) as _response: @@ -4421,9 +4317,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4431,19 +4327,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4451,9 +4337,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4471,9 +4357,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4491,9 +4377,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4668,9 +4554,6 @@ async def main() -> None: "raw_prompting": raw_prompting, "stream": False, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -4726,9 +4609,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4736,19 +4619,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4756,9 +4629,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4776,9 +4649,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4796,9 +4669,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4891,7 +4764,14 @@ async def embed( async def main() -> None: - await client.embed() + await client.embed( + model="embed-english-v3.0", + input_type="image", + embedding_types=["float"], + images=[ + "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gAfQ29tcHJlc3NlZCBieSBqcGVnLXJlY29tcHJlc3P/2wCEAAQEBAQEBAQEBAQGBgUGBggHBwcHCAwJCQkJCQwTDA4MDA4MExEUEA8QFBEeFxUVFx4iHRsdIiolJSo0MjRERFwBBAQEBAQEBAQEBAYGBQYGCAcHBwcIDAkJCQkJDBMMDgwMDgwTERQQDxAUER4XFRUXHiIdGx0iKiUlKjQyNEREXP/CABEIAZABkAMBIgACEQEDEQH/xAAdAAEAAQQDAQAAAAAAAAAAAAAABwEFBggCAwQJ/9oACAEBAAAAAN/gAAAAAAAAAAAAAAAAAAAAAAAAAAHTg9j6agAAp23/ADjsAAAPFrlAUYeagAAArdZ12uzcAAKax6jWUAAAAO/bna+oAC1aBxAAAAAAbM7rVABYvnRgYAAAAAbwbIABw+cMYAAAAAAvH1CuwA091RAAAAAAbpbPAGJfMXzAAAAAAJk+hdQGlmsQAAAAABk31JqBx+V1iAAAAAALp9W6gRp826AAAAAAGS/UqoGuGjwAAAAAAl76I1A1K1EAAAAAAG5G1ADUHU0AAAAAAu/1Cu4DVbTgAAAAAA3n2JAIG0IAAAAAArt3toAMV+XfEAAAAAL1uzPlQBT5qR2AAAAAenZDbm/AAa06SgAAAAerYra/LQADp+YmIAAAAC77J7Q5KAACIPnjwAAAAzbZzY24gAAGq+m4AAA7Zo2cmaoAAANWdOOAAAMl2N2TysAAAApEOj2HgAOyYtl5w5jw4zZPJyuGQ5H2AAAdes+suDUAVyfYbZTLajG8HxjgD153n3IAABH8QxxiVo4XPKpGlyTKjowvCbUAF4mD3AAACgqCzYPiPQAA900XAACmN4favRk+a9wB0xdiNAAAvU1cgAxe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==" + ], + ) asyncio.run(main()) @@ -4907,9 +4787,6 @@ async def main() -> None: "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -4965,9 +4842,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4975,19 +4852,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -4995,9 +4862,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5015,9 +4882,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5035,9 +4902,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5113,8 +4980,26 @@ async def rerank( async def main() -> None: await client.rerank( - query="query", - documents=["documents"], + documents=[ + { + "text": "Carson City is the capital city of the American state of Nevada." + }, + { + "text": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + }, + { + "text": "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages." + }, + { + "text": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + }, + { + "text": "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + }, + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) @@ -5134,9 +5019,6 @@ async def main() -> None: "return_documents": return_documents, "max_chunks_per_doc": max_chunks_per_doc, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -5192,9 +5074,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5202,19 +5084,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5222,9 +5094,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5242,9 +5114,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5262,9 +5134,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5322,7 +5194,7 @@ async def classify( -------- import asyncio - from cohere import AsyncClient + from cohere import AsyncClient, ClassifyExample client = AsyncClient( client_name="YOUR_CLIENT_NAME", @@ -5332,7 +5204,49 @@ async def classify( async def main() -> None: await client.classify( - inputs=["inputs"], + examples=[ + ClassifyExample( + text="Dermatologists don't like her!", + label="Spam", + ), + ClassifyExample( + text="'Hello, open to this?'", + label="Spam", + ), + ClassifyExample( + text="I need help please wire me $1000 right now", + label="Spam", + ), + ClassifyExample( + text="Nice to know you ;)", + label="Spam", + ), + ClassifyExample( + text="Please help me?", + label="Spam", + ), + ClassifyExample( + text="Your parcel will be delivered today", + label="Not spam", + ), + ClassifyExample( + text="Review changes to our Terms and Conditions", + label="Not spam", + ), + ClassifyExample( + text="Weekly sync notes", + label="Not spam", + ), + ClassifyExample( + text="'Re: Follow up from today's meeting'", + label="Not spam", + ), + ClassifyExample( + text="Pre-read for tomorrow", + label="Not spam", + ), + ], + inputs=["Confirm your email address", "hey i need u to send some $"], ) @@ -5350,9 +5264,6 @@ async def main() -> None: "preset": preset, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -5408,9 +5319,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5418,19 +5329,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5438,9 +5339,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5458,9 +5359,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5478,9 +5379,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5553,7 +5454,7 @@ async def summarize( async def main() -> None: await client.summarize( - text="text", + text='Ice cream is a sweetened frozen food typically eaten as a snack or dessert. It may be made from milk or cream and is flavoured with a sweetener, either sugar or an alternative, and a spice, such as cocoa or vanilla, or with fruit such as strawberries or peaches. It can also be made by whisking a flavored cream base and liquid nitrogen together. Food coloring is sometimes added, in addition to stabilizers. The mixture is cooled below the freezing point of water and stirred to incorporate air spaces and to prevent detectable ice crystals from forming. The result is a smooth, semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). It becomes more malleable as its temperature increases.\n\nThe meaning of the name "ice cream" varies from one country to another. In some countries, such as the United States, "ice cream" applies only to a specific variety, and most governments regulate the commercial use of the various terms according to the relative quantities of the main ingredients, notably the amount of cream. Products that do not meet the criteria to be called ice cream are sometimes labelled "frozen dairy dessert" instead. In other countries, such as Italy and Argentina, one word is used fo\r all variants. Analogues made from dairy alternatives, such as goat\'s or sheep\'s milk, or milk substitutes (e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are lactose intolerant, allergic to dairy protein or vegan.', ) @@ -5571,9 +5472,6 @@ async def main() -> None: "temperature": temperature, "additional_command": additional_command, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -5629,9 +5527,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5639,19 +5537,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5659,9 +5547,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5679,9 +5567,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5699,9 +5587,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5761,9 +5649,6 @@ async def main() -> None: "text": text, "model": model, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -5819,9 +5704,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5829,19 +5714,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5849,9 +5724,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5869,9 +5744,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5889,9 +5764,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -5937,8 +5812,8 @@ async def detokenize( async def main() -> None: await client.detokenize( - tokens=[1], - model="model", + tokens=[10002, 2261, 2012, 8, 2792, 43], + model="command", ) @@ -5951,9 +5826,6 @@ async def main() -> None: "tokens": tokens, "model": model, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -6009,9 +5881,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6019,19 +5891,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6039,9 +5901,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6059,9 +5921,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6079,9 +5941,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6180,9 +6042,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6190,19 +6052,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6210,9 +6062,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6230,9 +6082,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -6250,9 +6102,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/connectors/client.py b/src/cohere/connectors/client.py index 149800110..f829aefb5 100644 --- a/src/cohere/connectors/client.py +++ b/src/cohere/connectors/client.py @@ -10,13 +10,17 @@ from ..errors.forbidden_error import ForbiddenError from ..errors.not_found_error import NotFoundError from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..errors.too_many_requests_error import TooManyRequestsError -from ..errors.invalid_token_error import InvalidTokenError +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody from ..errors.client_closed_request_error import ClientClosedRequestError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..errors.internal_server_error import InternalServerError from ..errors.not_implemented_error import NotImplementedError +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..types.create_connector_o_auth import CreateConnectorOAuth @@ -135,9 +139,9 @@ def list( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -145,19 +149,9 @@ def list( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -165,9 +159,9 @@ def list( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -185,9 +179,9 @@ def list( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -205,9 +199,9 @@ def list( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -297,9 +291,6 @@ def create( object_=service_auth, annotation=CreateConnectorServiceAuth, direction="write" ), }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -355,9 +346,9 @@ def create( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -365,19 +356,9 @@ def create( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -385,9 +366,9 @@ def create( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -405,9 +386,9 @@ def create( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -425,9 +406,9 @@ def create( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -523,9 +504,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -533,19 +514,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -553,9 +524,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -573,9 +544,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -593,9 +564,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -691,9 +662,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -701,19 +672,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -721,9 +682,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -741,9 +702,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -761,9 +722,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -849,9 +810,6 @@ def update( object_=service_auth, annotation=CreateConnectorServiceAuth, direction="write" ), }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -907,9 +865,9 @@ def update( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -917,19 +875,9 @@ def update( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -937,9 +885,9 @@ def update( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -957,9 +905,9 @@ def update( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -977,9 +925,9 @@ def update( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -997,7 +945,7 @@ def o_auth_authorize( request_options: typing.Optional[RequestOptions] = None, ) -> OAuthAuthorizeResponse: """ - Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information. + Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information. Parameters ---------- @@ -1087,9 +1035,9 @@ def o_auth_authorize( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1097,19 +1045,9 @@ def o_auth_authorize( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1117,9 +1055,9 @@ def o_auth_authorize( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1137,9 +1075,9 @@ def o_auth_authorize( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1157,9 +1095,9 @@ def o_auth_authorize( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1279,9 +1217,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1289,19 +1227,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1309,9 +1237,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1329,9 +1257,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1349,9 +1277,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1449,9 +1377,6 @@ async def main() -> None: object_=service_auth, annotation=CreateConnectorServiceAuth, direction="write" ), }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1507,9 +1432,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1517,19 +1442,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1537,9 +1452,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1557,9 +1472,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1577,9 +1492,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1683,9 +1598,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1693,19 +1608,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1713,9 +1618,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1733,9 +1638,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1753,9 +1658,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1861,9 +1766,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1871,19 +1776,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1891,9 +1786,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1911,9 +1806,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1931,9 +1826,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2027,9 +1922,6 @@ async def main() -> None: object_=service_auth, annotation=CreateConnectorServiceAuth, direction="write" ), }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2085,9 +1977,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2095,19 +1987,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2115,9 +1997,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2135,9 +2017,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2155,9 +2037,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2175,7 +2057,7 @@ async def o_auth_authorize( request_options: typing.Optional[RequestOptions] = None, ) -> OAuthAuthorizeResponse: """ - Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information. + Authorize the connector with the given ID for the connector oauth app. See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information. Parameters ---------- @@ -2273,9 +2155,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2283,19 +2165,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2303,9 +2175,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2323,9 +2195,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2343,9 +2215,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/core/client_wrapper.py b/src/cohere/core/client_wrapper.py index 22e02d077..5b8e3984f 100644 --- a/src/cohere/core/client_wrapper.py +++ b/src/cohere/core/client_wrapper.py @@ -24,7 +24,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "cohere", - "X-Fern-SDK-Version": "5.13.8", + "X-Fern-SDK-Version": "6.0.0", } if self._client_name is not None: headers["X-Client-Name"] = self._client_name diff --git a/src/cohere/datasets/__init__.py b/src/cohere/datasets/__init__.py index 3778ddcf3..dd39ad419 100644 --- a/src/cohere/datasets/__init__.py +++ b/src/cohere/datasets/__init__.py @@ -1,17 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ( - DatasetsCreateResponse, - DatasetsCreateResponseDatasetPartsItem, - DatasetsGetResponse, - DatasetsGetUsageResponse, - DatasetsListResponse, -) +from .types import DatasetsCreateResponse, DatasetsGetResponse, DatasetsGetUsageResponse, DatasetsListResponse -__all__ = [ - "DatasetsCreateResponse", - "DatasetsCreateResponseDatasetPartsItem", - "DatasetsGetResponse", - "DatasetsGetUsageResponse", - "DatasetsListResponse", -] +__all__ = ["DatasetsCreateResponse", "DatasetsGetResponse", "DatasetsGetUsageResponse", "DatasetsListResponse"] diff --git a/src/cohere/datasets/client.py b/src/cohere/datasets/client.py index a3178a109..57023e5a2 100644 --- a/src/cohere/datasets/client.py +++ b/src/cohere/datasets/client.py @@ -13,13 +13,17 @@ from ..errors.forbidden_error import ForbiddenError from ..errors.not_found_error import NotFoundError from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..errors.too_many_requests_error import TooManyRequestsError -from ..errors.invalid_token_error import InvalidTokenError +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody from ..errors.client_closed_request_error import ClientClosedRequestError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..errors.internal_server_error import InternalServerError from ..errors.not_implemented_error import NotImplementedError +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..types.dataset_type import DatasetType @@ -155,9 +159,9 @@ def list( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -165,19 +169,9 @@ def list( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -185,9 +179,9 @@ def list( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -205,9 +199,9 @@ def list( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -225,9 +219,9 @@ def list( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -249,7 +243,6 @@ def create( optional_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, text_separator: typing.Optional[str] = None, csv_delimiter: typing.Optional[str] = None, - dry_run: typing.Optional[bool] = None, eval_data: typing.Optional[core.File] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> DatasetsCreateResponse: @@ -285,9 +278,6 @@ def create( csv_delimiter : typing.Optional[str] The delimiter used for .csv uploads. - dry_run : typing.Optional[bool] - flag to enable dry_run mode - eval_data : typing.Optional[core.File] See core.File for more documentation @@ -324,7 +314,6 @@ def create( "optional_fields": optional_fields, "text_separator": text_separator, "csv_delimiter": csv_delimiter, - "dry_run": dry_run, }, data={}, files={ @@ -386,9 +375,9 @@ def create( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -396,19 +385,9 @@ def create( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -416,9 +395,9 @@ def create( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -436,9 +415,9 @@ def create( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -456,9 +435,9 @@ def create( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -549,9 +528,9 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -559,19 +538,9 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -579,9 +548,9 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -599,9 +568,9 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -619,9 +588,9 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -716,9 +685,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -726,19 +695,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -746,9 +705,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -766,9 +725,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -786,9 +745,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -885,9 +844,9 @@ def delete( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -895,19 +854,9 @@ def delete( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -915,9 +864,9 @@ def delete( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -935,9 +884,9 @@ def delete( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -955,9 +904,9 @@ def delete( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1097,9 +1046,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1107,19 +1056,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1127,9 +1066,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1147,9 +1086,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1167,9 +1106,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1191,7 +1130,6 @@ async def create( optional_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, text_separator: typing.Optional[str] = None, csv_delimiter: typing.Optional[str] = None, - dry_run: typing.Optional[bool] = None, eval_data: typing.Optional[core.File] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> DatasetsCreateResponse: @@ -1227,9 +1165,6 @@ async def create( csv_delimiter : typing.Optional[str] The delimiter used for .csv uploads. - dry_run : typing.Optional[bool] - flag to enable dry_run mode - eval_data : typing.Optional[core.File] See core.File for more documentation @@ -1274,7 +1209,6 @@ async def main() -> None: "optional_fields": optional_fields, "text_separator": text_separator, "csv_delimiter": csv_delimiter, - "dry_run": dry_run, }, data={}, files={ @@ -1336,9 +1270,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1346,19 +1280,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1366,9 +1290,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1386,9 +1310,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1406,9 +1330,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1507,9 +1431,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1517,19 +1441,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1537,9 +1451,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1557,9 +1471,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1577,9 +1491,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1682,9 +1596,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1692,19 +1606,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1712,9 +1616,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1732,9 +1636,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1752,9 +1656,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1859,9 +1763,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1869,19 +1773,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1889,9 +1783,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1909,9 +1803,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1929,9 +1823,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/datasets/types/__init__.py b/src/cohere/datasets/types/__init__.py index 5d0f602a2..8a695cfe0 100644 --- a/src/cohere/datasets/types/__init__.py +++ b/src/cohere/datasets/types/__init__.py @@ -1,15 +1,8 @@ # This file was auto-generated by Fern from our API Definition. from .datasets_create_response import DatasetsCreateResponse -from .datasets_create_response_dataset_parts_item import DatasetsCreateResponseDatasetPartsItem from .datasets_get_response import DatasetsGetResponse from .datasets_get_usage_response import DatasetsGetUsageResponse from .datasets_list_response import DatasetsListResponse -__all__ = [ - "DatasetsCreateResponse", - "DatasetsCreateResponseDatasetPartsItem", - "DatasetsGetResponse", - "DatasetsGetUsageResponse", - "DatasetsListResponse", -] +__all__ = ["DatasetsCreateResponse", "DatasetsGetResponse", "DatasetsGetUsageResponse", "DatasetsListResponse"] diff --git a/src/cohere/datasets/types/datasets_create_response_dataset_parts_item.py b/src/cohere/datasets/types/datasets_create_response_dataset_parts_item.py deleted file mode 100644 index 77a9bcded..000000000 --- a/src/cohere/datasets/types/datasets_create_response_dataset_parts_item.py +++ /dev/null @@ -1,36 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.unchecked_base_model import UncheckedBaseModel -import typing -import pydantic -from ...core.pydantic_utilities import IS_PYDANTIC_V2 - - -class DatasetsCreateResponseDatasetPartsItem(UncheckedBaseModel): - """ - the underlying files that make up the dataset - """ - - name: typing.Optional[str] = pydantic.Field(default=None) - """ - the name of the dataset part - """ - - num_rows: typing.Optional[float] = pydantic.Field(default=None) - """ - the number of rows in the dataset part - """ - - samples: typing.Optional[typing.List[str]] = None - part_kind: typing.Optional[str] = pydantic.Field(default=None) - """ - the kind of dataset part - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 - else: - - class Config: - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/cohere/embed_jobs/client.py b/src/cohere/embed_jobs/client.py index bb1e5ce92..a667c7549 100644 --- a/src/cohere/embed_jobs/client.py +++ b/src/cohere/embed_jobs/client.py @@ -10,13 +10,17 @@ from ..errors.forbidden_error import ForbiddenError from ..errors.not_found_error import NotFoundError from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..errors.too_many_requests_error import TooManyRequestsError -from ..errors.invalid_token_error import InvalidTokenError +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody from ..errors.client_closed_request_error import ClientClosedRequestError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..errors.internal_server_error import InternalServerError from ..errors.not_implemented_error import NotImplementedError +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..types.embed_input_type import EmbedInputType @@ -116,9 +120,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -126,19 +130,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -146,9 +140,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -166,9 +160,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -186,9 +180,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -281,9 +275,6 @@ def create( "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -339,9 +330,9 @@ def create( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -349,19 +340,9 @@ def create( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -369,9 +350,9 @@ def create( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -389,9 +370,9 @@ def create( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -409,9 +390,9 @@ def create( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -507,9 +488,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -517,19 +498,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -537,9 +508,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -557,9 +528,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -577,9 +548,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -668,9 +639,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -678,19 +649,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -698,9 +659,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -718,9 +679,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -738,9 +699,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -844,9 +805,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -854,19 +815,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -874,9 +825,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -894,9 +845,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -914,9 +865,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1017,9 +968,6 @@ async def main() -> None: "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1075,9 +1023,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1085,19 +1033,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1105,9 +1043,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1125,9 +1063,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1145,9 +1083,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1251,9 +1189,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1261,19 +1199,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1281,9 +1209,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1301,9 +1229,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1321,9 +1249,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1420,9 +1348,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1430,19 +1358,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1450,9 +1368,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1470,9 +1388,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1490,9 +1408,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/errors/__init__.py b/src/cohere/errors/__init__.py index b23a4369d..c48c1d74a 100644 --- a/src/cohere/errors/__init__.py +++ b/src/cohere/errors/__init__.py @@ -5,7 +5,6 @@ from .forbidden_error import ForbiddenError from .gateway_timeout_error import GatewayTimeoutError from .internal_server_error import InternalServerError -from .invalid_token_error import InvalidTokenError from .not_found_error import NotFoundError from .not_implemented_error import NotImplementedError from .service_unavailable_error import ServiceUnavailableError @@ -19,7 +18,6 @@ "ForbiddenError", "GatewayTimeoutError", "InternalServerError", - "InvalidTokenError", "NotFoundError", "NotImplementedError", "ServiceUnavailableError", diff --git a/src/cohere/errors/client_closed_request_error.py b/src/cohere/errors/client_closed_request_error.py index adfaa83a9..83e68c96d 100644 --- a/src/cohere/errors/client_closed_request_error.py +++ b/src/cohere/errors/client_closed_request_error.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from ..core.api_error import ApiError -import typing +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody class ClientClosedRequestError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): + def __init__(self, body: ClientClosedRequestErrorBody): super().__init__(status_code=499, body=body) diff --git a/src/cohere/errors/gateway_timeout_error.py b/src/cohere/errors/gateway_timeout_error.py index 5a858551a..8d1617d80 100644 --- a/src/cohere/errors/gateway_timeout_error.py +++ b/src/cohere/errors/gateway_timeout_error.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from ..core.api_error import ApiError -import typing +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody class GatewayTimeoutError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): + def __init__(self, body: GatewayTimeoutErrorBody): super().__init__(status_code=504, body=body) diff --git a/src/cohere/errors/invalid_token_error.py b/src/cohere/errors/invalid_token_error.py deleted file mode 100644 index 816ea46bb..000000000 --- a/src/cohere/errors/invalid_token_error.py +++ /dev/null @@ -1,9 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ..core.api_error import ApiError -import typing - - -class InvalidTokenError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): - super().__init__(status_code=498, body=body) diff --git a/src/cohere/errors/not_implemented_error.py b/src/cohere/errors/not_implemented_error.py index 1219b9730..7dc79f06c 100644 --- a/src/cohere/errors/not_implemented_error.py +++ b/src/cohere/errors/not_implemented_error.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from ..core.api_error import ApiError -import typing +from ..types.not_implemented_error_body import NotImplementedErrorBody class NotImplementedError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): + def __init__(self, body: NotImplementedErrorBody): super().__init__(status_code=501, body=body) diff --git a/src/cohere/errors/too_many_requests_error.py b/src/cohere/errors/too_many_requests_error.py index 5361d6a87..ca82908cd 100644 --- a/src/cohere/errors/too_many_requests_error.py +++ b/src/cohere/errors/too_many_requests_error.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from ..core.api_error import ApiError -import typing +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody class TooManyRequestsError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): + def __init__(self, body: TooManyRequestsErrorBody): super().__init__(status_code=429, body=body) diff --git a/src/cohere/errors/unprocessable_entity_error.py b/src/cohere/errors/unprocessable_entity_error.py index 5666f3627..e27104ea7 100644 --- a/src/cohere/errors/unprocessable_entity_error.py +++ b/src/cohere/errors/unprocessable_entity_error.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from ..core.api_error import ApiError -import typing +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody class UnprocessableEntityError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): + def __init__(self, body: UnprocessableEntityErrorBody): super().__init__(status_code=422, body=body) diff --git a/src/cohere/finetuning/client.py b/src/cohere/finetuning/client.py index 8d431aa77..73c1e9b84 100644 --- a/src/cohere/finetuning/client.py +++ b/src/cohere/finetuning/client.py @@ -47,8 +47,7 @@ def list_finetuned_models( Parameters ---------- page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. @@ -59,7 +58,8 @@ def list_finetuned_models( " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + + - created_at (default) request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -589,9 +589,6 @@ def update_finetuned_model( "completed_at": completed_at, "last_used": last_used, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -685,8 +682,7 @@ def list_events( The parent fine-tuned model ID. page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. @@ -697,7 +693,8 @@ def list_events( " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + + - created_at (default) request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -818,8 +815,7 @@ def list_training_step_metrics( The parent fine-tuned model ID. page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. @@ -944,8 +940,7 @@ async def list_finetuned_models( Parameters ---------- page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. @@ -956,7 +951,8 @@ async def list_finetuned_models( " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + + - created_at (default) request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1526,9 +1522,6 @@ async def main() -> None: "completed_at": completed_at, "last_used": last_used, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1622,8 +1615,7 @@ async def list_events( The parent fine-tuned model ID. page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. @@ -1634,7 +1626,8 @@ async def list_events( " desc" to the field name. For example: "created_at desc,name". Supported sorting fields: - - created_at (default) + + - created_at (default) request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1763,8 +1756,7 @@ async def list_training_step_metrics( The parent fine-tuned model ID. page_size : typing.Optional[int] - Maximum number of results to be returned by the server. If 0, defaults to - 50. + Maximum number of results to be returned by the server. If 0, defaults to 50. page_token : typing.Optional[str] Request a specific page of the list results. diff --git a/src/cohere/models/client.py b/src/cohere/models/client.py index 9d516495b..8022ad214 100644 --- a/src/cohere/models/client.py +++ b/src/cohere/models/client.py @@ -11,13 +11,17 @@ from ..errors.forbidden_error import ForbiddenError from ..errors.not_found_error import NotFoundError from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..errors.too_many_requests_error import TooManyRequestsError -from ..errors.invalid_token_error import InvalidTokenError +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody from ..errors.client_closed_request_error import ClientClosedRequestError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..errors.internal_server_error import InternalServerError from ..errors.not_implemented_error import NotImplementedError +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..types.compatible_endpoint import CompatibleEndpoint @@ -114,9 +118,9 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -124,19 +128,9 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -144,9 +138,9 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -164,9 +158,9 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -184,9 +178,9 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -304,9 +298,9 @@ def list( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -314,19 +308,9 @@ def list( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -334,9 +318,9 @@ def list( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -354,9 +338,9 @@ def list( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -374,9 +358,9 @@ def list( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -484,9 +468,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -494,19 +478,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -514,9 +488,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -534,9 +508,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -554,9 +528,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -682,9 +656,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -692,19 +666,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -712,9 +676,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -732,9 +696,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -752,9 +716,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/types/__init__.py b/src/cohere/types/__init__.py index 48d31b72b..c5bb68837 100644 --- a/src/cohere/types/__init__.py +++ b/src/cohere/types/__init__.py @@ -44,10 +44,8 @@ ) from .chat_messages import ChatMessages from .chat_request_citation_quality import ChatRequestCitationQuality -from .chat_request_connectors_search_options import ChatRequestConnectorsSearchOptions from .chat_request_prompt_truncation import ChatRequestPromptTruncation from .chat_request_safety_mode import ChatRequestSafetyMode -from .chat_response import ChatResponse from .chat_search_queries_generation_event import ChatSearchQueriesGenerationEvent from .chat_search_query import ChatSearchQuery from .chat_search_result import ChatSearchResult @@ -58,7 +56,6 @@ from .chat_stream_event import ChatStreamEvent from .chat_stream_event_type import ChatStreamEventType from .chat_stream_request_citation_quality import ChatStreamRequestCitationQuality -from .chat_stream_request_connectors_search_options import ChatStreamRequestConnectorsSearchOptions from .chat_stream_request_prompt_truncation import ChatStreamRequestPromptTruncation from .chat_stream_request_safety_mode import ChatStreamRequestSafetyMode from .chat_stream_start_event import ChatStreamStartEvent @@ -96,6 +93,7 @@ ClassifyResponseClassificationsItemClassificationType, ) from .classify_response_classifications_item_labels_value import ClassifyResponseClassificationsItemLabelsValue +from .client_closed_request_error_body import ClientClosedRequestErrorBody from .compatible_endpoint import CompatibleEndpoint from .connector import Connector from .connector_auth_status import ConnectorAuthStatus @@ -113,6 +111,7 @@ from .detokenize_response import DetokenizeResponse from .document import Document from .document_content import DocumentContent +from .document_source import DocumentSource from .embed_by_type_response import EmbedByTypeResponse from .embed_by_type_response_embeddings import EmbedByTypeResponseEmbeddings from .embed_floats_response import EmbedFloatsResponse @@ -125,6 +124,7 @@ from .embedding_type import EmbeddingType from .finetune_dataset_metrics import FinetuneDatasetMetrics from .finish_reason import FinishReason +from .gateway_timeout_error_body import GatewayTimeoutErrorBody from .generate_request_return_likelihoods import GenerateRequestReturnLikelihoods from .generate_request_truncate import GenerateRequestTruncate from .generate_stream_end import GenerateStreamEnd @@ -153,9 +153,8 @@ from .logprob_item import LogprobItem from .message import ChatbotMessage, Message, SystemMessage, ToolMessage, UserMessage from .metrics import Metrics -from .metrics_embed_data import MetricsEmbedData -from .metrics_embed_data_fields_item import MetricsEmbedDataFieldsItem from .non_streamed_chat_response import NonStreamedChatResponse +from .not_implemented_error_body import NotImplementedErrorBody from .o_auth_authorize_response import OAuthAuthorizeResponse from .parse_info import ParseInfo from .rerank_document import RerankDocument @@ -182,44 +181,38 @@ ToolCallsChunkStreamedChatResponse, ToolCallsGenerationStreamedChatResponse, ) -from .streamed_chat_response_v2 import ( - CitationEndStreamedChatResponseV2, - CitationStartStreamedChatResponseV2, - ContentDeltaStreamedChatResponseV2, - ContentEndStreamedChatResponseV2, - ContentStartStreamedChatResponseV2, - DebugStreamedChatResponseV2, - MessageEndStreamedChatResponseV2, - MessageStartStreamedChatResponseV2, - StreamedChatResponseV2, - ToolCallDeltaStreamedChatResponseV2, - ToolCallEndStreamedChatResponseV2, - ToolCallStartStreamedChatResponseV2, - ToolPlanDeltaStreamedChatResponseV2, -) from .summarize_request_extractiveness import SummarizeRequestExtractiveness from .summarize_request_format import SummarizeRequestFormat from .summarize_request_length import SummarizeRequestLength from .summarize_response import SummarizeResponse +from .system_message import SystemMessage from .system_message_content import SystemMessageContent from .system_message_content_item import SystemMessageContentItem, TextSystemMessageContentItem +from .text_content import TextContent +from .text_response_format import TextResponseFormat +from .text_response_format_v2 import TextResponseFormatV2 from .tokenize_response import TokenizeResponse +from .too_many_requests_error_body import TooManyRequestsErrorBody from .tool import Tool from .tool_call import ToolCall from .tool_call_delta import ToolCallDelta from .tool_call_v2 import ToolCallV2 from .tool_call_v2function import ToolCallV2Function from .tool_content import DocumentToolContent, TextToolContent, ToolContent +from .tool_message import ToolMessage from .tool_message_v2 import ToolMessageV2 from .tool_message_v2content import ToolMessageV2Content from .tool_parameter_definitions_value import ToolParameterDefinitionsValue from .tool_result import ToolResult +from .tool_source import ToolSource from .tool_v2 import ToolV2 from .tool_v2function import ToolV2Function +from .unprocessable_entity_error_body import UnprocessableEntityErrorBody from .update_connector_response import UpdateConnectorResponse from .usage import Usage from .usage_billed_units import UsageBilledUnits from .usage_tokens import UsageTokens +from .user_message import UserMessage from .user_message_content import UserMessageContent __all__ = [ @@ -259,10 +252,8 @@ "ChatMessageV2", "ChatMessages", "ChatRequestCitationQuality", - "ChatRequestConnectorsSearchOptions", "ChatRequestPromptTruncation", "ChatRequestSafetyMode", - "ChatResponse", "ChatSearchQueriesGenerationEvent", "ChatSearchQuery", "ChatSearchResult", @@ -273,7 +264,6 @@ "ChatStreamEvent", "ChatStreamEventType", "ChatStreamRequestCitationQuality", - "ChatStreamRequestConnectorsSearchOptions", "ChatStreamRequestPromptTruncation", "ChatStreamRequestSafetyMode", "ChatStreamStartEvent", @@ -296,14 +286,12 @@ "CheckApiKeyResponse", "Citation", "CitationEndEvent", - "CitationEndStreamedChatResponseV2", "CitationGenerationStreamedChatResponse", "CitationOptions", "CitationOptionsMode", "CitationStartEvent", "CitationStartEventDelta", "CitationStartEventDeltaMessage", - "CitationStartStreamedChatResponseV2", "ClassifyDataMetrics", "ClassifyExample", "ClassifyRequestTruncate", @@ -311,14 +299,12 @@ "ClassifyResponseClassificationsItem", "ClassifyResponseClassificationsItemClassificationType", "ClassifyResponseClassificationsItemLabelsValue", + "ClientClosedRequestErrorBody", "CompatibleEndpoint", "Connector", "ConnectorAuthStatus", "ConnectorOAuth", "Content", - "ContentDeltaStreamedChatResponseV2", - "ContentEndStreamedChatResponseV2", - "ContentStartStreamedChatResponseV2", "CreateConnectorOAuth", "CreateConnectorResponse", "CreateConnectorServiceAuth", @@ -328,7 +314,6 @@ "DatasetType", "DatasetValidationStatus", "DebugStreamedChatResponse", - "DebugStreamedChatResponseV2", "DeleteConnectorResponse", "DetokenizeResponse", "Document", @@ -349,6 +334,7 @@ "EmbeddingsFloatsEmbedResponse", "FinetuneDatasetMetrics", "FinishReason", + "GatewayTimeoutErrorBody", "GenerateRequestReturnLikelihoods", "GenerateRequestTruncate", "GenerateStreamEnd", @@ -373,12 +359,9 @@ "ListModelsResponse", "LogprobItem", "Message", - "MessageEndStreamedChatResponseV2", - "MessageStartStreamedChatResponseV2", "Metrics", - "MetricsEmbedData", - "MetricsEmbedDataFieldsItem", "NonStreamedChatResponse", + "NotImplementedErrorBody", "OAuthAuthorizeResponse", "ParseInfo", "RerankDocument", @@ -400,7 +383,6 @@ "StreamErrorGenerateStreamedResponse", "StreamStartStreamedChatResponse", "StreamedChatResponse", - "StreamedChatResponseV2", "SummarizeRequestExtractiveness", "SummarizeRequestFormat", "SummarizeRequestLength", @@ -419,12 +401,10 @@ "TextSystemMessageContentItem", "TextToolContent", "TokenizeResponse", + "TooManyRequestsErrorBody", "Tool", "ToolCall", "ToolCallDelta", - "ToolCallDeltaStreamedChatResponseV2", - "ToolCallEndStreamedChatResponseV2", - "ToolCallStartStreamedChatResponseV2", "ToolCallV2", "ToolCallV2Function", "ToolCallsChunkStreamedChatResponse", @@ -435,11 +415,11 @@ "ToolMessageV2", "ToolMessageV2Content", "ToolParameterDefinitionsValue", - "ToolPlanDeltaStreamedChatResponseV2", "ToolResult", "ToolSource", "ToolV2", "ToolV2Function", + "UnprocessableEntityErrorBody", "UpdateConnectorResponse", "Usage", "UsageBilledUnits", diff --git a/src/cohere/types/chat_request_connectors_search_options.py b/src/cohere/types/chat_request_connectors_search_options.py deleted file mode 100644 index e22dd7a30..000000000 --- a/src/cohere/types/chat_request_connectors_search_options.py +++ /dev/null @@ -1,30 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ..core.unchecked_base_model import UncheckedBaseModel -import typing -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 - - -class ChatRequestConnectorsSearchOptions(UncheckedBaseModel): - """ - (internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of connectors_search_options are ignored (such as model= or temperature=). - """ - - seed: typing.Optional[int] = pydantic.Field(default=None) - """ - If specified, the backend will make a best effort to sample tokens - deterministically, such that repeated requests with the same - seed and parameters should return the same result. However, - determinism cannot be totally guaranteed. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 - else: - - class Config: - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/cohere/types/chat_stream_request_connectors_search_options.py b/src/cohere/types/chat_stream_request_connectors_search_options.py deleted file mode 100644 index ad7d8e3ce..000000000 --- a/src/cohere/types/chat_stream_request_connectors_search_options.py +++ /dev/null @@ -1,30 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ..core.unchecked_base_model import UncheckedBaseModel -import typing -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 - - -class ChatStreamRequestConnectorsSearchOptions(UncheckedBaseModel): - """ - (internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of connectors_search_options are ignored (such as model= or temperature=). - """ - - seed: typing.Optional[int] = pydantic.Field(default=None) - """ - If specified, the backend will make a best effort to sample tokens - deterministically, such that repeated requests with the same - seed and parameters should return the same result. However, - determinism cannot be totally guaranteed. - - Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 - else: - - class Config: - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/cohere/types/metrics_embed_data.py b/src/cohere/types/client_closed_request_error_body.py similarity index 64% rename from src/cohere/types/metrics_embed_data.py rename to src/cohere/types/client_closed_request_error_body.py index 72ff014d1..d8a8bbf2e 100644 --- a/src/cohere/types/metrics_embed_data.py +++ b/src/cohere/types/client_closed_request_error_body.py @@ -2,16 +2,12 @@ from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .metrics_embed_data_fields_item import MetricsEmbedDataFieldsItem -import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class MetricsEmbedData(UncheckedBaseModel): - fields: typing.Optional[typing.List[MetricsEmbedDataFieldsItem]] = pydantic.Field(default=None) - """ - the fields in the dataset - """ +class ClientClosedRequestErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/metrics_embed_data_fields_item.py b/src/cohere/types/gateway_timeout_error_body.py similarity index 60% rename from src/cohere/types/metrics_embed_data_fields_item.py rename to src/cohere/types/gateway_timeout_error_body.py index c1b3d5aef..bd5abd678 100644 --- a/src/cohere/types/metrics_embed_data_fields_item.py +++ b/src/cohere/types/gateway_timeout_error_body.py @@ -2,20 +2,12 @@ from ..core.unchecked_base_model import UncheckedBaseModel import typing -import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class MetricsEmbedDataFieldsItem(UncheckedBaseModel): - name: typing.Optional[str] = pydantic.Field(default=None) - """ - the name of the field - """ - - count: typing.Optional[float] = pydantic.Field(default=None) - """ - the number of times the field appears in the dataset - """ +class GatewayTimeoutErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/json_response_format.py b/src/cohere/types/json_response_format.py index 42b02cae3..d12edb8ef 100644 --- a/src/cohere/types/json_response_format.py +++ b/src/cohere/types/json_response_format.py @@ -15,12 +15,13 @@ class JsonResponseFormat(UncheckedBaseModel): """ A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. Example (required name and age object): + ```json { "type": "object", "properties": { - "name": {"type": "string"}, - "age": {"type": "integer"} + "name": { "type": "string" }, + "age": { "type": "integer" } }, "required": ["name", "age"] } diff --git a/src/cohere/types/json_response_format_v2.py b/src/cohere/types/json_response_format_v2.py index 830c6d386..42721388e 100644 --- a/src/cohere/types/json_response_format_v2.py +++ b/src/cohere/types/json_response_format_v2.py @@ -11,12 +11,13 @@ class JsonResponseFormatV2(UncheckedBaseModel): """ A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. Example (required name and age object): + ```json { "type": "object", "properties": { - "name": {"type": "string"}, - "age": {"type": "integer"} + "name": { "type": "string" }, + "age": { "type": "integer" } }, "required": ["name", "age"] } diff --git a/src/cohere/types/metrics.py b/src/cohere/types/metrics.py index 3c54392d5..26be9a9b3 100644 --- a/src/cohere/types/metrics.py +++ b/src/cohere/types/metrics.py @@ -3,14 +3,12 @@ from ..core.unchecked_base_model import UncheckedBaseModel import typing from .finetune_dataset_metrics import FinetuneDatasetMetrics -from .metrics_embed_data import MetricsEmbedData from ..core.pydantic_utilities import IS_PYDANTIC_V2 import pydantic class Metrics(UncheckedBaseModel): finetune_dataset_metrics: typing.Optional[FinetuneDatasetMetrics] = None - embed_data: typing.Optional[MetricsEmbedData] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/non_streamed_chat_response.py b/src/cohere/types/non_streamed_chat_response.py index b311ca425..722663c22 100644 --- a/src/cohere/types/non_streamed_chat_response.py +++ b/src/cohere/types/non_streamed_chat_response.py @@ -62,11 +62,6 @@ class NonStreamedChatResponse(UncheckedBaseModel): A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's `message`. """ - prompt: typing.Optional[str] = pydantic.Field(default=None) - """ - The prompt that was used. Only present when `return_prompt` in the request is set to true. - """ - meta: typing.Optional[ApiMeta] = None if IS_PYDANTIC_V2: diff --git a/src/cohere/types/not_implemented_error_body.py b/src/cohere/types/not_implemented_error_body.py new file mode 100644 index 000000000..d0855d3d8 --- /dev/null +++ b/src/cohere/types/not_implemented_error_body.py @@ -0,0 +1,18 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.unchecked_base_model import UncheckedBaseModel +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class NotImplementedErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/cohere/types/response_format.py b/src/cohere/types/response_format.py index 48a9ffebd..3ba954c27 100644 --- a/src/cohere/types/response_format.py +++ b/src/cohere/types/response_format.py @@ -18,7 +18,7 @@ class TextResponseFormat(UncheckedBaseModel): A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. - **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. + **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided). """ @@ -41,7 +41,7 @@ class JsonObjectResponseFormat(UncheckedBaseModel): A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. - **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. + **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided). """ diff --git a/src/cohere/types/response_format_v2.py b/src/cohere/types/response_format_v2.py index 4f34dca62..934294546 100644 --- a/src/cohere/types/response_format_v2.py +++ b/src/cohere/types/response_format_v2.py @@ -17,7 +17,7 @@ class TextResponseFormatV2(UncheckedBaseModel): A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. - **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. + **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting. @@ -43,7 +43,7 @@ class JsonObjectResponseFormatV2(UncheckedBaseModel): A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. - **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. + **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting. diff --git a/src/cohere/types/too_many_requests_error_body.py b/src/cohere/types/too_many_requests_error_body.py new file mode 100644 index 000000000..ade0cfc86 --- /dev/null +++ b/src/cohere/types/too_many_requests_error_body.py @@ -0,0 +1,18 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.unchecked_base_model import UncheckedBaseModel +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class TooManyRequestsErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/cohere/types/tool.py b/src/cohere/types/tool.py index c77f475ff..44354755b 100644 --- a/src/cohere/types/tool.py +++ b/src/cohere/types/tool.py @@ -23,6 +23,7 @@ class Tool(UncheckedBaseModel): ) """ The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit. + ``` { "my_param": { diff --git a/src/cohere/types/unprocessable_entity_error_body.py b/src/cohere/types/unprocessable_entity_error_body.py new file mode 100644 index 000000000..697759a3c --- /dev/null +++ b/src/cohere/types/unprocessable_entity_error_body.py @@ -0,0 +1,18 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.unchecked_base_model import UncheckedBaseModel +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class UnprocessableEntityErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/cohere/v2/__init__.py b/src/cohere/v2/__init__.py index 826c9ac29..1cd7a71cd 100644 --- a/src/cohere/v2/__init__.py +++ b/src/cohere/v2/__init__.py @@ -1,27 +1,53 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( + CitationEndV2ChatStreamResponse, + CitationStartV2ChatStreamResponse, + ContentDeltaV2ChatStreamResponse, + ContentEndV2ChatStreamResponse, + ContentStartV2ChatStreamResponse, + DebugV2ChatStreamResponse, + MessageEndV2ChatStreamResponse, + MessageStartV2ChatStreamResponse, + ToolCallDeltaV2ChatStreamResponse, + ToolCallEndV2ChatStreamResponse, + ToolCallStartV2ChatStreamResponse, + ToolPlanDeltaV2ChatStreamResponse, V2ChatRequestDocumentsItem, V2ChatRequestSafetyMode, V2ChatRequestToolChoice, + V2ChatResponse, V2ChatStreamRequestDocumentsItem, V2ChatStreamRequestSafetyMode, V2ChatStreamRequestToolChoice, + V2ChatStreamResponse, V2EmbedRequestTruncate, V2RerankResponse, V2RerankResponseResultsItem, - V2RerankResponseResultsItemDocument, ) __all__ = [ + "CitationEndV2ChatStreamResponse", + "CitationStartV2ChatStreamResponse", + "ContentDeltaV2ChatStreamResponse", + "ContentEndV2ChatStreamResponse", + "ContentStartV2ChatStreamResponse", + "DebugV2ChatStreamResponse", + "MessageEndV2ChatStreamResponse", + "MessageStartV2ChatStreamResponse", + "ToolCallDeltaV2ChatStreamResponse", + "ToolCallEndV2ChatStreamResponse", + "ToolCallStartV2ChatStreamResponse", + "ToolPlanDeltaV2ChatStreamResponse", "V2ChatRequestDocumentsItem", "V2ChatRequestSafetyMode", "V2ChatRequestToolChoice", + "V2ChatResponse", "V2ChatStreamRequestDocumentsItem", "V2ChatStreamRequestSafetyMode", "V2ChatStreamRequestToolChoice", + "V2ChatStreamResponse", "V2EmbedRequestTruncate", "V2RerankResponse", "V2RerankResponseResultsItem", - "V2RerankResponseResultsItemDocument", ] diff --git a/src/cohere/v2/client.py b/src/cohere/v2/client.py index 436b4c67a..dbf9b668c 100644 --- a/src/cohere/v2/client.py +++ b/src/cohere/v2/client.py @@ -10,7 +10,7 @@ from .types.v2chat_stream_request_safety_mode import V2ChatStreamRequestSafetyMode from .types.v2chat_stream_request_tool_choice import V2ChatStreamRequestToolChoice from ..core.request_options import RequestOptions -from ..types.streamed_chat_response_v2 import StreamedChatResponseV2 +from .types.v2chat_stream_response import V2ChatStreamResponse from ..core.serialization import convert_and_respect_annotation_metadata import httpx_sse from ..core.unchecked_base_model import construct_type @@ -20,19 +20,23 @@ from ..errors.forbidden_error import ForbiddenError from ..errors.not_found_error import NotFoundError from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..errors.too_many_requests_error import TooManyRequestsError -from ..errors.invalid_token_error import InvalidTokenError +from ..types.too_many_requests_error_body import TooManyRequestsErrorBody from ..errors.client_closed_request_error import ClientClosedRequestError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..errors.internal_server_error import InternalServerError from ..errors.not_implemented_error import NotImplementedError +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from json.decoder import JSONDecodeError from ..core.api_error import ApiError from .types.v2chat_request_documents_item import V2ChatRequestDocumentsItem from .types.v2chat_request_safety_mode import V2ChatRequestSafetyMode from .types.v2chat_request_tool_choice import V2ChatRequestToolChoice -from ..types.chat_response import ChatResponse +from .types.v2chat_response import V2ChatResponse from ..types.embed_input_type import EmbedInputType from ..types.embedding_type import EmbeddingType from .types.v2embed_request_truncate import V2EmbedRequestTruncate @@ -67,13 +71,12 @@ def chat_stream( presence_penalty: typing.Optional[float] = OMIT, k: typing.Optional[float] = OMIT, p: typing.Optional[float] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, logprobs: typing.Optional[bool] = OMIT, tool_choice: typing.Optional[V2ChatStreamRequestToolChoice] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[StreamedChatResponseV2]: + ) -> typing.Iterator[V2ChatStreamResponse]: """ - Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). + Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2. @@ -160,9 +163,6 @@ def chat_stream( Defaults to `0.75`. min value of `0.01`, max value of `0.99`. - return_prompt : typing.Optional[bool] - Whether to return the prompt in the response. - logprobs : typing.Optional[bool] Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response. @@ -182,23 +182,22 @@ def chat_stream( Yields ------ - typing.Iterator[StreamedChatResponseV2] + typing.Iterator[V2ChatStreamResponse] Examples -------- - from cohere import Client, ToolChatMessageV2 + from cohere import Client, UserChatMessageV2 client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) response = client.v2.chat_stream( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Hello!", ) ], ) @@ -235,14 +234,10 @@ def chat_stream( "presence_penalty": presence_penalty, "k": k, "p": p, - "return_prompt": return_prompt, "logprobs": logprobs, "tool_choice": tool_choice, "stream": True, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) as _response: @@ -252,9 +247,9 @@ def chat_stream( for _sse in _event_source.iter_sse(): try: yield typing.cast( - StreamedChatResponseV2, + V2ChatStreamResponse, construct_type( - type_=StreamedChatResponseV2, # type: ignore + type_=V2ChatStreamResponse, # type: ignore object_=json.loads(_sse.data), ), ) @@ -305,9 +300,9 @@ def chat_stream( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -315,19 +310,9 @@ def chat_stream( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -335,9 +320,9 @@ def chat_stream( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -355,9 +340,9 @@ def chat_stream( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -375,9 +360,9 @@ def chat_stream( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -406,11 +391,10 @@ def chat( presence_penalty: typing.Optional[float] = OMIT, k: typing.Optional[float] = OMIT, p: typing.Optional[float] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, logprobs: typing.Optional[bool] = OMIT, tool_choice: typing.Optional[V2ChatRequestToolChoice] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> ChatResponse: + ) -> V2ChatResponse: """ Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). @@ -499,9 +483,6 @@ def chat( Defaults to `0.75`. min value of `0.01`, max value of `0.99`. - return_prompt : typing.Optional[bool] - Whether to return the prompt in the response. - logprobs : typing.Optional[bool] Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response. @@ -521,23 +502,22 @@ def chat( Returns ------- - ChatResponse + V2ChatResponse Examples -------- - from cohere import Client, ToolChatMessageV2 + from cohere import Client, UserChatMessageV2 client = Client( client_name="YOUR_CLIENT_NAME", token="YOUR_TOKEN", ) client.v2.chat( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Tell me about LLMs", ) ], ) @@ -572,23 +552,19 @@ def chat( "presence_penalty": presence_penalty, "k": k, "p": p, - "return_prompt": return_prompt, "logprobs": logprobs, "tool_choice": tool_choice, "stream": False, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: return typing.cast( - ChatResponse, + V2ChatResponse, construct_type( - type_=ChatResponse, # type: ignore + type_=V2ChatResponse, # type: ignore object_=_response.json(), ), ) @@ -635,9 +611,9 @@ def chat( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -645,19 +621,9 @@ def chat( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -665,9 +631,9 @@ def chat( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -685,9 +651,9 @@ def chat( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -705,9 +671,9 @@ def chat( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -796,9 +762,12 @@ def embed( token="YOUR_TOKEN", ) client.v2.embed( - model="model", - input_type="search_document", + model="embed-english-v3.0", + input_type="image", embedding_types=["float"], + images=[ + "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gAfQ29tcHJlc3NlZCBieSBqcGVnLXJlY29tcHJlc3P/2wCEAAQEBAQEBAQEBAQGBgUGBggHBwcHCAwJCQkJCQwTDA4MDA4MExEUEA8QFBEeFxUVFx4iHRsdIiolJSo0MjRERFwBBAQEBA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5JqLojgUYyNqznvZ2q46GYLKDq0khPejk/8ArOsU6HX1irTWre8xDeQBk4/FHduPtALEKozJq3skjAaQaT/wOqv4NJdco3jj6bNtby3c8VtAulJIwVRWCYJb4PbKqqGnYDWSdpPcPLZ6V9HEmikxOxjAlQaUqL9Q7x5+2xgCrrmG8/p9OrIDAg8CKkTQd07iRsdBcPV3ucSkX9H9KP1O8naIBBBG410gsBh2K3MCDKNjrE/2tSLpuqDtIFKAqhRwA6y9GVw/mAdjohEEwK2I4u0jH/Lb6exgXljL2tEwP9pq0GdzF69bfHO4fyAGx0ScPgVpl9JkB/yO309cG6w9O0ROeZq3bQnib/UOsJyBJqV9ZI7952Ogl8DDdYezfEra1B5HcdvpTfC+xicoc44QIl/t4/z7LaUTRK3bwPr1d9PoJqlPxN/A2cOvpsNvIbyA/Eh3jvHaDWHYjbYnapdWzgg/qHap7js9JseTDLZreBwbuVSAB9AP1GiSSSeJ9ltcGB8/pPEUjq6hlOYPU3FykC97dgp3aRi7HMnaw3FbzCptdaSZeJDvVh5isO6aYdcqq3gNvJ25705ikxXDJAGS/gI/5FqfHMIt10pb+H0DBjyGdYr03XRaLCojnw1sg/6FTTSzyPNNIXkc5szHMnYhuJIDmh3doPCo7+F9z5oaE0R4SrzrWR/cXnWsj+4vOtZH9xeYrWx/cXmKe6gTjID6b6lxAnMQrl5mmYsSzEkn92//2Q==" + ], ) """ _response = self._client_wrapper.httpx_client.request( @@ -812,9 +781,6 @@ def embed( "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -870,9 +836,9 @@ def embed( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -880,19 +846,9 @@ def embed( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -900,9 +856,9 @@ def embed( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -920,9 +876,9 @@ def embed( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -940,9 +896,9 @@ def embed( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -959,7 +915,6 @@ def rerank( query: str, documents: typing.Sequence[str], top_n: typing.Optional[int] = OMIT, - return_documents: typing.Optional[bool] = OMIT, max_tokens_per_doc: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> V2RerankResponse: @@ -985,10 +940,6 @@ def rerank( top_n : typing.Optional[int] Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned. - return_documents : typing.Optional[bool] - - If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request. - - If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request. - max_tokens_per_doc : typing.Optional[int] Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens. @@ -1009,9 +960,16 @@ def rerank( token="YOUR_TOKEN", ) client.v2.rerank( - model="model", - query="query", - documents=["documents"], + documents=[ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) """ _response = self._client_wrapper.httpx_client.request( @@ -1022,12 +980,8 @@ def rerank( "query": query, "documents": documents, "top_n": top_n, - "return_documents": return_documents, "max_tokens_per_doc": max_tokens_per_doc, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -1083,9 +1037,9 @@ def rerank( if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1093,19 +1047,9 @@ def rerank( if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1113,9 +1057,9 @@ def rerank( if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1133,9 +1077,9 @@ def rerank( if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1153,9 +1097,9 @@ def rerank( if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1189,13 +1133,12 @@ async def chat_stream( presence_penalty: typing.Optional[float] = OMIT, k: typing.Optional[float] = OMIT, p: typing.Optional[float] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, logprobs: typing.Optional[bool] = OMIT, tool_choice: typing.Optional[V2ChatStreamRequestToolChoice] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[StreamedChatResponseV2]: + ) -> typing.AsyncIterator[V2ChatStreamResponse]: """ - Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). + Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2. @@ -1282,9 +1225,6 @@ async def chat_stream( Defaults to `0.75`. min value of `0.01`, max value of `0.99`. - return_prompt : typing.Optional[bool] - Whether to return the prompt in the response. - logprobs : typing.Optional[bool] Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response. @@ -1304,14 +1244,14 @@ async def chat_stream( Yields ------ - typing.AsyncIterator[StreamedChatResponseV2] + typing.AsyncIterator[V2ChatStreamResponse] Examples -------- import asyncio - from cohere import AsyncClient, ToolChatMessageV2 + from cohere import AsyncClient, UserChatMessageV2 client = AsyncClient( client_name="YOUR_CLIENT_NAME", @@ -1321,11 +1261,10 @@ async def chat_stream( async def main() -> None: response = await client.v2.chat_stream( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Hello!", ) ], ) @@ -1365,14 +1304,10 @@ async def main() -> None: "presence_penalty": presence_penalty, "k": k, "p": p, - "return_prompt": return_prompt, "logprobs": logprobs, "tool_choice": tool_choice, "stream": True, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) as _response: @@ -1382,9 +1317,9 @@ async def main() -> None: async for _sse in _event_source.aiter_sse(): try: yield typing.cast( - StreamedChatResponseV2, + V2ChatStreamResponse, construct_type( - type_=StreamedChatResponseV2, # type: ignore + type_=V2ChatStreamResponse, # type: ignore object_=json.loads(_sse.data), ), ) @@ -1435,9 +1370,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1445,19 +1380,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1465,9 +1390,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1485,9 +1410,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1505,9 +1430,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1536,11 +1461,10 @@ async def chat( presence_penalty: typing.Optional[float] = OMIT, k: typing.Optional[float] = OMIT, p: typing.Optional[float] = OMIT, - return_prompt: typing.Optional[bool] = OMIT, logprobs: typing.Optional[bool] = OMIT, tool_choice: typing.Optional[V2ChatRequestToolChoice] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> ChatResponse: + ) -> V2ChatResponse: """ Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). @@ -1629,9 +1553,6 @@ async def chat( Defaults to `0.75`. min value of `0.01`, max value of `0.99`. - return_prompt : typing.Optional[bool] - Whether to return the prompt in the response. - logprobs : typing.Optional[bool] Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response. @@ -1651,14 +1572,14 @@ async def chat( Returns ------- - ChatResponse + V2ChatResponse Examples -------- import asyncio - from cohere import AsyncClient, ToolChatMessageV2 + from cohere import AsyncClient, UserChatMessageV2 client = AsyncClient( client_name="YOUR_CLIENT_NAME", @@ -1668,11 +1589,10 @@ async def chat( async def main() -> None: await client.v2.chat( - model="model", + model="command-r", messages=[ - ToolChatMessageV2( - tool_call_id="messages", - content="messages", + UserChatMessageV2( + content="Tell me about LLMs", ) ], ) @@ -1710,23 +1630,19 @@ async def main() -> None: "presence_penalty": presence_penalty, "k": k, "p": p, - "return_prompt": return_prompt, "logprobs": logprobs, "tool_choice": tool_choice, "stream": False, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: return typing.cast( - ChatResponse, + V2ChatResponse, construct_type( - type_=ChatResponse, # type: ignore + type_=V2ChatResponse, # type: ignore object_=_response.json(), ), ) @@ -1773,9 +1689,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1783,19 +1699,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1803,9 +1709,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1823,9 +1729,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1843,9 +1749,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -1939,9 +1845,12 @@ async def embed( async def main() -> None: await client.v2.embed( - model="model", - input_type="search_document", + model="embed-english-v3.0", + input_type="image", embedding_types=["float"], + images=[ + "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gAfQ29tcHJlc3NlZCBieSBqcGVnLX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cq90TxGvdE8RoW0Q7M6Cqu5VA9kVrNLvC5DvNRWEa75CWPIUqqgyVQB5bVzarMCy7n7++mUoxVhkRtW9tPdypBbRNJI3BVFYf0FdlWTErnQP24uP5JqLojgUYyNqznvZ2q46GYLKDq0khPejk/8ArOsU6HX1irTWre8xDeQBk4/FHduPtALEKozJq3skjAaQaT/wOqv4NJdco3jj6bNtby3c8VtAulJIwVRWCYJb4PbKqqGnYDWSdpPcPLZ6V9HEmikxOxjAlQaUqL9Q7x5+2xgCrrmG8/p9OrIDAg8CKkTQd07iRsdBcPV3ucSkX9H9KP1O8naIBBBG410gsBh2K3MCDKNjrE/2tSLpuqDtIFKAqhRwA6y9GVw/mAdjohEEwK2I4u0jH/Lb6exgXljL2tEwP9pq0GdzF69bfHO4fyAGx0ScPgVpl9JkB/yO309cG6w9O0ROeZq3bQnib/UOsJyBJqV9ZI7952Ogl8DDdYezfEra1B5HcdvpTfC+xicoc44QIl/t4/z7LaUTRK3bwPr1d9PoJqlPxN/A2cOvpsNvIbyA/Eh3jvHaDWHYjbYnapdWzgg/qHap7js9JseTDLZreBwbuVSAB9AP1GiSSSeJ9ltcGB8/pPEUjq6hlOYPU3FykC97dgp3aRi7HMnaw3FbzCptdaSZeJDvVh5isO6aYdcqq3gNvJ25705ikxXDJAGS/gI/5FqfHMIt10pb+H0DBjyGdYr03XRaLCojnw1sg/6FTTSzyPNNIXkc5szHMnYhuJIDmh3doPCo7+F9z5oaE0R4SrzrWR/cXnWsj+4vOtZH9xeYrWx/cXmKe6gTjID6b6lxAnMQrl5mmYsSzEkn92//2Q==" + ], ) @@ -1958,9 +1867,6 @@ async def main() -> None: "embedding_types": embedding_types, "truncate": truncate, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2016,9 +1922,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2026,19 +1932,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2046,9 +1942,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2066,9 +1962,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2086,9 +1982,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2105,7 +2001,6 @@ async def rerank( query: str, documents: typing.Sequence[str], top_n: typing.Optional[int] = OMIT, - return_documents: typing.Optional[bool] = OMIT, max_tokens_per_doc: typing.Optional[int] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> V2RerankResponse: @@ -2131,10 +2026,6 @@ async def rerank( top_n : typing.Optional[int] Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned. - return_documents : typing.Optional[bool] - - If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request. - - If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request. - max_tokens_per_doc : typing.Optional[int] Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens. @@ -2160,9 +2051,16 @@ async def rerank( async def main() -> None: await client.v2.rerank( - model="model", - query="query", - documents=["documents"], + documents=[ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.", + ], + query="What is the capital of the United States?", + top_n=3, + model="rerank-v3.5", ) @@ -2176,12 +2074,8 @@ async def main() -> None: "query": query, "documents": documents, "top_n": top_n, - "return_documents": return_documents, "max_tokens_per_doc": max_tokens_per_doc, }, - headers={ - "content-type": "application/json", - }, request_options=request_options, omit=OMIT, ) @@ -2237,9 +2131,9 @@ async def main() -> None: if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( - typing.Optional[typing.Any], + UnprocessableEntityErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=UnprocessableEntityErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2247,19 +2141,9 @@ async def main() -> None: if _response.status_code == 429: raise TooManyRequestsError( typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 498: - raise InvalidTokenError( - typing.cast( - typing.Optional[typing.Any], + TooManyRequestsErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=TooManyRequestsErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2267,9 +2151,9 @@ async def main() -> None: if _response.status_code == 499: raise ClientClosedRequestError( typing.cast( - typing.Optional[typing.Any], + ClientClosedRequestErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=ClientClosedRequestErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2287,9 +2171,9 @@ async def main() -> None: if _response.status_code == 501: raise NotImplementedError( typing.cast( - typing.Optional[typing.Any], + NotImplementedErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=NotImplementedErrorBody, # type: ignore object_=_response.json(), ), ) @@ -2307,9 +2191,9 @@ async def main() -> None: if _response.status_code == 504: raise GatewayTimeoutError( typing.cast( - typing.Optional[typing.Any], + GatewayTimeoutErrorBody, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=GatewayTimeoutErrorBody, # type: ignore object_=_response.json(), ), ) diff --git a/src/cohere/v2/types/__init__.py b/src/cohere/v2/types/__init__.py index 4e5eddbee..3d2c40ea6 100644 --- a/src/cohere/v2/types/__init__.py +++ b/src/cohere/v2/types/__init__.py @@ -3,23 +3,51 @@ from .v2chat_request_documents_item import V2ChatRequestDocumentsItem from .v2chat_request_safety_mode import V2ChatRequestSafetyMode from .v2chat_request_tool_choice import V2ChatRequestToolChoice +from .v2chat_response import V2ChatResponse from .v2chat_stream_request_documents_item import V2ChatStreamRequestDocumentsItem from .v2chat_stream_request_safety_mode import V2ChatStreamRequestSafetyMode from .v2chat_stream_request_tool_choice import V2ChatStreamRequestToolChoice +from .v2chat_stream_response import ( + CitationEndV2ChatStreamResponse, + CitationStartV2ChatStreamResponse, + ContentDeltaV2ChatStreamResponse, + ContentEndV2ChatStreamResponse, + ContentStartV2ChatStreamResponse, + DebugV2ChatStreamResponse, + MessageEndV2ChatStreamResponse, + MessageStartV2ChatStreamResponse, + ToolCallDeltaV2ChatStreamResponse, + ToolCallEndV2ChatStreamResponse, + ToolCallStartV2ChatStreamResponse, + ToolPlanDeltaV2ChatStreamResponse, + V2ChatStreamResponse, +) from .v2embed_request_truncate import V2EmbedRequestTruncate from .v2rerank_response import V2RerankResponse from .v2rerank_response_results_item import V2RerankResponseResultsItem -from .v2rerank_response_results_item_document import V2RerankResponseResultsItemDocument __all__ = [ + "CitationEndV2ChatStreamResponse", + "CitationStartV2ChatStreamResponse", + "ContentDeltaV2ChatStreamResponse", + "ContentEndV2ChatStreamResponse", + "ContentStartV2ChatStreamResponse", + "DebugV2ChatStreamResponse", + "MessageEndV2ChatStreamResponse", + "MessageStartV2ChatStreamResponse", + "ToolCallDeltaV2ChatStreamResponse", + "ToolCallEndV2ChatStreamResponse", + "ToolCallStartV2ChatStreamResponse", + "ToolPlanDeltaV2ChatStreamResponse", "V2ChatRequestDocumentsItem", "V2ChatRequestSafetyMode", "V2ChatRequestToolChoice", + "V2ChatResponse", "V2ChatStreamRequestDocumentsItem", "V2ChatStreamRequestSafetyMode", "V2ChatStreamRequestToolChoice", + "V2ChatStreamResponse", "V2EmbedRequestTruncate", "V2RerankResponse", "V2RerankResponseResultsItem", - "V2RerankResponseResultsItemDocument", ] diff --git a/src/cohere/types/chat_response.py b/src/cohere/v2/types/v2chat_response.py similarity index 56% rename from src/cohere/types/chat_response.py rename to src/cohere/v2/types/v2chat_response.py index 483cbade6..34acae8da 100644 --- a/src/cohere/types/chat_response.py +++ b/src/cohere/v2/types/v2chat_response.py @@ -1,27 +1,22 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +from ...core.unchecked_base_model import UncheckedBaseModel import pydantic -from .chat_finish_reason import ChatFinishReason +from ...types.chat_finish_reason import ChatFinishReason +from ...types.assistant_message_response import AssistantMessageResponse import typing -from .assistant_message_response import AssistantMessageResponse -from .usage import Usage -from .logprob_item import LogprobItem -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ...types.usage import Usage +from ...types.logprob_item import LogprobItem +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ChatResponse(UncheckedBaseModel): +class V2ChatResponse(UncheckedBaseModel): id: str = pydantic.Field() """ Unique identifier for the generated reply. Useful for submitting feedback. """ finish_reason: ChatFinishReason - prompt: typing.Optional[str] = pydantic.Field(default=None) - """ - The prompt that was used. Only present when `return_prompt` in the request is set to true. - """ - message: AssistantMessageResponse usage: typing.Optional[Usage] = None logprobs: typing.Optional[typing.List[LogprobItem]] = None diff --git a/src/cohere/types/streamed_chat_response_v2.py b/src/cohere/v2/types/v2chat_stream_response.py similarity index 75% rename from src/cohere/types/streamed_chat_response_v2.py rename to src/cohere/v2/types/v2chat_stream_response.py index f5eb2f7be..8ec02897c 100644 --- a/src/cohere/types/streamed_chat_response_v2.py +++ b/src/cohere/v2/types/v2chat_stream_response.py @@ -1,24 +1,24 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel +from ...core.unchecked_base_model import UncheckedBaseModel import typing -from .chat_message_start_event_delta import ChatMessageStartEventDelta -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ...types.chat_message_start_event_delta import ChatMessageStartEventDelta +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import pydantic -from .chat_content_start_event_delta import ChatContentStartEventDelta -from .chat_content_delta_event_delta import ChatContentDeltaEventDelta -from .logprob_item import LogprobItem -from .chat_tool_plan_delta_event_delta import ChatToolPlanDeltaEventDelta -from .chat_tool_call_start_event_delta import ChatToolCallStartEventDelta -from .chat_tool_call_delta_event_delta import ChatToolCallDeltaEventDelta -from .citation_start_event_delta import CitationStartEventDelta -from .chat_message_end_event_delta import ChatMessageEndEventDelta +from ...types.chat_content_start_event_delta import ChatContentStartEventDelta +from ...types.chat_content_delta_event_delta import ChatContentDeltaEventDelta +from ...types.logprob_item import LogprobItem +from ...types.chat_tool_plan_delta_event_delta import ChatToolPlanDeltaEventDelta +from ...types.chat_tool_call_start_event_delta import ChatToolCallStartEventDelta +from ...types.chat_tool_call_delta_event_delta import ChatToolCallDeltaEventDelta +from ...types.citation_start_event_delta import CitationStartEventDelta +from ...types.chat_message_end_event_delta import ChatMessageEndEventDelta import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ...core.unchecked_base_model import UnionMetadata -class MessageStartStreamedChatResponseV2(UncheckedBaseModel): +class MessageStartV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -36,7 +36,7 @@ class Config: extra = pydantic.Extra.allow -class ContentStartStreamedChatResponseV2(UncheckedBaseModel): +class ContentStartV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -54,7 +54,7 @@ class Config: extra = pydantic.Extra.allow -class ContentDeltaStreamedChatResponseV2(UncheckedBaseModel): +class ContentDeltaV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -73,7 +73,7 @@ class Config: extra = pydantic.Extra.allow -class ContentEndStreamedChatResponseV2(UncheckedBaseModel): +class ContentEndV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -90,7 +90,7 @@ class Config: extra = pydantic.Extra.allow -class ToolPlanDeltaStreamedChatResponseV2(UncheckedBaseModel): +class ToolPlanDeltaV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -107,7 +107,7 @@ class Config: extra = pydantic.Extra.allow -class ToolCallStartStreamedChatResponseV2(UncheckedBaseModel): +class ToolCallStartV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -125,7 +125,7 @@ class Config: extra = pydantic.Extra.allow -class ToolCallDeltaStreamedChatResponseV2(UncheckedBaseModel): +class ToolCallDeltaV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -143,7 +143,7 @@ class Config: extra = pydantic.Extra.allow -class ToolCallEndStreamedChatResponseV2(UncheckedBaseModel): +class ToolCallEndV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -160,7 +160,7 @@ class Config: extra = pydantic.Extra.allow -class CitationStartStreamedChatResponseV2(UncheckedBaseModel): +class CitationStartV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -178,7 +178,7 @@ class Config: extra = pydantic.Extra.allow -class CitationEndStreamedChatResponseV2(UncheckedBaseModel): +class CitationEndV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -195,7 +195,7 @@ class Config: extra = pydantic.Extra.allow -class MessageEndStreamedChatResponseV2(UncheckedBaseModel): +class MessageEndV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -213,7 +213,7 @@ class Config: extra = pydantic.Extra.allow -class DebugStreamedChatResponseV2(UncheckedBaseModel): +class DebugV2ChatStreamResponse(UncheckedBaseModel): """ StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request). """ @@ -230,20 +230,20 @@ class Config: extra = pydantic.Extra.allow -StreamedChatResponseV2 = typing_extensions.Annotated[ +V2ChatStreamResponse = typing_extensions.Annotated[ typing.Union[ - MessageStartStreamedChatResponseV2, - ContentStartStreamedChatResponseV2, - ContentDeltaStreamedChatResponseV2, - ContentEndStreamedChatResponseV2, - ToolPlanDeltaStreamedChatResponseV2, - ToolCallStartStreamedChatResponseV2, - ToolCallDeltaStreamedChatResponseV2, - ToolCallEndStreamedChatResponseV2, - CitationStartStreamedChatResponseV2, - CitationEndStreamedChatResponseV2, - MessageEndStreamedChatResponseV2, - DebugStreamedChatResponseV2, + MessageStartV2ChatStreamResponse, + ContentStartV2ChatStreamResponse, + ContentDeltaV2ChatStreamResponse, + ContentEndV2ChatStreamResponse, + ToolPlanDeltaV2ChatStreamResponse, + ToolCallStartV2ChatStreamResponse, + ToolCallDeltaV2ChatStreamResponse, + ToolCallEndV2ChatStreamResponse, + CitationStartV2ChatStreamResponse, + CitationEndV2ChatStreamResponse, + MessageEndV2ChatStreamResponse, + DebugV2ChatStreamResponse, ], UnionMetadata(discriminant="type"), ] diff --git a/src/cohere/v2/types/v2rerank_response_results_item.py b/src/cohere/v2/types/v2rerank_response_results_item.py index adb0b3ceb..078c84fd6 100644 --- a/src/cohere/v2/types/v2rerank_response_results_item.py +++ b/src/cohere/v2/types/v2rerank_response_results_item.py @@ -1,18 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from ...core.unchecked_base_model import UncheckedBaseModel -import typing -from .v2rerank_response_results_item_document import V2RerankResponseResultsItemDocument import pydantic from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing class V2RerankResponseResultsItem(UncheckedBaseModel): - document: typing.Optional[V2RerankResponseResultsItemDocument] = pydantic.Field(default=None) - """ - If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in - """ - index: int = pydantic.Field() """ Corresponds to the index in the original list of documents to which the ranked document belongs. (i.e. if the first value in the `results` object has an `index` value of 3, it means in the list of documents passed in, the document at `index=3` had the highest relevance) diff --git a/src/cohere/v2/types/v2rerank_response_results_item_document.py b/src/cohere/v2/types/v2rerank_response_results_item_document.py deleted file mode 100644 index e139e593b..000000000 --- a/src/cohere/v2/types/v2rerank_response_results_item_document.py +++ /dev/null @@ -1,25 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ...core.unchecked_base_model import UncheckedBaseModel -import pydantic -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing - - -class V2RerankResponseResultsItemDocument(UncheckedBaseModel): - """ - If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in - """ - - text: str = pydantic.Field() - """ - The text of the document to rerank - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 - else: - - class Config: - smart_union = True - extra = pydantic.Extra.allow