Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/ai
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ai@3.0.9
Choose a base ref
...
head repository: vercel/ai
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ai@3.0.10
Choose a head ref
  • 2 commits
  • 23 files changed
  • 3 contributors

Commits on Mar 13, 2024

  1. Fix .append() behavior (#1139)

    shuding authored Mar 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    33d261a View commit details
  2. Version Packages (#1145)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Mar 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    397a89b View commit details
2 changes: 1 addition & 1 deletion examples/next-anthropic/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
},
"dependencies": {
"@anthropic-ai/sdk": "0.15.0",
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"react": "18.2.0",
"react-dom": "^18.2.0"
2 changes: 1 addition & 1 deletion examples/next-aws-bedrock/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "3.451.0",
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"react": "18.2.0",
"react-dom": "^18.2.0"
2 changes: 1 addition & 1 deletion examples/next-fireworks/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"openai": "4.16.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-google-generative-ai/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
},
"dependencies": {
"@google/generative-ai": "0.1.1",
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"react": "18.2.0",
"react-dom": "^18.2.0"
2 changes: 1 addition & 1 deletion examples/next-huggingface/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"dependencies": {
"@huggingface/inference": "^2.5.1",
"next": "14.1.1",
"ai": "3.0.9",
"ai": "3.0.10",
"react": "18.2.0",
"react-dom": "^18.2.0"
},
2 changes: 1 addition & 1 deletion examples/next-inkeep/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
},
"dependencies": {
"@inkeep/ai-api": "^0.1.8",
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"react": "18.2.0",
"react-dom": "^18.2.0"
2 changes: 1 addition & 1 deletion examples/next-langchain/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"langchain": "^0.0.196",
"next": "14.1.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-mistral/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"@mistralai/mistralai": "0.1.3",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-openai-pages/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"openai": "4.16.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-openai-rate-limits/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"dependencies": {
"@upstash/ratelimit": "^0.4.3",
"@vercel/kv": "^0.2.2",
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"openai": "4.16.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-openai/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"openai": "4.16.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/next-perplexity/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"ai": "3.0.9",
"ai": "3.0.10",
"next": "14.1.1",
"openai": "4.16.1",
"react": "18.2.0",
2 changes: 1 addition & 1 deletion examples/nuxt-openai/package.json
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
"@vue/runtime-core": "^3.3.4",
"@vue/runtime-dom": "^3.3.4",
"@vue/shared": "^3.3.4",
"ai": "3.0.9",
"ai": "3.0.10",
"nuxt": "^3.6.5",
"openai": "4.16.1",
"tailwindcss": "^3.3.3",
2 changes: 1 addition & 1 deletion examples/solidstart-openai/package.json
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
"dependencies": {
"@solidjs/meta": "0.29.3",
"@solidjs/router": "0.8.2",
"ai": "3.0.9",
"ai": "3.0.10",
"openai": "4.16.1",
"solid-js": "1.8.7",
"solid-start": "0.3.10",
2 changes: 1 addition & 1 deletion examples/sveltekit-openai/package.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
},
"dependencies": {
"openai": "4.16.1",
"ai": "3.0.9"
"ai": "3.0.10"
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ai

## 3.0.10

### Patch Changes

- 33d261a: fix(ai/rsc): Fix .append() behavior

## 3.0.9

### Patch Changes
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ai",
"version": "3.0.9",
"version": "3.0.10",
"license": "Apache-2.0",
"sideEffects": false,
"main": "./dist/index.js",
@@ -111,6 +111,7 @@
"msw": "2.0.9",
"openai": "4.28.4",
"react-dom": "^18.2.0",
"react-server-dom-webpack": "18.3.0-canary-eb33bd747-20240312",
"solid-js": "^1.8.7",
"tsup": "^7.2.0",
"typescript": "5.1.3",
18 changes: 9 additions & 9 deletions packages/core/rsc/__snapshots__/streamable.ui.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ exports[`rsc - render() > should emit React Nodes with async render function 1`]
"children": {
"children": {},
"props": {
"current": undefined,
"next": {
"c": undefined,
"n": {
"done": false,
"next": {
"done": true,
@@ -19,7 +19,7 @@ exports[`rsc - render() > should emit React Nodes with async render function 1`]
</div>,
},
},
"type": "Row",
"type": "",
},
"props": {
"fallback": undefined,
@@ -33,8 +33,8 @@ exports[`rsc - render() > should emit React Nodes with generator render function
"children": {
"children": {},
"props": {
"current": undefined,
"next": {
"c": undefined,
"n": {
"done": false,
"next": {
"done": false,
@@ -53,7 +53,7 @@ exports[`rsc - render() > should emit React Nodes with generator render function
</div>,
},
},
"type": "Row",
"type": "",
},
"props": {
"fallback": undefined,
@@ -67,8 +67,8 @@ exports[`rsc - render() > should emit React Nodes with sync render function 1`]
"children": {
"children": {},
"props": {
"current": undefined,
"next": {
"c": undefined,
"n": {
"done": false,
"next": {
"done": true,
@@ -81,7 +81,7 @@ exports[`rsc - render() > should emit React Nodes with sync render function 1`]
</div>,
},
},
"type": "Row",
"type": "",
},
"props": {
"fallback": undefined,
2 changes: 1 addition & 1 deletion packages/core/rsc/shared-client/streamable.tsx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ function assertStreamableValue(
value.type !== STREAMABLE_VALUE_TYPE
) {
throw new Error(
'Invalid value: this hook only accepts values created via `createValueStream` from the server.',
'Invalid value: this hook only accepts values created via `createStreamableValue` from the server.',
);
}
}
31 changes: 18 additions & 13 deletions packages/core/rsc/streamable.tsx
Original file line number Diff line number Diff line change
@@ -65,18 +65,9 @@ export function createStreamableUI(initialValue?: React.ReactNode) {
assertStream('.append()');

const resolvable = createResolvablePromise();
if (typeof currentValue === 'string' && typeof value === 'string') {
currentValue += value;
} else {
currentValue = (
<>
{currentValue}
{value}
</>
);
}
currentValue = value;

resolve({ value: currentValue, done: false, next: resolvable.promise });
resolve({ value, done: false, append: true, next: resolvable.promise });
resolve = resolvable.resolve;
reject = resolvable.reject;

@@ -242,7 +233,21 @@ export function render<
messages: Parameters<
typeof OpenAI.prototype.chat.completions.create
>[0]['messages'];
text?: Renderer<{ content: string; done: boolean }>;
text?: Renderer<{
/**
* The full text content from the model so far.
*/
content: string;
/**
* The new appended text content from the model since the last `text` call.
*/
delta: string;
/**
* Whether the model is done generating text.
* If `true`, the `content` will be the final output and this call will be the last.
*/
done: boolean;
}>;
tools?: {
[name in keyof TS]: {
description?: string;
@@ -415,7 +420,7 @@ export function render<
: {}),
onText(chunk) {
content += chunk;
handleRender({ content, done: false }, text, ui);
handleRender({ content, done: false, delta: chunk }, text, ui);
},
async onFinal() {
if (hasFunction) {
Loading