From 7be884b1edb3e13d0628a4f20525f4bb35c26be4 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Wed, 18 Sep 2024 00:54:11 +0100 Subject: [PATCH] chore: renaming --- ...up-instructions.ts => handle-repo-docs.ts} | 23 +++++++++++++++---- src/proxy-callbacks.ts | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) rename src/handlers/onboarding/{create-setup-instructions.ts => handle-repo-docs.ts} (77%) diff --git a/src/handlers/onboarding/create-setup-instructions.ts b/src/handlers/onboarding/handle-repo-docs.ts similarity index 77% rename from src/handlers/onboarding/create-setup-instructions.ts rename to src/handlers/onboarding/handle-repo-docs.ts index ca3be19..1fee191 100644 --- a/src/handlers/onboarding/create-setup-instructions.ts +++ b/src/handlers/onboarding/handle-repo-docs.ts @@ -1,7 +1,23 @@ import { CallbackResult } from "../../proxy-callbacks"; import { Context } from "../../types"; -export async function createSetupInstructions(context: Context<"push">): Promise { +/** + * Will create embeddings for any .md files found in the repository. + * Would benefit from a structured schema, but most of our readmes are + * pretty uniform anyway. + * + * Storage schema looks like: + * + * ```json + * { + * "sourceId": "owner/repo/file.md", + * "type": "setup_instructions", + * "plaintext": "file content", + * "metadata": { + * "author_association": "OWNER", + * "author_id": 123456, + */ +export async function handleRepoDocuments(context: Context<"push">): Promise { const { logger, octokit, @@ -39,7 +55,7 @@ export async function createSetupInstructions(context: Context<"push">): Promise } /** - * voyageai use a special encoding schema and we cannot easily + * voyageai uses a special encoding schema and we cannot easily * use their encoder so we will just have to play it by ear for now. */ for (const doc of docs) { @@ -60,11 +76,10 @@ export async function createSetupInstructions(context: Context<"push">): Promise const text = docContent.data as unknown as string; const uploaded = await supabase.embeddings.createEmbedding(sourceId, "setup_instructions", text, { - author_association: "OWNER", - author_id: sender?.id, isPrivate: repository.private, repo_node_id: repository.node_id, repo_full_name: repository.full_name, + filePath: doc, fileChunkIndex: 0, }); diff --git a/src/proxy-callbacks.ts b/src/proxy-callbacks.ts index 2911477..54f77b1 100644 --- a/src/proxy-callbacks.ts +++ b/src/proxy-callbacks.ts @@ -6,7 +6,7 @@ import { taskSimilaritySearch } from "./handlers/tasks/task-deduplication"; import { updateCommentEmbedding } from "./handlers/comments/update-comment-embedding"; import { updateTaskEmbedding } from "./handlers/tasks/update-task-embedding"; import { Context, SupportedEvents, SupportedEventsU } from "./types"; -import { createSetupInstructions } from "./handlers/onboarding/create-setup-instructions"; +import { handleRepoDocuments } from "./handlers/onboarding/handle-repo-docs"; export type CallbackResult = { status: 200 | 201 | 204 | 404 | 500; reason: string; content?: string | Record }; @@ -47,7 +47,7 @@ const callbacks = { "issues.edited": [updateTaskEmbedding], "issues.deleted": [deleteTaskEmbedding], - "push": [createSetupInstructions] + "push": [handleRepoDocuments] } as ProxyCallbacks; /**