@ai-sdk/cohere 3.0.74 → 3.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/index.js +236 -174
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +242 -175
- package/dist/index.mjs.map +1 -1
- package/docs/25-cohere.mdx +69 -0
- package/package.json +2 -2
- package/src/cohere-chat-language-model.ts +67 -45
- package/src/cohere-citations.ts +77 -0
- package/src/convert-cohere-usage.ts +8 -6
- package/src/convert-to-cohere-chat-prompt.ts +20 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @ai-sdk/cohere
|
|
2
2
|
|
|
3
|
+
## 3.0.76
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 225154e: fix(cohere): tolerate partial citations and usage in non-streaming responses
|
|
8
|
+
|
|
9
|
+
Cohere citations and usage fields are optional in the API specification, but the
|
|
10
|
+
response schema required `start`, `end`, `text`, every source `document` with
|
|
11
|
+
`text` and `title`, and usage token counts. Responses with untitled documents
|
|
12
|
+
(documents passed without a filename), with tool-sourced citations, or without
|
|
13
|
+
token counts failed with an `AI_TypeValidationError` and discarded the whole
|
|
14
|
+
response.
|
|
15
|
+
|
|
16
|
+
These fields are now validated loosely: citation fields and source `type`/`id`
|
|
17
|
+
are nullish, `document` is a loose object with optional `id`/`text`/`title`, tool
|
|
18
|
+
sources are accepted, and `usage` plus its token counts are nullish. Document
|
|
19
|
+
citations without a title fall back to `"Document"`. Tool-only citations are
|
|
20
|
+
skipped because they have no document to point at; their data stays in the
|
|
21
|
+
response body.
|
|
22
|
+
|
|
23
|
+
`convertCohereUsage` no longer falls back to `billed_units`, which are a
|
|
24
|
+
different measure than `tokens` (e.g. 12 billed vs 507 input tokens in a single
|
|
25
|
+
response) and would go negative when cached tokens are subtracted. A response
|
|
26
|
+
without `tokens` now reports undefined token counts instead of unrelated
|
|
27
|
+
numbers. This usage conversion is shared with streaming.
|
|
28
|
+
|
|
29
|
+
- 024df7d: fix(cohere): read the response id from v2 chat responses
|
|
30
|
+
|
|
31
|
+
The non-streaming response schema read `generation_id`, which Cohere's v2 chat
|
|
32
|
+
response does not return. As a result, `generateText().response.id` was a locally
|
|
33
|
+
generated fallback instead of the provider's id, while `streamText` returned the
|
|
34
|
+
id from the `message-start` event. `doGenerate` now reads `id` and keeps
|
|
35
|
+
`generation_id` (the v1 field) only for compatibility with proxies and mocks that
|
|
36
|
+
still return it.
|
|
37
|
+
|
|
38
|
+
- 225154e: fix(cohere): emit `source` stream parts for citations
|
|
39
|
+
|
|
40
|
+
`streamText` did not produce sources for Cohere RAG responses because `citation-start` stream events were ignored, while `generateText` mapped `message.citations` to document sources. Streaming now maps each cited document to the same `source` part as the non-streaming path. Citations that only reference tool output are not emitted as sources, and `citation-start` events without citations are ignored.
|
|
41
|
+
|
|
42
|
+
## 3.0.75
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- d900e58: fix(cohere): preserve string tool call arguments and safely serialize BigInt and circular structures in tool calls and outputs
|
|
47
|
+
- Updated dependencies [d900e58]
|
|
48
|
+
- Updated dependencies [d900e58]
|
|
49
|
+
- Updated dependencies [d900e58]
|
|
50
|
+
- @ai-sdk/provider-utils@4.0.64
|
|
51
|
+
|
|
3
52
|
## 3.0.74
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|