feat: add initial recommendation data

This commit is contained in:
2023-09-08 13:33:29 +02:00
parent 517b1ba23d
commit cc112b7554
19 changed files with 289 additions and 170 deletions

View File

@@ -1,4 +1,4 @@
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
import { OpenAI } from "https://deno.land/x/openai@1.4.2/mod.ts";
import { OPENAI_API_KEY } from "@lib/env.ts";
const openAI = OPENAI_API_KEY && new OpenAI(OPENAI_API_KEY);
@@ -63,6 +63,28 @@ export async function extractAuthorName(content: string) {
return author;
}
export async function createKeywords(type: string, description: string) {
if (!openAI) return;
const chatCompletion = await openAI.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{
"role": "system",
"content":
`you create some general vibey keywords to use in a recommendation system based on a ${type} description`,
},
{ "role": "user", "content": description.slice(0, 2000) },
{
"role": "user",
"content": "return a list of keywords seperated by commas",
},
],
});
return chatCompletion.choices[0].message.content?.toLowerCase().split(", ")
.map((v) => v.replaceAll(" ", "-"));
}
export async function createTags(content: string) {
if (!openAI) return;
const chatCompletion = await openAI.createChatCompletion({