-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
import { streamText } from "ai"; | ||
import { createClient } from "edgedb"; | ||
import { createGel } from "../../../../../edgedb-js/packages/gel/dist"; | ||
import { createEdgeDBRag } from "../../../../../edgedb-js/packages/edgedb-ai-sdk/dist"; | ||
|
||
export const client = createClient(); | ||
|
||
export async function POST(req: Request) { | ||
const { prompt } = await req.json(); | ||
|
||
const edgedbRag = await createEdgeDBRag(client); | ||
const textModel = edgedbRag.languageModel("gpt-4-turbo-preview"); | ||
|
||
const result = await streamText({ | ||
model: ( | ||
await createGel(client) | ||
).languageModel("gpt-4-turbo-preview", { context: { query: "Book" } }), | ||
model: textModel.withSettings({ context: { query: "Book" } }), | ||
prompt, | ||
}); | ||
|
||
return result.toDataStreamResponse(); | ||
} | ||
|
||
// or provide context right away | ||
|
||
// const edgedbRag = await createEdgeDBRag(client); | ||
// const result = await streamText({ | ||
// model: edgedbRag.languageModel("gpt-4-turbo-preview", { | ||
// context: { query: "Book" }, | ||
// }), | ||
// prompt, | ||
// }); | ||
|
||
// Embedding example | ||
|
||
// const embeddingResult = await embed({ | ||
// model: edgedbRag.textEmbeddingModel("text-embedding-3-small"), | ||
// value: "sunny day at the beach", | ||
// }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters