Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/cli/corpus_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ def federated_corpora():
try:
col = client.get_collection(name=collection_name_for(sub))
except Exception:
# An image has no spear-index: a tree is indexed from a session.

how = (f"open a session in {sub['path']} and run /reindex"
if SHIPPED_DB_PATH else f"spear-index {sub['path']}")
print(f"{C_WARN}corpus '{n}' has no index yet "
f"({collection_name_for(sub)}) — index it with: "
f"spear-index {sub['path']}{C_RST}")
f"({collection_name_for(sub)}) — index it with: {how}{C_RST}")
continue

out.append((col, corpus_prefix(sub["path"])))
Expand Down
33 changes: 27 additions & 6 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,46 @@ print(f"corpora: {found} present, {miss} missing "
# packaging fault, not a user choice. Unchecked, the harness says "no index
# for this corpus yet (optional)" and starts with no retrieval at all -- which
# is the entire reason the tool exists.
import json
import textwrap

have = {c.name for c in corpus_search._db().list_collections()}
absent = sorted(n for n, spec in corpus_registry.load_projects().items()
if os.path.isdir(spec["path"])
and corpus_search.collection_name_for(spec) not in have)
if absent:

# The image's own corpora and the ones the user registered are two cases: the
# first without an index is a fault of the image, the second is a tree nobody
# has indexed yet.

try:
with open(corpus_registry.PROJECTS_FILE) as handle:
shipped = set(json.load(handle))
except (OSError, ValueError):
shipped = set()

faulty = [n for n in absent if n in shipped]
unindexed = [n for n in absent if n not in shipped]

if faulty:
# Every name, not the first six. Announcing 11 and listing 6 reads as a
# bug in the count -- the reader cannot tell which five are missing from
# the list, and the whole point of the line is to say which corpora will
# answer without retrieval.
print(f" WARNING: {len(absent)} mounted corpora have no collection in the "
f"baked index:")
for line in textwrap.wrap(", ".join(absent), 72):
print(f" WARNING: {len(faulty)} corpora of this image have no collection "
f"in its index:")
for line in textwrap.wrap(", ".join(faulty), 72):
print(f" {line}")
print(" They will answer without retrieval. Re-index on the host and "
"rebuild (scripts/docker/build.sh).")
"rebuild the image.")
else:
print(f"index: every mounted corpus has its collection ({len(have)} total)")
print(f"index: every corpus of the image has its collection ({len(have)} total)")

if unindexed:
print(f" {len(unindexed)} of your own corpora are not indexed yet:")
for line in textwrap.wrap(", ".join(unindexed), 72):
print(f" {line}")
print(" To index one: cd into its tree, spear-chat, then /reindex.")
PY

# The normative store. An image that carries a standard nothing is bound to
Expand Down
25 changes: 25 additions & 0 deletions docker/spear-chat
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,29 @@ case " $* " in
&& MODEL=(--provider "$SPEAR_CHAT_PROVIDER" ${SPEAR_CHAT_MODEL:+--model "$SPEAR_CHAT_MODEL"}) ;;
esac

# With no model named anywhere the session would open on a local server that
# is not there, and only say so at the first question.

case " $* " in
*" --provider"*|*" --api-base"*|*" --reds "*|*" --remote "*|*" --local "*|*" --help "*|*" -h "*) ;;
*) if [ -z "$SPEAR_CHAT_PROVIDER" ] && [ -z "$SPEAR_API_BASE" ]; then
cat >&2 <<'MSG'
spear-chat: no model is configured, so SPEAR could not answer.

Leave this shell, name the model in ~/.config/spear/local.conf on your
machine, and run spear-run.sh again:

SPEAR_PROVIDER=anthropic a hosted model, with its key
SPEAR_MODEL=<model name>
ANTHROPIC_API_KEY=<key>

or REDS_HOST=<account>@<host> an inference host reached through ssh
SPEAR_REDS_KEY=<ssh identity file>

`claude` needs none of this: it logs in with your own account.
MSG
exit 1
fi ;;
esac

exec /opt/spear/entrypoint.sh "${MODEL[@]}" "$@"
Loading