From 0001c24d09b9839a3ae7a3868fdfc567b2ee7e5e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 6 Nov 2024 03:28:49 +0300 Subject: [PATCH] Use predicted outputs for doc edits (#495) --- app/(chat)/api/chat/route.ts | 10 +++++++++- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/(chat)/api/chat/route.ts b/app/(chat)/api/chat/route.ts index 50c31f2..0543c61 100644 --- a/app/(chat)/api/chat/route.ts +++ b/app/(chat)/api/chat/route.ts @@ -202,6 +202,14 @@ export async function POST(request: Request) { model: customModel(model.apiIdentifier), system: 'You are a helpful writing assistant. Based on the description, please update the piece of writing.', + experimental_providerMetadata: { + openai: { + prediction: { + type: 'content', + content: currentContent, + }, + }, + }, messages: [ { role: 'user', @@ -266,7 +274,7 @@ export async function POST(request: Request) { const { elementStream } = await streamObject({ model: customModel(model.apiIdentifier), system: - 'You are a help writing assistant. Given a piece of writing, please offer suggestions to improve the piece of writing and describe the change. It is very important for the edits to contain full sentences instead of just words.', + 'You are a help writing assistant. Given a piece of writing, please offer suggestions to improve the piece of writing and describe the change. It is very important for the edits to contain full sentences instead of just words. Max 5 suggestions.', prompt: document.content, output: 'array', schema: z.object({ diff --git a/package.json b/package.json index 562c795..138da3a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@vercel/analytics": "^1.3.1", "@vercel/blob": "^0.24.1", "@vercel/postgres": "^0.10.0", - "ai": "3.4.32", + "ai": "3.4.33", "bcrypt-ts": "^5.0.2", "class-variance-authority": "^0.7.0", "classnames": "^2.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc76d8d..a716ced 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,8 +48,8 @@ dependencies: specifier: ^0.10.0 version: 0.10.0 ai: - specifier: 3.4.32 - version: 3.4.32(react@19.0.0-rc-45804af1-20241021)(svelte@5.1.3)(vue@3.5.12)(zod@3.23.8) + specifier: 3.4.33 + version: 3.4.33(react@19.0.0-rc-45804af1-20241021)(svelte@5.1.3)(vue@3.5.12)(zod@3.23.8) bcrypt-ts: specifier: ^5.0.2 version: 5.0.2 @@ -2506,8 +2506,8 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - /ai@3.4.32(react@19.0.0-rc-45804af1-20241021)(svelte@5.1.3)(vue@3.5.12)(zod@3.23.8): - resolution: {integrity: sha512-d5Im7kWsjw1T/IFfYPH4KDLUn4W+XIZqip34q7wcyVBAKLcjGSbJh+5F7Ktc1MIzThHUPh/NUzbHlDDNhTlCgA==} + /ai@3.4.33(react@19.0.0-rc-45804af1-20241021)(svelte@5.1.3)(vue@3.5.12)(zod@3.23.8): + resolution: {integrity: sha512-plBlrVZKwPoRTmM8+D1sJac9Bq8eaa2jiZlHLZIWekKWI1yMWYZvCCEezY9ASPwRhULYDJB2VhKOBUUeg3S5JQ==} engines: {node: '>=18'} peerDependencies: openai: ^4.42.0