Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

October Update #33

Merged
merged 38 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aba3449
feat: schema validation
gentlementlegen Sep 23, 2024
d3d7391
chore: update wrangler
gentlementlegen Sep 29, 2024
3f17e9e
chore: fixed kernel data return
gentlementlegen Sep 29, 2024
bacd208
fix: enable RLS for tables
gentlementlegen Sep 30, 2024
12a4725
Merge pull request #22 from gentlementlegen/development
0x4007 Sep 30, 2024
3721f0f
feat: added edit distance re-ranker
sshivaditya Oct 1, 2024
ac2eae6
fix: editdistthreshold
sshivaditya Oct 1, 2024
9d3bdbf
fix: removed edit distance using l2 distance
sshivaditya Oct 2, 2024
cc96c8f
fix: main.test.ts values
shiv810 Oct 2, 2024
4ecd854
fix: ui for issue dedup
sshivaditya Oct 2, 2024
3a360b9
Update src/handlers/issue-deduplication.ts
0x4007 Oct 3, 2024
e7890fd
Apply suggestions from code review
0x4007 Oct 3, 2024
bb7f7d6
Merge pull request #26 from sshivaditya2019/issuesim
0x4007 Oct 3, 2024
b08a321
Merge branch 'development' into feat/schema-validation
gentlementlegen Oct 3, 2024
fb0e67a
chore: added schema generation
gentlementlegen Oct 3, 2024
d72c7da
chore: updated generated configuration
ubiquity-os[bot] Oct 3, 2024
92af35f
chore: fix tests
gentlementlegen Oct 3, 2024
8e8da2c
fix: empty footnotes
sshivaditya Oct 3, 2024
4582a14
fix: similar issue filter
sshivaditya Oct 3, 2024
cd97812
Merge pull request #29 from sshivaditya2019/issuesim
0x4007 Oct 3, 2024
2f06bd6
Merge pull request #19 from gentlementlegen/feat/schema-validation
gentlementlegen Oct 4, 2024
caa4ee3
chore: changed manifest endpoint
gentlementlegen Oct 4, 2024
0fc8d04
refactor: update package and plugin names to reflect new organization
0x4007 Oct 10, 2024
6f07c6c
feat: updated issue similarity ui
sshivaditya Oct 3, 2024
0cbce17
fix: empty strings init removed
sshivaditya Oct 3, 2024
e13461a
fix: changed the removeFootnote function
sshivaditya Oct 4, 2024
8af9f8b
feat: change the issue result mention
sshivaditya Oct 5, 2024
d7f262e
fix: tests, tests passing locally fails in ci
sshivaditya Oct 8, 2024
3ff27ee
fix: footnotes breaking link
sshivaditya Oct 8, 2024
b909ff3
feat: updated similarity search function
sshivaditya Oct 8, 2024
a875107
fix: issue creation fix
sshivaditya Oct 8, 2024
03f0110
fix: update the l2_distance with a weighted sum of inner product and …
sshivaditya Oct 8, 2024
4bce42c
fix: changed the order of the similarity search result
sshivaditya Oct 10, 2024
3477aea
fix: fixed tests
sshivaditya Oct 10, 2024
ab3df04
Merge pull request #31 from sshivaditya2019/issuesim
0x4007 Oct 11, 2024
34528ea
fix: transferissue
sshivaditya Oct 11, 2024
fb56335
feat: issue being edited all the time fixed
sshivaditya Oct 15, 2024
ab694b1
Merge pull request #35 from sshivaditya2019/issuesim
0x4007 Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Supabase",
"SUPABASE",
"typebox",
"ubiquibot",
"ubiquity-os",
"Smee",
"typeguards",
"mswjs",
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Update Configuration"

on:
workflow_dispatch:
push:

jobs:
update:
name: "Update Configuration in manifest.json"
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20.10.0"

- name: Install deps and run configuration update
run: |
yarn install --immutable --immutable-cache --check-cache
yarn tsc --noCheck --project tsconfig.json

- name: Update manifest configuration using GitHub Script
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');

const { pluginSettingsSchema } = require('./src/types');

const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));

const configuration = JSON.stringify(pluginSettingsSchema);

manifest["configuration"] = JSON.parse(configuration);

const updatedManifest = JSON.stringify(manifest, null, 2)
console.log('Updated manifest:', updatedManifest);
fs.writeFileSync(manifestPath, updatedManifest);

- name: Commit and Push generated types
run: |
git config --global user.name 'ubiquity-os[bot]'
git config --global user.email 'ubiquity-os[bot]@users.noreply.github.com'
git add ./manifest.json
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then
git commit -m "chore: updated generated configuration" || echo "Lint-staged check failed"
git push origin HEAD:${{ github.ref_name }}
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
id: wrangler_deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.78.12"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
Expand Down
36 changes: 18 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@

### Features

* modified tests ([97e267f](https://github.com/ubiquibot/issue-comment-embeddings/commit/97e267f801ce4e6bd29bbe967de3df4fc3b1942a))
* modified tests ([97e267f](https://github.com/ubiquity-os/issue-comment-embeddings/commit/97e267f801ce4e6bd29bbe967de3df4fc3b1942a))


### Bug Fixes

* added config.yml ([c0f784b](https://github.com/ubiquibot/issue-comment-embeddings/commit/c0f784b20e59c2c4714805331c7ae9034fd73f73))
* added config.yml ([221d34d](https://github.com/ubiquibot/issue-comment-embeddings/commit/221d34d801af6ebd764028be4a5c6200a18b776e))
* added config.yml ([d12c522](https://github.com/ubiquibot/issue-comment-embeddings/commit/d12c522291db36dcf6aea72e5759e1a055185d8f))
* cspell fix ([736bea6](https://github.com/ubiquibot/issue-comment-embeddings/commit/736bea6172444fdf783ffff729879d8278ff82f3))
* fixed tests missing supabase files ([0e870ac](https://github.com/ubiquibot/issue-comment-embeddings/commit/0e870ac50eb68249edf5fc4e46fd509425dd7bbb))
* github workflow, types package.json, env examples ([16786d7](https://github.com/ubiquibot/issue-comment-embeddings/commit/16786d76ee7a598c885f15af1baeadcf6a471b2c))
* issue_comments linting added issue_comments:edited, created and deleted ([9c0de23](https://github.com/ubiquibot/issue-comment-embeddings/commit/9c0de237048ce30bf4254960c443bf3938037dce))
* knip workflow ([f325310](https://github.com/ubiquibot/issue-comment-embeddings/commit/f3253109c290c9fce6d14e6a2e1e328133ac6f81))
* manifest.json, compute.yml ([21409d5](https://github.com/ubiquibot/issue-comment-embeddings/commit/21409d530c3aad6ff2676fc813314e5b29c1a533))
* package.json ([806c6c0](https://github.com/ubiquibot/issue-comment-embeddings/commit/806c6c0b393a9b87741a6341fa65bc5b3d22cb15))
* plugin name ([d91b991](https://github.com/ubiquibot/issue-comment-embeddings/commit/d91b991d717b7fb0b73359ca29ae6de08a1074b9))
* readme.md ([9c5fbfe](https://github.com/ubiquibot/issue-comment-embeddings/commit/9c5fbfe9ca46eb842779468c85d329b9f941fb82))
* readme.md ([2fec447](https://github.com/ubiquibot/issue-comment-embeddings/commit/2fec44786526e7c10faaa2c13c4349e1232cf5bd))
* remove config.yml and wrangler.toml namespace entries ([127cc22](https://github.com/ubiquibot/issue-comment-embeddings/commit/127cc225903c3fe3ca934e8407df4eb9c27e378c))
* removed config.yml changed name ([744e08c](https://github.com/ubiquibot/issue-comment-embeddings/commit/744e08cebac310ae81c3c102f5f3a9473e6e4b9e))
* test and linting ([a4ee41e](https://github.com/ubiquibot/issue-comment-embeddings/commit/a4ee41e6fca8723ce2fddc96b1171c89cfe7d5b7))
* wrangler name ([f890071](https://github.com/ubiquibot/issue-comment-embeddings/commit/f890071c01c5bb1d611a5b7aa07cba84f4546251))
* added config.yml ([c0f784b](https://github.com/ubiquity-os/issue-comment-embeddings/commit/c0f784b20e59c2c4714805331c7ae9034fd73f73))
* added config.yml ([221d34d](https://github.com/ubiquity-os/issue-comment-embeddings/commit/221d34d801af6ebd764028be4a5c6200a18b776e))
* added config.yml ([d12c522](https://github.com/ubiquity-os/issue-comment-embeddings/commit/d12c522291db36dcf6aea72e5759e1a055185d8f))
* cspell fix ([736bea6](https://github.com/ubiquity-os/issue-comment-embeddings/commit/736bea6172444fdf783ffff729879d8278ff82f3))
* fixed tests missing supabase files ([0e870ac](https://github.com/ubiquity-os/issue-comment-embeddings/commit/0e870ac50eb68249edf5fc4e46fd509425dd7bbb))
* github workflow, types package.json, env examples ([16786d7](https://github.com/ubiquity-os/issue-comment-embeddings/commit/16786d76ee7a598c885f15af1baeadcf6a471b2c))
* issue_comments linting added issue_comments:edited, created and deleted ([9c0de23](https://github.com/ubiquity-os/issue-comment-embeddings/commit/9c0de237048ce30bf4254960c443bf3938037dce))
* knip workflow ([f325310](https://github.com/ubiquity-os/issue-comment-embeddings/commit/f3253109c290c9fce6d14e6a2e1e328133ac6f81))
* manifest.json, compute.yml ([21409d5](https://github.com/ubiquity-os/issue-comment-embeddings/commit/21409d530c3aad6ff2676fc813314e5b29c1a533))
* package.json ([806c6c0](https://github.com/ubiquity-os/issue-comment-embeddings/commit/806c6c0b393a9b87741a6341fa65bc5b3d22cb15))
* plugin name ([d91b991](https://github.com/ubiquity-os/issue-comment-embeddings/commit/d91b991d717b7fb0b73359ca29ae6de08a1074b9))
* readme.md ([9c5fbfe](https://github.com/ubiquity-os/issue-comment-embeddings/commit/9c5fbfe9ca46eb842779468c85d329b9f941fb82))
* readme.md ([2fec447](https://github.com/ubiquity-os/issue-comment-embeddings/commit/2fec44786526e7c10faaa2c13c4349e1232cf5bd))
* remove config.yml and wrangler.toml namespace entries ([127cc22](https://github.com/ubiquity-os/issue-comment-embeddings/commit/127cc225903c3fe3ca934e8407df4eb9c27e378c))
* removed config.yml changed name ([744e08c](https://github.com/ubiquity-os/issue-comment-embeddings/commit/744e08cebac310ae81c3c102f5f3a9473e6e4b9e))
* test and linting ([a4ee41e](https://github.com/ubiquity-os/issue-comment-embeddings/commit/a4ee41e6fca8723ce2fddc96b1171c89cfe7d5b7))
* wrangler name ([f890071](https://github.com/ubiquity-os/issue-comment-embeddings/commit/f890071c01c5bb1d611a5b7aa07cba84f4546251))
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `@ubiquibot/issue-comment-embeddings`
# `@ubiquity-os/issue-comment-embeddings`

This is a plugin for [Ubiquibot](https://github.com/ubiquity/ubiquibot-kernel). It listens for issue comments, and adds them to a vector store. It handles comment edits and deletions as well.
This is a plugin for [Ubiquibot](https://github.com/ubiquity-os/ubiquity-os-kernel). It listens for issue comments, and adds them to a vector store. It handles comment edits and deletions as well.

## Configuration
- Host the plugin on a server that Ubiquibot can access.
Expand All @@ -10,9 +10,9 @@ To set up the `.dev.vars` file, you will need to provide the following variables
- `VOYAGEAI_API_KEY`: The API key for Voyage.

## Usage
- Add the following to your `.ubiquibot-config.yml` file with the appropriate URL:
- Add the following to your `.ubiquity-os.config.yml` file with the appropriate URL:
```yaml
- plugin: ubiquity-os-marketplace/generate-vector-embeddings
- plugin: https://ubiquity-os-comment-vector-embeddings-main.ubiquity.workers.dev
with:
matchThreshold: 0.95
warningThreshold: 0.75
Expand Down
35 changes: 33 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
{
"name": "Generate vector embeddings",
"description": "Enables the storage, updating, and deletion of issue comment embeddings.",
"ubiquity:listeners": ["issue_comment.created", "issue_comment.edited", "issue_comment.deleted", "issues.opened", "issues.edited", "issues.deleted", "issues.labeled"]
}
"ubiquity:listeners": [
"issue_comment.created",
"issue_comment.edited",
"issue_comment.deleted",
"issues.opened",
"issues.edited",
"issues.deleted",
"issues.labeled"
],
"configuration": {
"default": {},
"type": "object",
"properties": {
"matchThreshold": {
"default": 0.95,
"type": "number"
},
"warningThreshold": {
"default": 0.75,
"type": "number"
},
"jobMatchingThreshold": {
"default": 0.75,
"type": "number"
}
},
"required": [
"matchThreshold",
"warningThreshold",
"jobMatchingThreshold"
]
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ubiquibot/issue-comment-embeddings",
"name": "@ubiquity-os/issue-comment-embeddings",
"version": "1.0.0",
"description": "Generates vector embeddings of GitHub comments and stores them in Supabase.",
"author": "Ubiquity DAO",
Expand Down Expand Up @@ -36,7 +36,7 @@
"@sinclair/typebox": "0.32.33",
"@supabase/supabase-js": "^2.45.2",
"@types/markdown-it": "^14.1.2",
"@ubiquity-dao/ubiquibot-logger": "^1.3.0",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "16.4.5",
"markdown-it": "^14.1.0",
"markdown-it-plain-text": "^0.3.0",
Expand Down Expand Up @@ -69,10 +69,10 @@
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"supabase": "1.191.3",
"supabase": "1.200.3",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript": "5.6.2",
"typescript-eslint": "7.13.1",
"wrangler": "3.78.12"
},
Expand Down
31 changes: 22 additions & 9 deletions src/adapters/supabase/helpers/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Comment extends SuperSupabase {
} else {
//Create the embedding for this comment
const embedding = await this.context.adapters.voyage.embedding.createEmbedding(markdown);
let plaintext: string | null = markdownToPlainText(markdown || "");
let plaintext: string | null = markdownToPlainText(markdown);
if (isPrivate) {
markdown = null as string | null;
payload = null as Record<string, unknown> | null;
Expand All @@ -54,21 +54,34 @@ export class Comment extends SuperSupabase {
this.context.logger.info("Comment created successfully");
}

async updateComment(markdown: string | null, commentNodeId: string, payload: Record<string, unknown> | null, isPrivate: boolean) {
async updateComment(
markdown: string | null,
commentNodeId: string,
authorId: number,
payload: Record<string, unknown> | null,
isPrivate: boolean,
issueId: string
) {
//Create the embedding for this comment
const embedding = Array.from(await this.context.adapters.voyage.embedding.createEmbedding(markdown));
let plaintext: string | null = markdownToPlainText(markdown || "");
let plaintext: string | null = markdownToPlainText(markdown);
if (isPrivate) {
markdown = null as string | null;
payload = null as Record<string, unknown> | null;
plaintext = null as string | null;
}
const { error } = await this.supabase
.from("issue_comments")
.update({ markdown, plaintext, embedding: embedding, payload, modified_at: new Date() })
.eq("id", commentNodeId);
if (error) {
this.context.logger.error("Error updating comment", error);
const comments = await this.getComment(commentNodeId);
if (comments && comments.length == 0) {
this.context.logger.info("Comment does not exist, creating a new one");
await this.createComment(markdown, commentNodeId, authorId, payload, isPrivate, issueId);
} else {
const { error } = await this.supabase
.from("issue_comments")
.update({ markdown, plaintext, embedding: embedding, payload, modified_at: new Date() })
.eq("id", commentNodeId);
if (error) {
this.context.logger.error("Error updating comment", error);
}
}
}

Expand Down
30 changes: 17 additions & 13 deletions src/adapters/supabase/helpers/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Issues extends SuperSupabase {
return;
} else {
const embedding = await this.context.adapters.voyage.embedding.createEmbedding(markdown);
let plaintext: string | null = markdownToPlainText(markdown || "");
let plaintext: string | null = markdownToPlainText(markdown);
if (isPrivate) {
payload = null;
markdown = null;
Expand All @@ -52,21 +52,24 @@ export class Issues extends SuperSupabase {
this.context.logger.info("Issue created successfully");
}

async updateIssue(markdown: string | null, issueNodeId: string, payload: Record<string, unknown> | null, isPrivate: boolean) {
//Create the embedding for this comment
async updateIssue(markdown: string | null, issueNodeId: string, payload: Record<string, unknown> | null, isPrivate: boolean, authorId: number) {
const embedding = Array.from(await this.context.adapters.voyage.embedding.createEmbedding(markdown));
let plaintext: string | null = markdownToPlainText(markdown || "");
let plaintext: string | null = markdownToPlainText(markdown);
if (isPrivate) {
markdown = null as string | null;
payload = null as Record<string, unknown> | null;
plaintext = null as string | null;
markdown = null;
payload = null;
plaintext = null;
}
const { error } = await this.supabase
.from("issues")
.update({ markdown, plaintext, embedding: embedding, payload, modified_at: new Date() })
.eq("id", issueNodeId);
if (error) {
this.context.logger.error("Error updating comment", error);
const issues = await this.getIssue(issueNodeId);
if (issues && issues.length == 0) {
this.context.logger.info("Issue does not exist, creating a new one");
await this.createIssue(issueNodeId, payload, isPrivate, markdown, authorId);
} else {
const { error } = await this.supabase.from("issues").update({ markdown, plaintext, embedding, payload, modified_at: new Date() }).eq("id", issueNodeId);

if (error) {
this.context.logger.error("Error updating comment", error);
}
}
}

Expand Down Expand Up @@ -96,6 +99,7 @@ export class Issues extends SuperSupabase {
current_id: currentId,
query_embedding: embedding,
threshold: threshold,
top_k: 5,
});
if (error) {
this.context.logger.error("Error finding similar issues", error);
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/add-issue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Context } from "../types";
import { IssuePayload } from "../types/payload";
import { removeFootnotes } from "./issue-deduplication";

export async function addIssue(context: Context) {
const {
Expand All @@ -16,7 +17,8 @@ export async function addIssue(context: Context) {
if (!markdown) {
throw new Error("Issue body is empty");
}
await supabase.issue.createIssue(nodeId, payload, isPrivate, markdown, authorId);
const cleanedIssue = removeFootnotes(markdown);
await supabase.issue.createIssue(nodeId, payload, isPrivate, cleanedIssue, authorId);
} catch (error) {
if (error instanceof Error) {
logger.error(`Error creating issue:`, { error: error, stack: error.stack });
Expand Down
Loading
Loading