|
@@ -3,11 +3,9 @@
|
|
|
import type { IPageHasId, Lang } from '@growi/core/dist/interfaces';
|
|
import type { IPageHasId, Lang } from '@growi/core/dist/interfaces';
|
|
|
import type { MessageContentDelta } from 'openai/resources/beta/threads/messages.mjs';
|
|
import type { MessageContentDelta } from 'openai/resources/beta/threads/messages.mjs';
|
|
|
|
|
|
|
|
-import VectorStoreFileRelationModel, { type VectorStoreFileRelation } from '~/features/openai/server/models/vector-store-file-relation';
|
|
|
|
|
|
|
+import VectorStoreFileRelationModel from '~/features/openai/server/models/vector-store-file-relation';
|
|
|
import { getTranslation } from '~/server/service/i18next';
|
|
import { getTranslation } from '~/server/service/i18next';
|
|
|
|
|
|
|
|
-type PopulatedVectorStoreFileRelation = Omit<VectorStoreFileRelation, 'pageId'> & { pageId: IPageHasId }
|
|
|
|
|
-
|
|
|
|
|
export const replaceAnnotationWithPageLink = async(messageContentDelta: MessageContentDelta, lang?: Lang): Promise<void> => {
|
|
export const replaceAnnotationWithPageLink = async(messageContentDelta: MessageContentDelta, lang?: Lang): Promise<void> => {
|
|
|
if (messageContentDelta?.type === 'text' && messageContentDelta?.text?.annotations != null) {
|
|
if (messageContentDelta?.type === 'text' && messageContentDelta?.text?.annotations != null) {
|
|
|
const annotations = messageContentDelta?.text?.annotations;
|
|
const annotations = messageContentDelta?.text?.annotations;
|
|
@@ -16,7 +14,7 @@ export const replaceAnnotationWithPageLink = async(messageContentDelta: MessageC
|
|
|
|
|
|
|
|
const vectorStoreFileRelation = await VectorStoreFileRelationModel
|
|
const vectorStoreFileRelation = await VectorStoreFileRelationModel
|
|
|
.findOne({ fileIds: { $in: [annotation.file_citation?.file_id] } })
|
|
.findOne({ fileIds: { $in: [annotation.file_citation?.file_id] } })
|
|
|
- .populate('pageId', 'path') as PopulatedVectorStoreFileRelation;
|
|
|
|
|
|
|
+ .populate<{pageId: Pick<IPageHasId, 'path' | '_id'>}>('pageId', 'path');
|
|
|
|
|
|
|
|
if (vectorStoreFileRelation != null) {
|
|
if (vectorStoreFileRelation != null) {
|
|
|
const { t } = await getTranslation(lang);
|
|
const { t } = await getTranslation(lang);
|