mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
* feat: Ollama and LM Studio chat via OpenAI-compatible streaming API - Add ollama/lmstudio cases to ChatProvider with isLocal, pillID, init?(pillID:) - Add LocalChat helpers: normaliseURL, parseSSEDelta, filterThinkingBlocks - Stream local responses token-by-token via URLSession.bytes - Add ai_ollama (#FACC15) and ai_lmstudio (#A3E635) pills to PillCatalog - Add server URL settings in Settings → Chat (Local models GroupBox) - NSAllowsLocalNetworking in both Info.plist targets Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: Markdown rendering in chat assistant responses - Add ChatMarkdown block parser (Foundation only) and ChatMarkdownView renderer - ChatBubble uses ChatMarkdownView for assistant messages - Update system prompt to allow markdown formatting - Add ChatMarkdown/LocalChat test suite with compile-and-run script - Add test-chat-parsing step to CI build workflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: move local model networking into LocalChat, add fake server e2e tests - Add LocalChatError typed enum (serverUnreachable, modelNotFound, serverError) - Add LocalChat.fetchModels with embedding model filter (nomic-embed, bge, etc.) - Add LocalChat.streamChat: full SSE streaming with typed error handling - Add LocalChat.progressiveFilter for partial think-block suppression - ClaudeService delegates local streaming entirely to LocalChat.streamChat - Add tests/fake_local_llm.py: stdlib Python server with think blocks, null-content deltas, model filter, unknown model 404, and Markdown streaming - ChatParsingTests: unit tests + 4 end-to-end tests against fake server - test-chat-parsing.sh starts/stops fake server with port-file handoff Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Local model connect flow, Markdown improvements, and docs update Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix pill hints, local model error flow, streaming scroll, and docs polish Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Make the chat test server start reliably on CI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.8 KiB
Bash
Executable File
45 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-chat-parsing.XXXXXX")"
|
|
SERVER_PID=""
|
|
trap 'rm -rf "$TEST_DIR"; [ -n "$SERVER_PID" ] && kill "$SERVER_PID" 2>/dev/null || true' EXIT
|
|
|
|
PORT_FILE="$TEST_DIR/port.txt"
|
|
|
|
# ── Start fake LLM server ────────────────────────────────────────────────────
|
|
python3 tests/fake_local_llm.py "$PORT_FILE" &
|
|
SERVER_PID=$!
|
|
|
|
# ── Compile test binary (runs in parallel with server startup) ───────────────
|
|
# Compilation typically takes a few seconds, which gives the server plenty of
|
|
# time to bind and write its port — avoiding a busy-wait on fast machines.
|
|
swiftc \
|
|
NotchBuddy/Sources/App/LocalChat.swift \
|
|
NotchBuddy/Sources/App/ChatMarkdown.swift \
|
|
tests/ChatParsingTests.swift \
|
|
-o "$TEST_DIR/chat-parsing-tests"
|
|
|
|
# ── Wait for server port file (up to 30 s) ───────────────────────────────────
|
|
for i in $(seq 1 300); do
|
|
# Bail out immediately if the server process has already died
|
|
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
|
echo "ERROR: fake LLM server process exited unexpectedly" >&2
|
|
exit 1
|
|
fi
|
|
[ -s "$PORT_FILE" ] && break
|
|
sleep 0.1
|
|
done
|
|
|
|
if [ ! -s "$PORT_FILE" ]; then
|
|
echo "ERROR: fake LLM server did not write its port within 30 s" >&2
|
|
exit 1
|
|
fi
|
|
|
|
PORT=$(cat "$PORT_FILE")
|
|
echo "Fake LLM server listening on port $PORT (PID $SERVER_PID)"
|
|
|
|
# ── Run tests ────────────────────────────────────────────────────────────────
|
|
"$TEST_DIR/chat-parsing-tests" "$PORT"
|