Skip to content

Commit

Permalink
feat: extract markdown at server side and use predicted output feature
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Nov 9, 2024
1 parent 5ad3000 commit 1c961fd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/routes/api/extract/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { RequestHandler } from "./$types"

import { systemPrompt } from "./prompt"
import { error } from "@sveltejs/kit"
import { toMarkdown } from "$lib/utils/html2md"
import { iteratorToStream } from "$lib/utils/stream"
import { OpenAI } from "openai"

Expand All @@ -16,7 +17,10 @@ async function * extract(html: string) {
],
stream: true,
temperature: 0,
prediction: { type: "content", content: toMarkdown(html).trim() },
stream_options: { include_usage: true },
})) {
chunk.usage && console.error(chunk.usage)
const delta = chunk.choices[0].delta.content
if (delta)
yield delta
Expand Down

0 comments on commit 1c961fd

Please sign in to comment.