Shun Miyazawa 1 год назад
Родитель
Сommit
4cf7b63f50

+ 1 - 1
apps/app/src/server/service/openai/embeddings.ts

@@ -2,7 +2,7 @@ import type { OpenAI } from 'openai';
 
 import { openaiClient } from './client';
 
-export const embed = async(username: string, input: string): Promise<OpenAI.Embedding[]> => {
+export const embed = async(input: string, username?: string): Promise<OpenAI.Embedding[]> => {
   const result = await openaiClient.embeddings.create({
     input,
     model: 'text-embedding-3-large',

+ 1 - 1
apps/app/src/server/service/search-delegator/bulk-write.d.ts

@@ -15,7 +15,7 @@ export type AggregatedPage = Pick<IPageHasId,
   bookmarksCount: number,
   likeCount: number,
   seenUsersCount: number,
-  creator: {
+  creator?: {
     username: string,
     email: string,
   },

+ 1 - 1
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -486,7 +486,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
       async transform(chunk: AggregatedPage[], encoding, callback) {
         // append embedding
         for await (const doc of chunk) {
-          doc.revisionBodyEmbedded = (await embed(doc.creator.username, doc.revision.body))[0].embedding;
+          doc.revisionBodyEmbedded = (await embed(doc.revision.body, doc.creator?.username))[0].embedding;
         }
 
         this.push(chunk);