Use predicted outputs for doc edits (#495)

This commit is contained in:
Jeremy 2024-11-06 03:28:49 +03:00 committed by GitHub
parent d782400cfa
commit 0001c24d09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View file

@ -202,6 +202,14 @@ export async function POST(request: Request) {
model: customModel(model.apiIdentifier), model: customModel(model.apiIdentifier),
system: system:
'You are a helpful writing assistant. Based on the description, please update the piece of writing.', '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: [ messages: [
{ {
role: 'user', role: 'user',
@ -266,7 +274,7 @@ export async function POST(request: Request) {
const { elementStream } = await streamObject({ const { elementStream } = await streamObject({
model: customModel(model.apiIdentifier), model: customModel(model.apiIdentifier),
system: 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, prompt: document.content,
output: 'array', output: 'array',
schema: z.object({ schema: z.object({

View file

@ -23,7 +23,7 @@
"@vercel/analytics": "^1.3.1", "@vercel/analytics": "^1.3.1",
"@vercel/blob": "^0.24.1", "@vercel/blob": "^0.24.1",
"@vercel/postgres": "^0.10.0", "@vercel/postgres": "^0.10.0",
"ai": "3.4.32", "ai": "3.4.33",
"bcrypt-ts": "^5.0.2", "bcrypt-ts": "^5.0.2",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"classnames": "^2.5.1", "classnames": "^2.5.1",

8
pnpm-lock.yaml generated
View file

@ -48,8 +48,8 @@ dependencies:
specifier: ^0.10.0 specifier: ^0.10.0
version: 0.10.0 version: 0.10.0
ai: ai:
specifier: 3.4.32 specifier: 3.4.33
version: 3.4.32(react@19.0.0-rc-45804af1-20241021)(svelte@5.1.3)(vue@3.5.12)(zod@3.23.8) 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: bcrypt-ts:
specifier: ^5.0.2 specifier: ^5.0.2
version: 5.0.2 version: 5.0.2
@ -2506,8 +2506,8 @@ packages:
engines: {node: '>=0.4.0'} engines: {node: '>=0.4.0'}
hasBin: true 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): /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-d5Im7kWsjw1T/IFfYPH4KDLUn4W+XIZqip34q7wcyVBAKLcjGSbJh+5F7Ktc1MIzThHUPh/NUzbHlDDNhTlCgA==} resolution: {integrity: sha512-plBlrVZKwPoRTmM8+D1sJac9Bq8eaa2jiZlHLZIWekKWI1yMWYZvCCEezY9ASPwRhULYDJB2VhKOBUUeg3S5JQ==}
engines: {node: '>=18'} engines: {node: '>=18'}
peerDependencies: peerDependencies:
openai: ^4.42.0 openai: ^4.42.0