22
33import { anthropic } from "@ai-sdk/anthropic" ;
44import { createStreamableValue } from "@ai-sdk/rsc" ;
5- import { streamObject } from "ai" ;
5+ import { Output , streamText } from "ai" ;
66import * as z from "zod/v4" ;
77
88export async function generateCsvMapping (
@@ -12,29 +12,33 @@ export async function generateCsvMapping(
1212 const stream = createStreamableValue ( ) ;
1313
1414 ( async ( ) => {
15- const { partialObjectStream } = streamObject ( {
16- model : anthropic ( "claude-sonnet-4-20250514" ) ,
17- schema : z . object ( {
18- link : z
19- . string ( )
20- . optional ( )
21- . describe ( "The shortlink (link), including the domain and path." ) ,
22- url : z . string ( ) . optional ( ) . describe ( "The full URL of the shortlink" ) ,
23- title : z . string ( ) . optional ( ) . describe ( "The title of the shortlink" ) ,
24- description : z
25- . string ( )
26- . optional ( )
27- . describe ( "The description of the shortlink" ) ,
28- tags : z
29- . string ( )
30- . optional ( )
31- . describe (
32- "A comma-separated list of tags for shortlink organization (NOT to be mapped to a description)." ,
33- ) ,
34- createdAt : z
35- . string ( )
36- . optional ( )
37- . describe ( "The date and time the shortlink was created (createdAt)" ) ,
15+ const { partialOutputStream } = streamText ( {
16+ model : anthropic ( "claude-sonnet-6" ) ,
17+ output : Output . object ( {
18+ schema : z . object ( {
19+ link : z
20+ . string ( )
21+ . optional ( )
22+ . describe ( "The shortlink (link), including the domain and path." ) ,
23+ url : z . string ( ) . optional ( ) . describe ( "The full URL of the shortlink" ) ,
24+ title : z . string ( ) . optional ( ) . describe ( "The title of the shortlink" ) ,
25+ description : z
26+ . string ( )
27+ . optional ( )
28+ . describe ( "The description of the shortlink" ) ,
29+ tags : z
30+ . string ( )
31+ . optional ( )
32+ . describe (
33+ "A comma-separated list of tags for shortlink organization (NOT to be mapped to a description)." ,
34+ ) ,
35+ createdAt : z
36+ . string ( )
37+ . optional ( )
38+ . describe (
39+ "The date and time the shortlink was created (createdAt)" ,
40+ ) ,
41+ } ) ,
3842 } ) ,
3943 prompt :
4044 `The following columns are the headings from a CSV import file for importing a company's short links. ` +
@@ -47,7 +51,7 @@ export async function generateCsvMapping(
4751 temperature : 0.2 ,
4852 } ) ;
4953
50- for await ( const partialObject of partialObjectStream ) {
54+ for await ( const partialObject of partialOutputStream ) {
5155 stream . update ( partialObject ) ;
5256 }
5357
0 commit comments