-
Notifications
You must be signed in to change notification settings - Fork 0
[AIT-676] Move /api/chat default from core to Vercel layer
#35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| // Vercel-specific React hooks | ||
| export type { ChatTransport } from '../transport/chat-transport.js'; | ||
| export type { ChatTransportHandle } from './use-chat-transport.js'; | ||
| export { useChatTransport } from './use-chat-transport.js'; | ||
| export { useMessageSync } from './use-message-sync.js'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,11 @@ import type { | |
| } from '../../core/transport/types.js'; | ||
| import { UIMessageCodec } from '../codec/index.js'; | ||
|
|
||
| /** Options for creating a Vercel client transport. Same as core options but without the codec field. */ | ||
| export type VercelClientTransportOptions = Omit<ClientTransportOptions<AI.UIMessageChunk, AI.UIMessage>, 'codec'>; | ||
| /** Core client transport options with Vercel AI SDK types pre-applied. */ | ||
| type CoreClientOpts = ClientTransportOptions<AI.UIMessageChunk, AI.UIMessage>; | ||
|
|
||
| /** Options for creating a Vercel client transport. Same as core options but without the codec field, and with `api` optional (defaults to `"/api/chat"`). */ | ||
| export type VercelClientTransportOptions = Omit<CoreClientOpts, 'codec' | 'api'> & Partial<Pick<CoreClientOpts, 'api'>>; | ||
|
|
||
| /** Options for creating a Vercel server transport. Same as core options but without the codec field. */ | ||
| export type VercelServerTransportOptions = Omit<ServerTransportOptions<AI.UIMessageChunk, AI.UIMessage>, 'codec'>; | ||
|
|
@@ -42,7 +45,13 @@ export type VercelServerTransportOptions = Omit<ServerTransportOptions<AI.UIMess | |
| */ | ||
| export const createClientTransport = ( | ||
| options: VercelClientTransportOptions, | ||
| ): ClientTransport<AI.UIMessageChunk, AI.UIMessage> => createCoreClientTransport({ ...options, codec: UIMessageCodec }); | ||
| ): ClientTransport<AI.UIMessageChunk, AI.UIMessage> => | ||
| createCoreClientTransport({ | ||
| ...options, | ||
| codec: UIMessageCodec, | ||
| // Mirrors the Vercel AI SDK's DefaultChatTransport default. | ||
| api: options.api ?? '/api/chat', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious what value you think this would add? It's only used in this place and isn't intended as a reusable value. If you feel strongly I'm happy to change though
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's pretty hidden / unclear what would happen if you don't pass
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's documented on
|
||
| }); | ||
|
|
||
| /** | ||
| * Create a server-side transport pre-configured with the Vercel AI SDK codec. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.