feat: enhance creation of recommendation keywords

This commit is contained in:
2023-09-08 14:01:35 +02:00
parent cc112b7554
commit 217dce04fb
5 changed files with 58 additions and 35 deletions

View File

@ -71,12 +71,13 @@ export async function createKeywords(type: string, description: string) {
{
"role": "system",
"content":
`you create some general vibey keywords to use in a recommendation system based on a ${type} description`,
`you create some keywords to use in a recommendation system based on a ${type} description, create a range of keywords from very specific ones that describe the general vibe also include some that describe the genre`,
},
{ "role": "user", "content": description.slice(0, 2000) },
{
"role": "user",
"content": "return a list of keywords seperated by commas",
"content":
"only return a list of around 20 keywords seperated by commas",
},
],
});

View File

@ -51,3 +51,10 @@ export async function createRecommendationResource(
cache.set(cacheId, JSON.stringify(resource));
}
export async function getAllRecommendations() {
const keys = await cache.keys("recommendations:movie:*");
return Promise.all(keys.map((k) => cache.get(k))).then((res) =>
res.map((r) => JSON.parse(r))
);
}