Skip to content

Commit

Permalink
fix code search scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stoerr committed Jul 31, 2024
1 parent 2aa1176 commit 40547e7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .cgptcodeveloper/.readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Folder for ChatGPT developers toolbench

See https://github.com/stoerr/DevelopersChatGPTToolBench . I use that to review and sometimes make changes
automatically from ChatGPT. This directory contains helper files, like actions that can be executed through ChatGPT.
10 changes: 10 additions & 0 deletions .cgptcodeveloper/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Plugin Action: maven build incl. running unit- and integrationtests
echo executing mvn clean install
mvn -B clean install > build.log 2>&1
if [ $? -ne 0 ]; then
echo "mvn clean install failed, see build.log. You can use the grep action with at least 10 context lines to look for errors and exceptions in file build.log"
exit 1
else
echo "successful; build log is in build.log"
exit 0
fi
8 changes: 8 additions & 0 deletions .cgptcodeveloper/listActions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Plugin Action: list all available actions
cd $(dirname $(realpath "$0")) || (
echo "ERROR: Could not cd to $(dirname $(realpath "$0"))"
exit 1
)
for fil in *.sh; do
echo "${fil%.sh} : " $(egrep -o "Plugin ""Action: .*" "$fil" | sed -e 's/Plugin ''Action: //')
done
10 changes: 10 additions & 0 deletions .cgptcodeveloper/llmsearch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Plugin Action: execute a LLM based search for the search string given as input
# echo executing a LLM based search
searchstring=$(cat)
echo "Searching for \"$searchstring\""

for type in md java js html jsp; do
bin/llmsearch.sh "$type" "$searchstring"
done | fgrep '{' | jq -c -s 'map(del(.[] | select(. == null))) | sort_by(.score) | reverse[]' | head -n 20

echo ...
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ target
*.orig
/tags

.cgptdevbench/llmsearch.db
.cgptcodeveloper/llmsearch.db
.linklint
.lycheecache
build.log
Expand Down
8 changes: 4 additions & 4 deletions bin/llmsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ cd $progdir

key=$1
shift
echo searching at key $1 for "$*"
echo searching at key "\"$key\"" for "\"$*\""

# if .cgptdevbench/llmsearch.db does not exist or is older than a week
# if .cgptcodeveloper/llmsearch.db does not exist or is older than a week
# then update it using bin/llmupdatedb.sh
if [[ ! -f .cgptdevbench/llmsearch.db ]] || [[ $(find .cgptdevbench/llmsearch.db -mtime +7) ]]; then
if [[ ! -f .cgptcodeveloper/llmsearch.db ]] || [[ $(find .cgptcodeveloper/llmsearch.db -mtime +7) ]]; then
# echo starting database update
bin/llmupdatedb.sh >& /dev/null
# echo finished database update
fi

llm similar $key -d .cgptdevbench/llmsearch.db -n 20 -c "$*" | fgrep -v /node_modules/
llm similar $key -d .cgptcodeveloper/llmsearch.db -n 20 -c "$*" | fgrep -v /node_modules/
12 changes: 7 additions & 5 deletions bin/llmupdatedb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ fi
progdir=$(dirname "$progfile")/..
cd $progdir

mkdir -p .cgptcodeveloper

# STORE="--store"
STORE=""

set -vx
llm embed-multi md -d .cgptdevbench/llmsearch.db -m minilm $STORE --files . '**/*.md'
llm embed-multi java -d .cgptdevbench/llmsearch.db -m minilm $STORE --files . '**/src/**/*.java'
llm embed-multi js -d .cgptdevbench/llmsearch.db -m minilm $STORE --files . '**/src/**/*.js'
llm embed-multi html -d .cgptdevbench/llmsearch.db -m minilm $STORE --files . '**/src/**/*.html'
llm embed-multi jsp -d .cgptdevbench/llmsearch.db -m minilm $STORE --files . '**/src/**/*.jsp'
llm embed-multi md -d .cgptcodeveloper/llmsearch.db -m minilm $STORE --files . '**/*.md'
llm embed-multi java -d .cgptcodeveloper/llmsearch.db -m minilm $STORE --files . '**/src/**/*.java'
llm embed-multi js -d .cgptcodeveloper/llmsearch.db -m minilm $STORE --files . '**/src/**/*.js'
llm embed-multi html -d .cgptcodeveloper/llmsearch.db -m minilm $STORE --files . '**/src/**/*.html'
llm embed-multi jsp -d .cgptcodeveloper/llmsearch.db -m minilm $STORE --files . '**/src/**/*.jsp'

0 comments on commit 40547e7

Please sign in to comment.