Skip to content

Commit

Permalink
chore: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 17, 2024
1 parent b3443ec commit 7be884b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { CallbackResult } from "../../proxy-callbacks";
import { Context } from "../../types";

export async function createSetupInstructions(context: Context<"push">): Promise<CallbackResult> {
/**
* 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<CallbackResult> {
const {
logger,
octokit,
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
});

Expand Down
4 changes: 2 additions & 2 deletions src/proxy-callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown> };

Expand Down Expand Up @@ -47,7 +47,7 @@ const callbacks = {
"issues.edited": [updateTaskEmbedding],
"issues.deleted": [deleteTaskEmbedding],

"push": [createSetupInstructions]
"push": [handleRepoDocuments]
} as ProxyCallbacks;

/**
Expand Down

0 comments on commit 7be884b

Please sign in to comment.