Skip to content

Commit

Permalink
camel case sql query response
Browse files Browse the repository at this point in the history
  • Loading branch information
mantagen committed Dec 12, 2024
1 parent 1fd47b2 commit dba54e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/rag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export async function getRelevantLessonPlans({
});
log.info(`Got ${vectorSearchResults.length} search results`);

if (vectorSearchResults.length === 0) {
return [];
}

log.info(`Reranking lesson plans`);
const rerankedResults = await rerankResults({
cohereClient,
Expand Down
12 changes: 6 additions & 6 deletions packages/rag/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export async function vectorSearch({
const startAt = new Date();
const response = await prisma.$queryRaw<RagLessonPlanResult[]>`
SELECT
rag_lesson_plan_id as ragLessonPlanId,
oak_lesson_id as oakLessonId,
oak_lesson_slug as oakLessonSlug,
lesson_plan as lessonPlan,
key as matchedKey,
value_text as matchedValue,
rag_lesson_plan_id as "ragLessonPlanId",
oak_lesson_id as "oakLessonId",
oak_lesson_slug as "oakLessonSlug",
lesson_plan as "lessonPlan",
key as "matchedKey",
value_text as "matchedValue",
embedding <-> ${queryEmbedding}::vector as distance
FROM rag.rag_lesson_plan_parts JOIN rag.rag_lesson_plans ON rag_lesson_plan_id = rag_lesson_plans.id
WHERE rag_lesson_plans.is_published = true
Expand Down

0 comments on commit dba54e4

Please sign in to comment.