Skip to content

Commit

Permalink
fix: enable CCDA documents to be properly searched with semantic search
Browse files Browse the repository at this point in the history
  • Loading branch information
cfu288 committed Sep 29, 2024
1 parent 6ffb552 commit 45ea3a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function serializeAndChunkXmlContentForVectorization({
Math.min(offset + CHUNK_SIZE, content.length),
);
chunkedDocumentsList.push({
id: `${documentId}_chunk${chunkId}`,
id: `${documentId}_chunk${chunkId}${prependText ? `_${prependText}` : ''}`,
text: prependText + chunkData,
chunk: {
offset: offset,
Expand Down Expand Up @@ -182,7 +182,7 @@ function serializeCCDADocumentForVectorization(
serializeAndChunkXmlContentForVectorization({
content: data,
meta,
documentId: documentId + sectionType,
documentId: documentId,
chunkedDocumentsList,
chunkedMetadataList,
prependText: sectionType + '|',
Expand Down
20 changes: 19 additions & 1 deletion apps/web/src/features/mere-ai-chat/open-ai/callOpenAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import { differenceInDays, parseISO } from 'date-fns';
import { UserDocument } from '../../../models/user-document/UserDocument.type';
import { ChatMessage } from '../types/ChatMessage';

const OPEN_AI_MODEL = 'gpt-4o';

export const getOpenAIModels = async (openAiKey: string) => {
const response = await fetch('https://api.openai.com/v1/models', {
headers: {
Authorization: `Bearer ${openAiKey}`,
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error(`Error fetching models: ${response.statusText}`);
}

const data = await response.json();
return data;
};

export const callOpenAI = async ({
query,
messages,
Expand Down Expand Up @@ -57,7 +75,7 @@ ${user.gender ? 'Gender:' + user?.gender : ''}`,
Authorization: `Bearer ${openAiKey}`,
},
body: JSON.stringify({
model: 'gpt-4-turbo-preview',
model: OPEN_AI_MODEL,
messages: promptMessages,
functions: [
{
Expand Down

0 comments on commit 45ea3a6

Please sign in to comment.