doclin-dev / doclin

Server and VS Code Extension of Doclin
https://doclin.dev
GNU Affero General Public License v3.0
44 stars 22 forks source link

Use Semantic Search for Copilot #136

Closed shawonibnkamal closed 3 weeks ago

shawonibnkamal commented 2 months ago

Description

Describe in detail what your pull request does and why.

Current implementation of copilot uses full text search of postgres. Which is ineffective to find relevant threads when user types a large prompt. So changed the implementation to use embeddings that will be generated for each threads. Then the prompt's embedding will be compared for the closest distance to find the relevant threads.

Also update copilot UI funcitonality. Needed to store history as cache locally. Added a check to allow users to not refer to doclin threads if needed and a check to allow users to refer to currently open code file

Screenshots or screen recordings

image

How to test the change

Outline the steps to set up and validate the change.


Check this if your PR is ready to merge and a reviewer will merge when approved.

shawonibnkamal commented 1 month ago

@taprottoy Can you review when get a chance?

taprottoy commented 1 month ago

getting this error when sending prompt

POST /organizations/462c0943-3dba-4333-a437-e1fbf479b28f/projects/1/copilot
Unable to load from local path "/Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/models/Xenova/all-MiniLM-L6-v2/tokenizer.json": "ReferenceError: Headers is not defined"
Unable to load from local path "/Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/models/Xenova/all-MiniLM-L6-v2/tokenizer_config.json": "ReferenceError: Headers is not defined"
Unable to load from local path "/Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/models/Xenova/all-MiniLM-L6-v2/config.json": "ReferenceError: Headers is not defined"
Error in createEmbedding: ReferenceError: Headers is not defined
    at getFile (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/utils/hub.js:185:25)
    at getModelFile (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/utils/hub.js:468:30)
    at async getModelJSON (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/utils/hub.js:572:18)
    at async Promise.all (index 0)
    at async loadTokenizer (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/tokenizers.js:61:18)
    at async Function.from_pretrained (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/tokenizers.js:4459:50)
    at async Promise.all (index 0)
    at async loadItems (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/pipelines.js:3279:5)
    at async pipeline (file:///Users/taprottoy/Desktop/prottoy/tp/doclin/api/node_modules/@xenova/transformers/src/pipelines.js:3219:21)
Uncaught Exception: Headers is not defined
[nodemon] app crashed - waiting for file changes before starting...
taprottoy commented 1 month ago

also throws this error when opening the copilot window for the first time.

copilotSidebar.js:4704 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'scroll')
    at scrollToBottom (copilotSidebar.js:4704:12)