Skip to content

Commit f700e94

Browse files
committed
[fern-generated] SDK regeneration
1 parent 050f9c0 commit f700e94

32 files changed

Lines changed: 1887 additions & 342 deletions

.fern/metadata.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@
100100
}
101101
]
102102
},
103-
"originGitCommit": "3f4bc18b3d90a318965a1fc2f5980339c012a6e2",
104-
"originGitCommitIsDirty": true,
103+
"originGitCommit": "5c526877987b8b4e11151461d0c251002eb24341",
104+
"originGitCommitIsDirty": false,
105105
"invokedBy": "ci",
106-
"requestedVersion": "7.0.8",
106+
"requestedVersion": "7.1.0",
107107
"ciProvider": "github",
108-
"sdkVersion": "7.0.8"
108+
"sdkVersion": "7.1.0"
109109
}

poetry.lock

Lines changed: 409 additions & 332 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "cohere"
7-
version = "7.0.8"
7+
version = "7.1.0"
88
description = ""
99
readme = "README.md"
1010
authors = []

reference.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,107 @@ If tool_choice isn't specified, then the model is free to choose whether to use
28762876
</dl>
28772877

28782878

2879+
</dd>
2880+
</dl>
2881+
</details>
2882+
2883+
<details><summary><code>client.v2.<a href="src/cohere/v2/client.py">parse</a>(...) -> ParseResponse</code></summary>
2884+
<dl>
2885+
<dd>
2886+
2887+
#### 📝 Description
2888+
2889+
<dl>
2890+
<dd>
2891+
2892+
<dl>
2893+
<dd>
2894+
2895+
Parse a document image into structured output. Use `output_format` to select
2896+
blocks or markdown (default).
2897+
2898+
Currently supports `document.type = image_url` only (data URI or remote http(s)
2899+
image URL). PDF / file URL inputs are not yet supported.
2900+
2901+
Image limits: 20 MB file size; 50 megapixels or 200 MB decoded (whichever is
2902+
exceeded first).
2903+
</dd>
2904+
</dl>
2905+
</dd>
2906+
</dl>
2907+
2908+
#### 🔌 Usage
2909+
2910+
<dl>
2911+
<dd>
2912+
2913+
<dl>
2914+
<dd>
2915+
2916+
```python
2917+
from cohere import Client, ParseDocument
2918+
from cohere.environment import ClientEnvironment
2919+
2920+
client = Client(
2921+
token="<token>",
2922+
environment=ClientEnvironment.PRODUCTION,
2923+
)
2924+
2925+
client.v2.parse(
2926+
model="parse-v5.0",
2927+
document=ParseDocument(
2928+
type="image_url",
2929+
image_url="https://cohere.com/favicon-32x32.png",
2930+
),
2931+
output_format="markdown",
2932+
)
2933+
2934+
```
2935+
</dd>
2936+
</dl>
2937+
</dd>
2938+
</dl>
2939+
2940+
#### ⚙️ Parameters
2941+
2942+
<dl>
2943+
<dd>
2944+
2945+
<dl>
2946+
<dd>
2947+
2948+
**model:** `str` — The name of a compatible Cohere parse model.
2949+
2950+
</dd>
2951+
</dl>
2952+
2953+
<dl>
2954+
<dd>
2955+
2956+
**document:** `ParseDocument`
2957+
2958+
</dd>
2959+
</dl>
2960+
2961+
<dl>
2962+
<dd>
2963+
2964+
**output_format:** `typing.Optional[ParseOutputFormat]`
2965+
2966+
</dd>
2967+
</dl>
2968+
2969+
<dl>
2970+
<dd>
2971+
2972+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
2973+
2974+
</dd>
2975+
</dl>
2976+
</dd>
2977+
</dl>
2978+
2979+
28792980
</dd>
28802981
</dl>
28812982
</details>

src/cohere/__init__.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
AssistantMessageV2Content,
1919
AssistantMessageV2ContentOneItem,
2020
AuthTokenType,
21+
BlocksParsePage,
2122
ChatCitation,
2223
ChatCitationGenerationEvent,
2324
ChatCitationType,
@@ -156,6 +157,7 @@
156157
GetModelResponseSamplingDefaults,
157158
Image,
158159
ImageContent,
160+
ImageParseBlock,
159161
ImageUrl,
160162
ImageUrlContent,
161163
ImageUrlDetail,
@@ -169,11 +171,30 @@
169171
ListEmbedJobResponse,
170172
ListModelsResponse,
171173
LogprobItem,
174+
MarkdownParsePage,
172175
Message,
173176
Metrics,
174177
NonStreamedChatResponse,
175178
OAuthAuthorizeResponse,
179+
ParseBlock,
180+
ParseBlocksPageVariant,
181+
ParseBoundingBox,
182+
ParseBoundingBoxNormalized,
183+
ParseDocument,
184+
ParseImageBlock,
185+
ParseImageCategory,
186+
ParseImageContentBlock,
176187
ParseInfo,
188+
ParseMarkdownPage,
189+
ParseMarkdownPageVariant,
190+
ParseOutputFormat,
191+
ParsePage,
192+
ParseResponse,
193+
ParseTableBlock,
194+
ParseTableContentBlock,
195+
ParseTableContentType,
196+
ParseTextBlock,
197+
ParseTextContentBlock,
177198
RerankDocument,
178199
RerankRequestDocumentsItem,
179200
RerankResponse,
@@ -202,12 +223,14 @@
202223
SystemMessageV2,
203224
SystemMessageV2Content,
204225
SystemMessageV2ContentOneItem,
226+
TableParseBlock,
205227
TextAssistantMessageResponseContentItem,
206228
TextAssistantMessageV2ContentOneItem,
207229
TextContent,
208230
TextEmbedContent,
209231
TextGenerationGenerateStreamedResponse,
210232
TextGenerationStreamedChatResponse,
233+
TextParseBlock,
211234
TextResponseFormat,
212235
TextResponseFormatV2,
213236
TextSystemMessageV2ContentOneItem,
@@ -334,6 +357,7 @@
334357
"BatchStatus": ".batches",
335358
"BedrockClient": ".bedrock_client",
336359
"BedrockClientV2": ".bedrock_client",
360+
"BlocksParsePage": ".types",
337361
"CancelBatchResponse": ".batches",
338362
"ChatCitation": ".types",
339363
"ChatCitationGenerationEvent": ".types",
@@ -498,6 +522,7 @@
498522
"GetModelResponseSamplingDefaults": ".types",
499523
"Image": ".types",
500524
"ImageContent": ".types",
525+
"ImageParseBlock": ".types",
501526
"ImageUrl": ".types",
502527
"ImageUrlContent": ".types",
503528
"ImageUrlDetail": ".types",
@@ -514,6 +539,7 @@
514539
"ListEmbedJobResponse": ".types",
515540
"ListModelsResponse": ".types",
516541
"LogprobItem": ".types",
542+
"MarkdownParsePage": ".types",
517543
"Message": ".types",
518544
"MessageEndStreamedChatResponseV2": ".aliases",
519545
"MessageEndV2ChatStreamResponse": ".v2",
@@ -526,7 +552,25 @@
526552
"OAuthAuthorizeResponse": ".types",
527553
"OciClient": ".oci_client",
528554
"OciClientV2": ".oci_client",
555+
"ParseBlock": ".types",
556+
"ParseBlocksPageVariant": ".types",
557+
"ParseBoundingBox": ".types",
558+
"ParseBoundingBoxNormalized": ".types",
559+
"ParseDocument": ".types",
560+
"ParseImageBlock": ".types",
561+
"ParseImageCategory": ".types",
562+
"ParseImageContentBlock": ".types",
529563
"ParseInfo": ".types",
564+
"ParseMarkdownPage": ".types",
565+
"ParseMarkdownPageVariant": ".types",
566+
"ParseOutputFormat": ".types",
567+
"ParsePage": ".types",
568+
"ParseResponse": ".types",
569+
"ParseTableBlock": ".types",
570+
"ParseTableContentBlock": ".types",
571+
"ParseTableContentType": ".types",
572+
"ParseTextBlock": ".types",
573+
"ParseTextContentBlock": ".types",
530574
"RerankDocument": ".types",
531575
"RerankRequestDocumentsItem": ".types",
532576
"RerankResponse": ".types",
@@ -559,12 +603,14 @@
559603
"SystemMessageV2": ".types",
560604
"SystemMessageV2Content": ".types",
561605
"SystemMessageV2ContentOneItem": ".types",
606+
"TableParseBlock": ".types",
562607
"TextAssistantMessageResponseContentItem": ".types",
563608
"TextAssistantMessageV2ContentOneItem": ".types",
564609
"TextContent": ".types",
565610
"TextEmbedContent": ".types",
566611
"TextGenerationGenerateStreamedResponse": ".types",
567612
"TextGenerationStreamedChatResponse": ".types",
613+
"TextParseBlock": ".types",
568614
"TextResponseFormat": ".types",
569615
"TextResponseFormatV2": ".types",
570616
"TextSystemMessageV2ContentOneItem": ".types",
@@ -673,6 +719,7 @@ def __dir__():
673719
"BatchStatus",
674720
"BedrockClient",
675721
"BedrockClientV2",
722+
"BlocksParsePage",
676723
"CancelBatchResponse",
677724
"ChatCitation",
678725
"ChatCitationGenerationEvent",
@@ -837,6 +884,7 @@ def __dir__():
837884
"GetModelResponseSamplingDefaults",
838885
"Image",
839886
"ImageContent",
887+
"ImageParseBlock",
840888
"ImageUrl",
841889
"ImageUrlContent",
842890
"ImageUrlDetail",
@@ -853,6 +901,7 @@ def __dir__():
853901
"ListEmbedJobResponse",
854902
"ListModelsResponse",
855903
"LogprobItem",
904+
"MarkdownParsePage",
856905
"Message",
857906
"MessageEndStreamedChatResponseV2",
858907
"MessageEndV2ChatStreamResponse",
@@ -865,7 +914,25 @@ def __dir__():
865914
"OAuthAuthorizeResponse",
866915
"OciClient",
867916
"OciClientV2",
917+
"ParseBlock",
918+
"ParseBlocksPageVariant",
919+
"ParseBoundingBox",
920+
"ParseBoundingBoxNormalized",
921+
"ParseDocument",
922+
"ParseImageBlock",
923+
"ParseImageCategory",
924+
"ParseImageContentBlock",
868925
"ParseInfo",
926+
"ParseMarkdownPage",
927+
"ParseMarkdownPageVariant",
928+
"ParseOutputFormat",
929+
"ParsePage",
930+
"ParseResponse",
931+
"ParseTableBlock",
932+
"ParseTableContentBlock",
933+
"ParseTableContentType",
934+
"ParseTextBlock",
935+
"ParseTextContentBlock",
869936
"RerankDocument",
870937
"RerankRequestDocumentsItem",
871938
"RerankResponse",
@@ -898,12 +965,14 @@ def __dir__():
898965
"SystemMessageV2",
899966
"SystemMessageV2Content",
900967
"SystemMessageV2ContentOneItem",
968+
"TableParseBlock",
901969
"TextAssistantMessageResponseContentItem",
902970
"TextAssistantMessageV2ContentOneItem",
903971
"TextContent",
904972
"TextEmbedContent",
905973
"TextGenerationGenerateStreamedResponse",
906974
"TextGenerationStreamedChatResponse",
975+
"TextParseBlock",
907976
"TextResponseFormat",
908977
"TextResponseFormatV2",
909978
"TextSystemMessageV2ContentOneItem",

src/cohere/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def get_headers(self) -> typing.Dict[str, str]:
3535
import platform
3636

3737
headers: typing.Dict[str, str] = {
38-
"User-Agent": "cohere/7.0.8",
38+
"User-Agent": "cohere/7.1.0",
3939
"X-Fern-Language": "Python",
4040
"X-Fern-Runtime": f"python/{platform.python_version()}",
4141
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
4242
"X-Fern-SDK-Name": "cohere",
43-
"X-Fern-SDK-Version": "7.0.8",
43+
"X-Fern-SDK-Version": "7.1.0",
4444
**(self.get_custom_headers() or {}),
4545
}
4646
if self._client_name is not None:

src/cohere/overrides.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,50 @@ def patched_init(self, /, **data):
5959
return cls
6060

6161

62+
def omit_authorization_header_when_api_key_is_empty() -> None:
63+
"""
64+
Do not send an `Authorization` header when the client is created with an empty API key.
65+
66+
This allows pointing the client at a proxy or a self-hosted deployment that performs its own
67+
authentication, e.g. `cohere.Client(api_key="")`.
68+
"""
69+
from .core.client_wrapper import AsyncClientWrapper, BaseClientWrapper
70+
71+
if getattr(BaseClientWrapper, "_omits_empty_authorization", False):
72+
return
73+
74+
get_headers = BaseClientWrapper.get_headers
75+
async_get_headers = AsyncClientWrapper.async_get_headers
76+
77+
def patched_get_headers(self: BaseClientWrapper) -> typing.Dict[str, str]:
78+
headers = get_headers(self)
79+
# Inspect the header that get_headers() already built rather than calling _get_token()
80+
# again: for the callable `api_key` form that would invoke the supplier twice per request,
81+
# and a supplier whose value changes between the two calls would produce the wrong header.
82+
if headers.get("Authorization") == "Bearer ":
83+
headers.pop("Authorization", None)
84+
return headers
85+
86+
async def patched_async_get_headers(self: AsyncClientWrapper) -> typing.Dict[str, str]:
87+
headers = await async_get_headers(self)
88+
if headers.get("Authorization") == "Bearer ":
89+
headers.pop("Authorization", None)
90+
return headers
91+
92+
BaseClientWrapper.get_headers = patched_get_headers # type: ignore[method-assign]
93+
AsyncClientWrapper.async_get_headers = patched_async_get_headers # type: ignore[method-assign]
94+
BaseClientWrapper._omits_empty_authorization = True # type: ignore[attr-defined]
95+
96+
6297
def run_overrides():
6398
"""
6499
These are overrides to allow us to make changes to generated code without touching the generated files themselves.
65100
Should be used judiciously!
66101
"""
67102

103+
# Override to skip the Authorization header entirely when an empty api_key is passed
104+
omit_authorization_header_when_api_key_is_empty()
105+
68106
# Override to allow access to aliases in EmbedByTypeResponseEmbeddings eg embeddings.float rather than embeddings.float_
69107
setattr(EmbedByTypeResponseEmbeddings, "__getattr__", allow_access_to_aliases)
70108

0 commit comments

Comments
 (0)