feat: in-process HTTP search; /get /stats /audit /ingest. (#13)
Tests / Test (push) Skipped
Tests / Release (semver) (push) Skipped
Tests / Test (push) Skipped
Tests / Release (semver) (push) Skipped
bin/brain/serve.go (ladybug tags) calls internal/brain instead of exec. HTTP tests inject a fake API so CI stays cgo-free. ExecSearcher remains the fallback when the binary is built without system_ladybug.
This commit is contained in:
committed by
GitHub
co-authored by
GitHub
parent
c1ee920b0a
commit
3f30052ea8
+19
-15
@@ -51,25 +51,13 @@ func runSearch(args []string) int {
|
||||
}
|
||||
defer closeBrain()
|
||||
|
||||
emb, err := embedQuery(query)
|
||||
hits, err := searchHits(query, root, repo, limit)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "embed: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "search: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
|
||||
fts, err := queryFTS(query, limit*3)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "fts: %v\n", err)
|
||||
return 1
|
||||
}
|
||||
|
||||
var vec []Hit
|
||||
if vec, err = queryVector(emb, limit*3); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "vec: %v\n", err)
|
||||
}
|
||||
|
||||
results := rank.RankAndFilter(fts, vec, root, repo, limit)
|
||||
|
||||
results := hits
|
||||
for i := range results {
|
||||
if results[i].Text != "" {
|
||||
runes := []rune(results[i].Text)
|
||||
@@ -97,6 +85,22 @@ func runSearch(args []string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func searchHits(query, root, repo string, limit int) ([]Hit, error) {
|
||||
emb, err := embedQuery(query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("embed: %w", err)
|
||||
}
|
||||
fts, err := queryFTS(query, limit*3)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fts: %w", err)
|
||||
}
|
||||
var vec []Hit
|
||||
if vec, err = queryVector(emb, limit*3); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "vec: %v\n", err)
|
||||
}
|
||||
return rank.RankAndFilter(fts, vec, root, repo, limit), nil
|
||||
}
|
||||
|
||||
func b2i(err error) int {
|
||||
if err != nil {
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user