Skip to content

Commit

Permalink
Merge pull request #82 from makeiteasierapps/adjust-similiarity-settings
Browse files Browse the repository at this point in the history
changed match threshold to 0.1 and embeddings model to 3-small
  • Loading branch information
adamcohenhillel authored Feb 28, 2024
2 parents 55aa14c + c5e0ca6 commit 7be9eb8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions supabase/functions/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,20 @@ const chat = async (req) => {
});
}

console.log("messageHistory: ", messageHistory);

// Embed the last messageHistory message using OpenAI's embeddings API
const embeddingsResponse = await openaiClient.embeddings.create({
model: "text-embedding-ada-002",
model: "text-embedding-3-small",
input: messageHistory[messageHistory.length - 1].content,
});
const embeddings = embeddingsResponse.data[0].embedding;
console.log("Embeddings:", embeddings);

// Retrieve records from Supabase based on embeddings similarity
const { data: relevantRecords, error: recordsError } = await supabase.rpc(
"match_records_embeddings_similarity",
{
query_embedding: JSON.stringify(embeddings),
match_threshold: 0.8,
match_threshold: 0.1,
match_count: 10,
}
);
Expand All @@ -107,6 +105,7 @@ const chat = async (req) => {
console.log("recordsError: ", recordsError);
throw new ApplicationError("Error getting records from Supabase");
}
console.log("relevantRecords: ", relevantRecords);

let messages = [
{
Expand All @@ -120,7 +119,6 @@ const chat = async (req) => {
},
...messageHistory,
];
console.log("messages: ", messages);

try {
const responseMessage = await generateResponse(
Expand Down

0 comments on commit 7be9eb8

Please sign in to comment.