Eine Regel kann `review N` tragen. Der Worker antwortet zuerst; junction hängt diese Antwort und einen festen Review-Prompt an dieselbe Konversation und schickt sie N-mal an denselben Endpoint/dasselbe Modell. Nur die letzte Fassung geht an den Client. Tool-Call-Antworten werden ungeprüft durchgereicht; scheitert eine Runde, bleibt die letzte gute Antwort. Streaming-Clients bekommen während der Runden SSE-Kommentare und danach die finale Antwort als Chunk + [DONE]; non-streaming ein JSON. Der Antwort-Cache ist für Review-Regeln aus, sonst käme eine ungeprüfte alte Antwort zurück. Antwort-Header für Judge und Review: X-Junction-Judge(-Step/-Every/-Model/-Served), X-Junction-Review(-Rounds/-Model/-Skipped). Bei Streams steht der geplante Judge/Review im Kopf; das tatsächliche Ergebnis steht im `junction`-Objekt des letzten Review-Chunks bzw. als SSE-Kommentar nach einem Judge-Stream. Tests: 429 OK, 0 FAIL.
58 lines
2.0 KiB
Makefile
58 lines
2.0 KiB
Makefile
# junction — C99 + POSIX. TLS is optional: an OpenSSL build adds https:// upstreams
|
|
# and a TLS listener; J_WITH_TLS=0 gives a dependency-free binary.
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Wpedantic -Wshadow -Wconversion
|
|
# _DEFAULT_SOURCE next to strict POSIX: without it glibc hides SO_REUSEPORT, and an
|
|
# #ifdef around a hidden constant compiles to nothing without a word — the symptom is
|
|
# "Address already in use" instead of two instances on one port.
|
|
CPPFLAGS += -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
|
|
CFLAGS += -pthread
|
|
LDFLAGS += -pthread
|
|
LDFLAGS ?=
|
|
PREFIX ?= /usr/local
|
|
J_WITH_TLS ?= auto
|
|
|
|
SRC = src/mesh.c src/mcp.c src/control.c src/control_ops.c src/compress.c src/price.c src/models.c src/config.c src/conn.c src/http.c src/cache.c src/opencode.c src/effort.c src/judge.c src/review.c src/junction.c
|
|
OBJ = $(SRC:.c=.o)
|
|
TOOLS = tools/junction-wol
|
|
|
|
ifeq ($(J_WITH_TLS),0)
|
|
TLS_LIBS =
|
|
else
|
|
ifeq ($(wildcard /usr/include/openssl/ssl.h),)
|
|
TLS_LIBS =
|
|
else
|
|
CPPFLAGS += -DJ_HAVE_TLS
|
|
TLS_LIBS = -lssl -lcrypto
|
|
endif
|
|
endif
|
|
|
|
all: junction $(TOOLS)
|
|
|
|
tools/junction-wol: tools/junction-wol.c
|
|
$(CC) -std=c99 -O2 -Wall -Wextra -Wpedantic $< -o $@
|
|
|
|
junction: $(OBJ)
|
|
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) $(TLS_LIBS)
|
|
|
|
src/%.o: src/%.c src/config.h src/conn.h src/http.h src/cache.h src/mcp.h src/control.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
test: junction
|
|
tests/run.sh
|
|
|
|
install: junction $(TOOLS)
|
|
install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/share/junction/hooks
|
|
install -m 0755 junction $(DESTDIR)$(PREFIX)/bin/junction
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/bin/junction-wol
|
|
install -m 0755 hooks/*.sh $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0755 $(TOOLS) $(DESTDIR)$(PREFIX)/share/junction/hooks/
|
|
install -m 0644 config.example $(DESTDIR)$(PREFIX)/share/junction/junction.conf
|
|
install -d $(DESTDIR)$(PREFIX)/share/junction/examples
|
|
install -m 0644 examples/*.conf $(DESTDIR)$(PREFIX)/share/junction/examples/
|
|
|
|
clean:
|
|
rm -f $(OBJ) junction $(TOOLS)
|
|
|
|
.PHONY: all test install clean
|