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

Refactor db #16

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
879d3d7
chore: createComment
Keyrxng Sep 17, 2024
e769769
chore: refactor adapters
Keyrxng Sep 17, 2024
50dfaf2
chore: add proxy callbacks for cleaner context types
Keyrxng Sep 17, 2024
b59b298
chore: create-comment-embeddings
Keyrxng Sep 17, 2024
5366f26
chore: delete-comment-embeddings
Keyrxng Sep 17, 2024
1654da3
chore: update-comment-embeddings
Keyrxng Sep 17, 2024
991a2ae
chore: create-task-embeddings
Keyrxng Sep 17, 2024
5dd0813
chore: delete-task-embeddings
Keyrxng Sep 17, 2024
59eccc1
chore: update-task-embeddings
Keyrxng Sep 17, 2024
a1ab5bc
chore: task dedupe
Keyrxng Sep 17, 2024
a540b47
chore: types, guards
Keyrxng Sep 17, 2024
215ec6e
chore: tests
Keyrxng Sep 17, 2024
09be08a
chore: log and fix tests
Keyrxng Sep 17, 2024
d707c9f
chore: knip, format, logs, fix test
Keyrxng Sep 17, 2024
48349ff
chore: create upon edit if needed
Keyrxng Sep 17, 2024
44ea012
chore: fix test
Keyrxng Sep 17, 2024
6f009de
chore: minor changes
Keyrxng Sep 30, 2024
ed80e8d
Merge remote-tracking branch 'upstream/development' into refactor-db
Keyrxng Sep 30, 2024
f34d03a
chore: refactor matchmaking into proxy callback, fix tests
Keyrxng Sep 30, 2024
44e36f4
chore: status > statusCode
Keyrxng Sep 30, 2024
18859db
chore: remove packageManager
Keyrxng Sep 30, 2024
3246324
chore(deps): add supabase cli
Keyrxng Sep 30, 2024
ee708ef
chore: content table migration
Keyrxng Sep 30, 2024
2915e70
chore: remove migrations
Keyrxng Sep 30, 2024
88489d8
chore: remove const fn, update db fn, update findSimilarContent
Keyrxng Sep 30, 2024
9516584
chore: remove log reliance from test
Keyrxng Sep 30, 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 .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ jobs:
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 18 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

## 1.0.0 (2024-09-01)


### Features

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

- modified tests ([97e267f](https://github.com/ubiquibot/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/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))
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
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.

## Configuration

- Host the plugin on a server that Ubiquibot can access.
To set up the `.dev.vars` file, you will need to provide the following variables:
To set up the `.dev.vars` file, you will need to provide the following variables:
- `SUPABASE_URL`: The URL for your Supabase instance.
- `SUPABASE_KEY`: The key for your Supabase instance.
- `VOYAGEAI_API_KEY`: The API key for Voyage.

## Usage

- Add the following to your `.ubiquibot-config.yml` file with the appropriate URL:

```yaml
- plugin: https://ubiquity-os-comment-vector-embeddings-main.ubiquity.workers.dev
with:
Expand All @@ -19,11 +22,12 @@ To set up the `.dev.vars` file, you will need to provide the following variables
jobMatchingThreshold: 0.75
```


## Testing Locally

- Run `yarn install` to install the dependencies.
- Run `yarn worker` to start the server.
- Make HTTP requests to the server to test the plugin with content type `Application/JSON`

```
{
"stateId": "",
Expand All @@ -37,7 +41,7 @@ To set up the `.dev.vars` file, you will need to provide the following variables
"id": <UNIQUE_COMMENT_ID>
},
"repository" : {
"name" : "REPONAME",
"name" : "REPO_NAME",
"owner":{
"login" : "USERNAME"
}
Expand All @@ -53,7 +57,9 @@ To set up the `.dev.vars` file, you will need to provide the following variables
"authToken": ""
}
```

- Replace the placeholders with the appropriate values.

## Testing

- Run `yarn test` to run the tests.
10 changes: 9 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"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"
]
}
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 5000",
"worker": "wrangler dev --env dev --port 4000",
"supabase:generate:local": "supabase gen types typescript --local > src/types/database.ts",
"supabase:generate:remote": "cross-env-shell \"supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/types/database.ts\""
},
Expand Down Expand Up @@ -69,7 +69,7 @@
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"supabase": "1.200.3",
"supabase": "^1.200.3",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
Expand All @@ -89,6 +89,5 @@
"extends": [
"@commitlint/config-conventional"
]
},
"packageManager": "[email protected]"
}
}
}
14 changes: 2 additions & 12 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "../types";
import { Comment } from "./supabase/helpers/comment";
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 { Embeddings } from "./supabase/helpers/embeddings";

export function createAdapters(supabaseClient: SupabaseClient, voyage: VoyageAIClient, context: Context) {
return {
supabase: {
comment: new Comment(supabaseClient, context),
issue: new Issues(supabaseClient, context),
super: new SuperSupabase(supabaseClient, context),
},
voyage: {
embedding: new VoyageEmbedding(voyage, context),
super: new SuperVoyage(voyage, context),
embeddings: new Embeddings(voyage, supabaseClient, context),
},
};
}
89 changes: 0 additions & 89 deletions src/adapters/supabase/helpers/comment.ts

This file was deleted.

Loading