feat: add initial recommendation data
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user