generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: repo readme embeddings (setup_instructions)
- Loading branch information
Showing
14 changed files
with
127 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,4 +91,4 @@ | |
] | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/handlers/create-comment-embedding.ts → ...lers/comments/create-comment-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/handlers/delete-comment-embedding.ts → ...lers/comments/delete-comment-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/handlers/update-comment-embedding.ts → ...lers/comments/update-comment-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { CallbackResult } from "../../proxy-callbacks"; | ||
import { Context } from "../../types"; | ||
|
||
export async function createSetupInstructions(context: Context<"push">): Promise<CallbackResult> { | ||
const { | ||
logger, | ||
octokit, | ||
adapters: { supabase }, | ||
payload: { repository, commits, sender, pusher } | ||
} = context; | ||
|
||
const docs = [] | ||
|
||
for (const commit of commits) { | ||
const { added, modified } = commit; | ||
const files = [] | ||
|
||
if (added && added.length > 0) { | ||
files.push(...added) | ||
} | ||
if (modified && modified.length > 0) { | ||
files.push(...modified) | ||
} | ||
|
||
for (const file of files) { | ||
if (file.endsWith(".md")) { | ||
docs.push(file) | ||
} | ||
} | ||
} | ||
|
||
if (docs.length === 0) { | ||
return { status: 200, reason: "no markdown files found" }; | ||
} | ||
|
||
logger.info(`Found ${docs.length} markdown files`); | ||
if (!repository.owner || !repository.name) { | ||
return { status: 200, reason: "no repository owner or name found" }; | ||
} | ||
|
||
/** | ||
* voyageai use 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) { | ||
const sourceId = repository.full_name + "/" + doc; | ||
const docContent = await octokit.repos.getContent({ | ||
owner: repository.owner.login, | ||
repo: repository.name, | ||
path: doc, | ||
mediaType: { | ||
format: "raw", | ||
} | ||
}); | ||
|
||
if (!docContent.data) { | ||
return { status: 200, reason: "no content found" }; | ||
} | ||
|
||
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, | ||
fileChunkIndex: 0, | ||
}); | ||
|
||
logger.info("Uploaded markdown file", { ...uploaded, embedding: "removed for brevity" }); | ||
} | ||
|
||
logger.ok("Successfully uploaded setup instructions", { repository: repository.full_name }); | ||
|
||
return { status: 200, reason: "success" }; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/handlers/create-task-embedding.ts → src/handlers/tasks/create-task-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/handlers/delete-task-embedding.ts → src/handlers/tasks/delete-task-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/handlers/update-task-embedding.ts → src/handlers/tasks/update-task-embedding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters