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.2.10
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.2.11
Choose a head ref
  • 8 commits
  • 54 files changed
  • 8 contributors

Commits on Jun 26, 2024

  1. chore (@ai-sdk/anthropic): remove anthropic-beta header (#2107)

    lgrammel authored Jun 26, 2024
    Copy the full SHA
    91dc429 View commit details
  2. docs: fix quickstart form handler (#2109)

    nicoalbanese authored Jun 26, 2024
    Copy the full SHA
    ee0b9d9 View commit details
  3. docs: fix wrong link (#2111)

    nicoalbanese authored Jun 26, 2024
    Copy the full SHA
    354ceb8 View commit details
  4. feat (ai/ui): improve error handling in useAssistant (#2112)

    Co-authored-by: Samuel <samuelint@gmail.com>
    lgrammel and samuelint authored Jun 26, 2024
    Copy the full SHA
    827ef45 View commit details
  5. fix (docs): remove duplicate code in useAssistant example (#2114)

    PawelKonie99 authored Jun 26, 2024
    Copy the full SHA
    ef7bc10 View commit details
  6. chore (ui/solid): update solidjs useChat and useCompletion to feature…

    … parity with React (#2095)
    
    Co-authored-by: Ian Pascoe <ian.g.pascoe@gmail.com>
    Co-authored-by: Ian Pascoe <122142608+spiritledsoftware@users.noreply.github.com>
    3 people authored Jun 26, 2024
    Copy the full SHA
    c908f74 View commit details
  7. fix (examples): add version back to solidstart package.json

    lgrammel committed Jun 26, 2024
    Copy the full SHA
    c258c24 View commit details
  8. Version Packages (#2108)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Jun 26, 2024
    Copy the full SHA
    bd0226f View commit details
Showing with 3,103 additions and 2,441 deletions.
  1. +4 −2 content/docs/02-getting-started/02-nextjs-app-router.mdx
  2. +1 −1 content/docs/04-ai-sdk-rsc/05-streaming-values.mdx
  3. +1 −1 content/docs/05-ai-sdk-ui/01-overview.mdx
  4. +1 −1 content/docs/05-ai-sdk-ui/03-chatbot-with-tool-calling.mdx
  5. +2 −2 content/docs/07-reference/ai-sdk-ui/01-use-chat.mdx
  6. +1 −1 content/docs/07-reference/ai-sdk-ui/index.mdx
  7. +0 −12 content/examples/01-next-app/06-assistants/02-stream-assistant-responses-with-tools.mdx
  8. +5 −4 examples/solidstart-openai/.gitignore
  9. +3 −0 examples/solidstart-openai/app.config.ts
  10. +14 −17 examples/solidstart-openai/package.json
  11. +2 −2 examples/solidstart-openai/postcss.config.cjs
  12. +1 −1 examples/solidstart-openai/src/{root.css → app.css}
  13. +19 −0 examples/solidstart-openai/src/app.tsx
  14. +3 −2 examples/solidstart-openai/src/entry-client.tsx
  15. +20 −8 examples/solidstart-openai/src/entry-server.tsx
  16. +1 −0 examples/solidstart-openai/src/global.d.ts
  17. +0 −36 examples/solidstart-openai/src/root.tsx
  18. +0 −92 examples/solidstart-openai/src/routes/api/chat-with-functions/index.ts
  19. +0 −43 examples/solidstart-openai/src/routes/api/chat-with-vision/index.ts
  20. +8 −13 examples/solidstart-openai/src/routes/api/chat/index.ts
  21. +14 −22 examples/solidstart-openai/src/routes/api/completion/index.ts
  22. +41 −0 examples/solidstart-openai/src/routes/api/use-chat-tools/index.ts
  23. +31 −0 examples/solidstart-openai/src/routes/api/use-chat-vision/index.ts
  24. +0 −90 examples/solidstart-openai/src/routes/function-calling/index.tsx
  25. +2 −9 examples/solidstart-openai/src/routes/index.tsx
  26. +117 −0 examples/solidstart-openai/src/routes/use-chat-tools/index.tsx
  27. +4 −11 examples/solidstart-openai/src/routes/{vision → use-chat-vision}/index.tsx
  28. +2 −2 examples/solidstart-openai/tailwind.config.cjs
  29. +8 −6 examples/solidstart-openai/tsconfig.json
  30. +0 −6 examples/solidstart-openai/vite.config.ts
  31. +6 −0 packages/anthropic/CHANGELOG.md
  32. +1 −1 packages/anthropic/package.json
  33. +0 −1 packages/anthropic/src/anthropic-provider.ts
  34. +12 −0 packages/core/CHANGELOG.md
  35. +4 −4 packages/core/package.json
  36. +9 −3 packages/core/svelte/use-assistant.ts
  37. +8 −0 packages/core/tests/e2e/next-server/CHANGELOG.md
  38. +6 −0 packages/react/CHANGELOG.md
  39. +1 −1 packages/react/package.json
  40. +10 −4 packages/react/src/use-assistant.ts
  41. +14 −1 packages/react/src/use-assistant.ui.test.tsx
  42. +2 −2 packages/react/src/use-chat.ts
  43. +0 −4 packages/react/src/use-chat.ui.test.tsx
  44. +3 −0 packages/solid/.eslintrc.js
  45. +6 −0 packages/solid/CHANGELOG.md
  46. +2 −4 packages/solid/package.json
  47. +330 −139 packages/solid/src/use-chat.ts
  48. +252 −15 packages/solid/src/use-chat.ui.test.tsx
  49. +97 −59 packages/solid/src/use-completion.ts
  50. +6 −0 packages/svelte/CHANGELOG.md
  51. +1 −1 packages/svelte/package.json
  52. +9 −3 packages/svelte/src/use-assistant.ts
  53. +1 −1 packages/ui-utils/src/call-chat-api.ts
  54. +2,018 −1,814 pnpm-lock.yaml
6 changes: 4 additions & 2 deletions content/docs/02-getting-started/02-nextjs-app-router.mdx
Original file line number Diff line number Diff line change
@@ -333,7 +333,8 @@ export default function Chat() {
))}

<form
action={async () => {
onSubmit={async e => {
e.preventDefault();
const newMessages: CoreMessage[] = [
...messages,
{ content: input, role: 'user' },
@@ -433,7 +434,8 @@ export default function Chat() {
))}

<form
action={async () => {
onSubmit={async e => {
e.preventDefault();
const newMessages: CoreMessage[] = [
...messages,
{ content: input, role: 'user' },
2 changes: 1 addition & 1 deletion content/docs/04-ai-sdk-rsc/05-streaming-values.mdx
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ The RSC API provides several utility functions to allow you to stream values fro

There are two functions provided by the RSC API that allow you to create streamable values:

- [`createStreamableValue`](/docs/reference/ai-sdk-rsc/stream-ui) - creates a streamable (serializable) value, with full control over how you create, update, and close the stream.
- [`createStreamableValue`](/docs/reference/ai-sdk-rsc/create-streamable-value) - creates a streamable (serializable) value, with full control over how you create, update, and close the stream.
- [`createStreamableUI`](/docs/reference/ai-sdk-rsc/create-streamable-ui) - creates a streamable React component, with full control over how you create, update, and close the stream.

## `createStreamableValue`
2 changes: 1 addition & 1 deletion content/docs/05-ai-sdk-ui/01-overview.mdx
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ Here is a comparison of the supported functions across these frameworks:
| Function | React | Svelte | Vue.js | SolidJS |
| ---------------------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) tool calling | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) tool calling | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Check size={18} /> |
| [useCompletion](/docs/reference/ai-sdk-ui/use-completion) | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| [useObject](/docs/reference/ai-sdk-ui/use-object) | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| [useAssistant](/docs/reference/ai-sdk-ui/use-assistant) | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
2 changes: 1 addition & 1 deletion content/docs/05-ai-sdk-ui/03-chatbot-with-tool-calling.mdx
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ description: Learn how to use tools with the useChat hook.

<Note type="warning">
The tool calling functionality described here is currently only available for
**React**.
**React** and **SolidJS**.
</Note>

With `useChat` and `streamText`, you can use tools in your chatbot application.
4 changes: 2 additions & 2 deletions content/docs/07-reference/ai-sdk-ui/01-use-chat.mdx
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ Allows you to easily create a conversational user interface for your chatbot app
name: 'maxToolRoundtrips',
type: 'number',
description:
'React only. Maximal number of automatic roundtrips for tool calls. An automatic tool call roundtrip is a call to the server with the tool call results when all tool calls in the last assistant message have results. A maximum number is required to prevent infinite loops in the case of misconfigured tools. By default, it is set to 0, which will disable the feature.',
'React and SolidJS only. Maximal number of automatic roundtrips for tool calls. An automatic tool call roundtrip is a call to the server with the tool call results when all tool calls in the last assistant message have results. A maximum number is required to prevent infinite loops in the case of misconfigured tools. By default, it is set to 0, which will disable the feature.',
},
{
name: 'streamMode',
@@ -247,7 +247,7 @@ Allows you to easily create a conversational user interface for your chatbot app
name: 'addToolResult',
type: '({toolCallId: string; result: any;}) => void',
description:
'React only. Function to add a tool result to the chat. This will update the chat messages with the tool result and call the API route if all tool results for the last message are available.',
'React and SolidJS only. Function to add a tool result to the chat. This will update the chat messages with the tool result and call the API route if all tool results for the last message are available.',
},
]}
/>
2 changes: 1 addition & 1 deletion content/docs/07-reference/ai-sdk-ui/index.mdx
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ Here is a comparison of the supported functions across these frameworks:
| Function | React | Svelte | Vue.js | SolidJS |
| ---------------------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) tool calling | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| [useChat](/docs/reference/ai-sdk-ui/use-chat) tool calling | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Check size={18} /> |
| [useCompletion](/docs/reference/ai-sdk-ui/use-completion) | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| [useObject](/docs/reference/ai-sdk-ui/use-object) | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| [useAssistant](/docs/reference/ai-sdk-ui/use-assistant) | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
Original file line number Diff line number Diff line change
@@ -91,18 +91,6 @@ export function Message({ textStream }: { textStream: StreamableValue }) {
}
```

```tsx filename='app/message.tsx'
'use client';

import { StreamableValue, useStreamableValue } from 'ai/rsc';

export function Message({ textStream }: { textStream: StreamableValue }) {
const [text] = useStreamableValue(textStream);

return <div>{text}</div>;
}
```

## Server

In your server action, you will create a function called `submitMessage` that adds the user's message to the thread. The function will create a new thread if one does not exist and add the user's message to the thread. If a thread already exists, the function will add the user's message to the existing thread. The function will then create a run and stream the assistant's response to the client. Furthermore, the run queue is used to manage multiple runs in the same thread during the lifetime of the server action.
9 changes: 5 additions & 4 deletions examples/solidstart-openai/.gitignore
Original file line number Diff line number Diff line change
@@ -4,7 +4,11 @@ dist
.output
.vercel
.netlify
netlify
.vinxi

# Environment
.env
.env*.local

# dependencies
/node_modules
@@ -22,6 +26,3 @@ gitignore
# System Files
.DS_Store
Thumbs.db

# Local env files
.env
3 changes: 3 additions & 0 deletions examples/solidstart-openai/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from '@solidjs/start/config';

export default defineConfig({});
31 changes: 14 additions & 17 deletions examples/solidstart-openai/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
{
"name": "solidstart-openai",
"private": true,
"type": "module",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
"dev": "vinxi dev",
"build": "vinxi build",
"start": "vinxi start"
},
"type": "module",
"devDependencies": {
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"solid-start-node": "0.3.10",
"tailwindcss": "^3.2.4",
"typescript": "^4.9.4",
"vite": "^4.1.4"
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"vinxi": "^0.3.12"
},
"dependencies": {
"@ai-sdk/openai": "latest",
"@ai-sdk/solid": "latest",
"@solidjs/meta": "0.29.3",
"@solidjs/router": "0.8.2",
"@solidjs/meta": "0.29.4",
"@solidjs/router": "^0.13.6",
"@solidjs/start": "^1.0.2",
"ai": "latest",
"openai": "4.47.1",
"solid-js": "1.8.7",
"solid-start": "0.3.10",
"undici": "^5.15.1"
"solid-js": "^1.8.17",
"zod": "^3.23.8"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"version": "0.0.0"
}
4 changes: 2 additions & 2 deletions examples/solidstart-openai/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
autoprefixer: {},
},
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind utilities;
19 changes: 19 additions & 0 deletions examples/solidstart-openai/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Router } from '@solidjs/router';
import { FileRoutes } from '@solidjs/start/router';
import { Suspense } from 'solid-js';

import './app.css';

export default function App() {
return (
<Router
root={props => (
<>
<Suspense>{props.children}</Suspense>
</>
)}
>
<FileRoutes />
</Router>
);
}
5 changes: 3 additions & 2 deletions examples/solidstart-openai/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mount, StartClient } from 'solid-start/entry-client';
// @refresh reload
import { mount, StartClient } from '@solidjs/start/client';

mount(() => <StartClient />, document);
mount(() => <StartClient />, document.getElementById('app')!);
28 changes: 20 additions & 8 deletions examples/solidstart-openai/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import {
StartServer,
createHandler,
renderAsync,
} from 'solid-start/entry-server';
// @refresh reload
import { createHandler, StartServer } from '@solidjs/start/server';

export default createHandler(
renderAsync(event => <StartServer event={event} />),
);
export default createHandler(() => (
<StartServer
document={({ assets, children, scripts }) => (
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
{assets}
</head>
<body>
<div id="app">{children}</div>
{scripts}
</body>
</html>
)}
/>
));
1 change: 1 addition & 0 deletions examples/solidstart-openai/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@solidjs/start/env" />
36 changes: 0 additions & 36 deletions examples/solidstart-openai/src/root.tsx

This file was deleted.

This file was deleted.

Loading