Skip to content

Commit 45ea3a6

Browse files
committed
fix: enable CCDA documents to be properly searched with semantic search
1 parent 6ffb552 commit 45ea3a6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: apps/web/src/components/providers/vector-provider/helpers/prepareClinicalDocumentForVectorization.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function serializeAndChunkXmlContentForVectorization({
146146
Math.min(offset + CHUNK_SIZE, content.length),
147147
);
148148
chunkedDocumentsList.push({
149-
id: `${documentId}_chunk${chunkId}`,
149+
id: `${documentId}_chunk${chunkId}${prependText ? `_${prependText}` : ''}`,
150150
text: prependText + chunkData,
151151
chunk: {
152152
offset: offset,
@@ -182,7 +182,7 @@ function serializeCCDADocumentForVectorization(
182182
serializeAndChunkXmlContentForVectorization({
183183
content: data,
184184
meta,
185-
documentId: documentId + sectionType,
185+
documentId: documentId,
186186
chunkedDocumentsList,
187187
chunkedMetadataList,
188188
prependText: sectionType + '|',

Diff for: apps/web/src/features/mere-ai-chat/open-ai/callOpenAI.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@ import { differenceInDays, parseISO } from 'date-fns';
22
import { UserDocument } from '../../../models/user-document/UserDocument.type';
33
import { ChatMessage } from '../types/ChatMessage';
44

5+
const OPEN_AI_MODEL = 'gpt-4o';
6+
7+
export const getOpenAIModels = async (openAiKey: string) => {
8+
const response = await fetch('https://api.openai.com/v1/models', {
9+
headers: {
10+
Authorization: `Bearer ${openAiKey}`,
11+
'Content-Type': 'application/json',
12+
},
13+
});
14+
15+
if (!response.ok) {
16+
throw new Error(`Error fetching models: ${response.statusText}`);
17+
}
18+
19+
const data = await response.json();
20+
return data;
21+
};
22+
523
export const callOpenAI = async ({
624
query,
725
messages,
@@ -57,7 +75,7 @@ ${user.gender ? 'Gender:' + user?.gender : ''}`,
5775
Authorization: `Bearer ${openAiKey}`,
5876
},
5977
body: JSON.stringify({
60-
model: 'gpt-4-turbo-preview',
78+
model: OPEN_AI_MODEL,
6179
messages: promptMessages,
6280
functions: [
6381
{

0 commit comments

Comments
 (0)