Code Monkey home page Code Monkey logo

sourcegraph-natural-search's Introduction

alt text

Sourcegraph Natural Search

This is an experimental project that translates natural language queries to Sourcegraph syntax. Made this as a way of expanding my React and javascript skills

Uses Typechat to generate a valid json out of the LLM. In this case it uses the default typechat implementation to its restricted to OpenAI models or Azure.


Features:

Handles basic logic like AND or OR

Show me the diffs containing useMemo or useEffect on the sourcegraph cody repo in the last 6 months

returns:

after:"6 months ago" type:diff repo:^github\.com/sourcegraph/cody$ content:"useMemo" OR after:"6 months ago" type:diff repo:^github\.com/sourcegraph/cody$ content:"useEffect"

Expands well know git addresses from a basic keyword:

all the instances of task_struct data structure on the linux repo

returns

type:symbol repo:^github\.com/torvalds/linux$ content:"task_struct"

Identifies authors and handles basic timeframes

all diffs with task_struct by Linus in the linux repo on the last 2 years

returns

author:"Linus" after:"2 years ago" type:diff repo:^github\.com/torvalds/linux$ content:"task_struct"

Handles multiple human languages

For example, portuguese:

todos os diffs com task_struct feitos pelo Linus no repositório Linux nos últimos 2 anos

returns

author:"Linus" after:"2 years ago" type:diff repo:^github\.com/torvalds/linux$ task_struct


Known Limitations

Still needs to be nudged a bit in the right direction.

For example, mentioning "changes" not always results in "type:diff". Very rarely identifies symbols in the query as symbols, but if the symbol keyword is present, then the results are more predictable

Does not cover the whole syntax

Things like fork: or case: or file:hasOwner() are not yet covered.

Hallucinates some less known git repos

Like mentioning "sourcegraph cody repo" is intreperted as "sourcegraph/sourcegraph-cody" which does not exist. Mentioning the full path is recommended.

Is flaky identifying paths

When a path for something or folder is mentioned in the natural lang query, it sometimes adds it to the repo name

Has limited knowledge about dependencies between keywords

If a language is mentioned with the diff keyword, its going to output syntax with both, which is not ideal. It does however understand that for author: a type:commit or type:diff is needed


How to run

needs a .env file on server folder with:

OPENAI_MODEL="gpt-4"
OPENAI_API_KEY="sk-YOUR-TOKEN"

To run front-end:

yarn 
yarn dev

to build the server after changes:

cd server
npm run build

to run the server:

cd server
node server.js

sourcegraph-natural-search's People

Contributors

danielmarquespt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.