Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d23c909
1
lgrammel Dec 8, 2025
b32b10f
p 1
lgrammel Dec 8, 2025
14d261c
p xai
lgrammel Dec 8, 2025
443a21b
Merge branch 'main' into lg/XY180bQG
lgrammel Dec 8, 2025
4b4426a
p groq
lgrammel Dec 8, 2025
8e37d57
p deepseek
lgrammel Dec 8, 2025
297829f
p perplexity
lgrammel Dec 8, 2025
a39b0aa
f usage
lgrammel Dec 8, 2025
3243d21
x test
lgrammel Dec 8, 2025
80a8fd4
x core
lgrammel Dec 8, 2025
9c1b782
x core
lgrammel Dec 8, 2025
cdd4289
f core
lgrammel Dec 8, 2025
000a746
google usage
aayush-kapoor Dec 8, 2025
8f809ad
pretty
aayush-kapoor Dec 8, 2025
e18e23e
anthropic usage
aayush-kapoor Dec 8, 2025
1227c0e
U - openai chat usage
aayush-kapoor Dec 8, 2025
a1f9ae7
U - openai completion usage
aayush-kapoor Dec 8, 2025
a6eeae0
U - openai responses usage
aayush-kapoor Dec 8, 2025
ac0d948
rsc fix
aayush-kapoor Dec 8, 2025
418b82e
bedrock usage
aayush-kapoor Dec 8, 2025
44a0b6c
cohere usage
aayush-kapoor Dec 8, 2025
09e3685
huggingface usage
aayush-kapoor Dec 8, 2025
d161754
mistral usage
aayush-kapoor Dec 8, 2025
9efd807
type check fixes
aayush-kapoor Dec 8, 2025
f992820
tc fixes
aayush-kapoor Dec 8, 2025
9285d32
updated tests and snapshots
aayush-kapoor Dec 8, 2025
8d42543
revert rsc fix
aayush-kapoor Dec 8, 2025
c55001a
doGenerate transform added
aayush-kapoor Dec 8, 2025
5128e47
fix for type-check error in rsc
aayush-kapoor Dec 8, 2025
43c0a46
Merge branch 'main' into lg/XY180bQG
aayush-kapoor Dec 8, 2025
e20f636
cs
lgrammel Dec 9, 2025
0e5b13f
push
lgrammel Dec 9, 2025
07eee4f
d migration guide
lgrammel Dec 9, 2025
084f816
rm redundant data
lgrammel Dec 9, 2025
b0c6068
d
lgrammel Dec 9, 2025
b938982
p
lgrammel Dec 9, 2025
b4fad60
e
lgrammel Dec 9, 2025
3f89b15
t
lgrammel Dec 9, 2025
ded158e
strea
lgrammel Dec 9, 2025
905500a
c
lgrammel Dec 9, 2025
b84b64e
x
lgrammel Dec 9, 2025
dfe4aa9
i
lgrammel Dec 9, 2025
8429372
d
lgrammel Dec 9, 2025
38c6ad5
Merge branch 'main' into lg/XY180bQG
lgrammel Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions examples/ai-core/src/benchmark/stream-text-benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ const generateLongContent = (tokens: number, includeTools = false) => {
type: 'finish',
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: tokens,
totalTokens: tokens + 10,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: tokens,
text: tokens,
reasoning: undefined,
},
},
});

Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-object/mock-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ async function main() {
},
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
}),
}),
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-object/mock-repair-add-close.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ async function main() {
model: new MockLanguageModelV3({
doGenerate: async () => ({
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
warnings: [],
finishReason: 'tool-calls',
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-object/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ async function main() {
content: [{ type: 'text', text: `{"content":"Hello, world!"}` }],
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
warnings: [],
}),
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-text/mock-invalid-tool-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ async function main() {
doGenerate: async () => ({
warnings: [],
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
finishReason: 'tool-calls',
content: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ async function main() {
doGenerate: async () => ({
warnings: [],
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
finishReason: 'tool-calls',
content: [
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-text/mock-tool-call-repair-reask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ async function main() {
doGenerate: async () => ({
warnings: [],
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
finishReason: 'tool-calls',
content: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ async function main() {
doGenerate: async () => ({
warnings: [],
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
finishReason: 'tool-calls',
content: [
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/generate-text/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ async function main() {
content: [{ type: 'text', text: `Hello, world!` }],
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
warnings: [],
}),
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/stream-object/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ async function main() {
finishReason: 'stop',
logprobs: undefined,
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
},
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ async function main() {
finishReason: 'tool-calls',
logprobs: undefined,
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
},
]),
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/stream-text/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ async function main() {
finishReason: 'stop',
logprobs: undefined,
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
},
]),
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/stream-text/smooth-stream-chinese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ async function main() {
finishReason: 'stop',
logprobs: undefined,
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
},
],
Expand Down
14 changes: 11 additions & 3 deletions examples/ai-core/src/stream-text/smooth-stream-japanese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ async function main() {
finishReason: 'stop',
logprobs: undefined,
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
},
],
Expand Down
14 changes: 11 additions & 3 deletions examples/next-openai/app/api/test-invalid-tool-call/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,17 @@ export async function POST(req: Request) {
type: 'finish',
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: 20,
totalTokens: 30,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 20,
text: 20,
reasoning: undefined,
},
},
},
]),
Expand Down
1 change: 1 addition & 0 deletions packages/ai/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { prepareToolsAndToolChoice } from '../src/prompt/prepare-tools-and-tool-
export { standardizePrompt } from '../src/prompt/standardize-prompt';
export { prepareCallSettings } from '../src/prompt/prepare-call-settings';
export { prepareRetries } from '../src/util/prepare-retries';
export { asLanguageModelUsage } from '../src/types/usage';
14 changes: 11 additions & 3 deletions packages/ai/src/agent/create-agent-ui-stream-response.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ describe('createAgentUIStreamResponse', () => {
type: 'finish',
finishReason: 'stop',
usage: {
inputTokens: 10,
outputTokens: 10,
totalTokens: 20,
inputTokens: {
total: 10,
noCache: 10,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
providerMetadata: {
testProvider: { testKey: 'testValue' },
Expand Down
31 changes: 22 additions & 9 deletions packages/ai/src/agent/tool-loop-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ describe('ToolLoopAgent', () => {
finishReason: 'stop',
usage: {
cachedInputTokens: undefined,
inputTokens: 3,
outputTokens: 10,
reasoningTokens: undefined,
totalTokens: 13,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
warnings: [],
};
Expand Down Expand Up @@ -261,11 +268,17 @@ describe('ToolLoopAgent', () => {
type: 'finish',
finishReason: 'stop',
usage: {
inputTokens: 3,
outputTokens: 10,
totalTokens: 13,
reasoningTokens: undefined,
cachedInputTokens: undefined,
inputTokens: {
total: 3,
noCache: 3,
cacheRead: undefined,
cacheWrite: undefined,
},
outputTokens: {
total: 10,
text: 10,
reasoning: undefined,
},
},
providerMetadata: {
testProvider: { testKey: 'testValue' },
Expand Down
Loading
Loading