Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Nov 26, 2024
1 parent de69549 commit 2ed32fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { SuperSupabase } from "./supabase/helpers/supabase";
import { Embedding as VoyageEmbedding } from "./voyage/helpers/embedding";
import { SuperVoyage } from "./voyage/helpers/voyage";
import { VoyageAIClient } from "voyageai";
import { Issues } from "./supabase/helpers/issues";
import { Issue } from "./supabase/helpers/issues";

export function createAdapters(supabaseClient: SupabaseClient, voyage: VoyageAIClient, context: Context) {
return {
supabase: {
comment: new Comment(supabaseClient, context),
issue: new Issues(supabaseClient, context),
issue: new Issue(supabaseClient, context),
super: new SuperSupabase(supabaseClient, context),
},
voyage: {
Expand Down
30 changes: 30 additions & 0 deletions src/adapters/supabase/helpers/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,41 @@ interface IssueData {
isPrivate: boolean;
}

interface FindSimilarIssuesParams {
markdown: string;
currentId: string;
threshold: number;
}

export class Issue extends SuperSupabase {
constructor(supabase: SupabaseClient, context: Context) {
super(supabase, context);
}

async findSimilarIssues(params: FindSimilarIssuesParams): Promise<IssueSimilaritySearchResult[]> {
const { markdown, currentId, threshold } = params;
const embedding = await this.context.adapters.voyage.embedding.createEmbedding(markdown);
const { data, error } = await this.supabase.rpc("match_issues", {
query_embedding: embedding,
match_threshold: threshold,
current_id: currentId,
});

if (error) {
this.context.logger.error("Error finding similar issues", {
Error: error,
params,
});
return [];
}

return data.map((item: IssueSimilaritySearchResult) => ({
id: item.id,
issue_id: item.id,
similarity: item.similarity,
}));
}

async createIssue(issueData: IssueData) {
const { isPrivate } = issueData;
//First Check if the issue already exists
Expand Down

0 comments on commit 2ed32fb

Please sign in to comment.