Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

The REST search endpoint

Reports the mode it actually used, its candidates and its timings.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

search_codebackend/app/modules/code/router.py, lines 220–238Open source
@router.post("/search/code", response_model=SearchResponse)def search_code(body: SearchRequest, db: Session = Depends(get_sync_db)):    """Chunk-level retrieval. ``mode=auto`` reports what it actually used."""    filters = _filters(db, body.repository, body.languages, body.kinds, body.path_prefix)    try:        outcome = Retriever(db, get_embedder()).search(body.query, mode=body.mode, k=body.k, filters=filters,                                                       hints=body.hints)    except ModeUnavailable as exc:        raise _mode_unavailable(exc) from exc    return SearchResponse(        query=outcome.query,        mode_requested=outcome.mode_requested,        mode_used=outcome.mode_used,        embedding_model=outcome.embedding_model,        warnings=outcome.warnings,        results=[hit_to_dict(h, i) for i, h in enumerate(outcome.hits, start=1)],        timings_ms=outcome.timings_ms,        candidates=outcome.candidates,    )

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/modules/code/router.py
Lines
220–238
Git blob
d914024790aaafe7234adda557677b76e4ad73d5
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/modules/code/router.py
git show 975a38d:backend/app/modules/code/router.py | sed -n '220,238p'