The six-question form is gone. `splinter --interview` now opens the chat with an interview system prompt: get to know the person, one question at a time, then write a compact summary and end with INTERVIEW_COMPLETE. - the marker is captured in the engine's turn thread and in the synchronous -p path: the summary before it is written to ~/.splinter/USER.txt (0600), the marker is stripped from the answer and the conversation, and a "interview saved to USER.txt" note goes into the transcript. An installation from before USER.txt keeps working: profile/<user>.md is the fallback until the first new interview. - the USER.txt text is appended to the system prompt of every later session (plain "What you know about the user" block), including after /new and an agent switch (it rides in base_prompt). - --interview is a chat mode with the interview prompt and no agent profiles; it needs a provider like any chat. - Telegram: /interview swaps the system prompt, starts the conversation and restores the normal prompt once the summary is captured. The initial turn and every later reply are checked, so a model that summarizes immediately also works. - test_interview.sh now proves capture, marker-free USER.txt and the summary in the next request; test_gateway drives /interview and the fake model answers with the marker when the interview prompt is in the request. - docs (README, PLUGINS) describe the new flow. make check: all tests passed.
72 lines
2.5 KiB
Bash
Executable File
72 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# splinter -- the model-driven interview and what it leaves behind.
|
|
#
|
|
# The script transport stands in for the model: its answer carries a summary
|
|
# and INTERVIEW_COMPLETE. The summary must land in USER.txt, the marker must
|
|
# not, and the next run's system prompt must carry the summary.
|
|
set -u
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-iv-XXXXXX") || exit 1
|
|
port=18992
|
|
srv=
|
|
cleanup() { [ -n "$srv" ] && kill "$srv" 2>/dev/null; rm -rf "$D"; }
|
|
trap cleanup EXIT INT TERM
|
|
fails=0
|
|
check() { d=$1; shift; if "$@"; then :; else echo "FAIL $d"; fails=$((fails+1)); fi; }
|
|
|
|
mkdir -p "$D/home"
|
|
echo 'answer Summary: the user likes C99 and short answers. INTERVIEW_COMPLETE' > "$D/r1"
|
|
HOME="$D/home" ./splinter --no-config --model m --script "$D/r1" \
|
|
-p "interview me" > "$D/out1" 2>&1
|
|
check "the turn ran" test $? -eq 0
|
|
check "USER.txt was written" test -f "$D/home/.splinter/USER.txt"
|
|
check "the summary is in USER.txt" grep -q 'likes C99' "$D/home/.splinter/USER.txt"
|
|
check "the marker is not in USER.txt" sh -c "! grep -q INTERVIEW_COMPLETE '$D/home/.splinter/USER.txt'"
|
|
|
|
# the next run's request must carry USER.txt in the system prompt
|
|
python3 - "$D/req.json" <<'PY' &
|
|
import http.server, sys
|
|
out = sys.argv[1]
|
|
class H(http.server.BaseHTTPRequestHandler):
|
|
def log_message(self, *a):
|
|
pass
|
|
def do_POST(self):
|
|
n = int(self.headers.get("Content-Length", 0))
|
|
open(out, "wb").write(self.rfile.read(n))
|
|
b = b'data: {"choices":[{"delta":{"content":"ok"}}]}\n\ndata: [DONE]\n\n'
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "text/event-stream")
|
|
self.send_header("Content-Length", str(len(b)))
|
|
self.end_headers()
|
|
self.wfile.write(b)
|
|
http.server.ThreadingHTTPServer(("127.0.0.1", 18992), H).serve_forever()
|
|
PY
|
|
srv=$!
|
|
i=0
|
|
while [ $i -lt 50 ]; do
|
|
if python3 - "$port" <<'PY'
|
|
import socket, sys
|
|
s = socket.socket(); s.settimeout(0.2)
|
|
try:
|
|
s.connect(("127.0.0.1", int(sys.argv[1])))
|
|
except OSError:
|
|
sys.exit(1)
|
|
finally:
|
|
s.close()
|
|
PY
|
|
then
|
|
break
|
|
fi
|
|
i=$((i + 1)); sleep 0.1
|
|
done
|
|
|
|
HOME="$D/home" ./splinter --no-config --model m \
|
|
--endpoint "http://127.0.0.1:$port/v1/chat/completions" \
|
|
-p "hallo" > "$D/out2" 2>&1
|
|
check "the second turn ran" test $? -eq 0
|
|
check "the request carries USER.txt" grep -q 'What you know about the user' "$D/req.json"
|
|
check "the request carries the summary" grep -q 'likes C99' "$D/req.json"
|
|
|
|
if [ "$fails" -eq 0 ]; then echo "test_interview: ok"; exit 0; fi
|
|
exit 1
|