From 5044ccc67b16b3f842e5cb0433c30a9863665f06 Mon Sep 17 00:00:00 2001 From: David Kifer Date: Wed, 22 Jul 2026 17:14:50 -0400 Subject: [PATCH] Fix LM Studio response payload format compatibility --- .app.pid | 2 +- server.ts | 13 +++++++------ start.sh | 19 ++++++++----------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.app.pid b/.app.pid index 41fc841..e43e440 100644 --- a/.app.pid +++ b/.app.pid @@ -1 +1 @@ -95660 +96509 diff --git a/server.ts b/server.ts index c748a66..4814267 100644 --- a/server.ts +++ b/server.ts @@ -49,15 +49,16 @@ const callLMStudioCompletion = async ( headers["Authorization"] = `Bearer ${apiKey}`; } + const payload: any = { + model: modelName || "local-model", + messages, + temperature: 0.3 + }; + const response = await fetch(targetUrl, { method: "POST", headers, - body: JSON.stringify({ - model: modelName || "local-model", - messages, - temperature: 0.3, - response_format: { type: "json_object" } - }) + body: JSON.stringify(payload) }); if (!response.ok) { diff --git a/start.sh b/start.sh index 29e033e..6aaea62 100755 --- a/start.sh +++ b/start.sh @@ -5,24 +5,20 @@ APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PID_FILE="$APP_DIR/.app.pid" LOG_FILE="$APP_DIR/.app.log" -if [ -f "$PID_FILE" ]; then - PID=$(cat "$PID_FILE") - if kill -0 "$PID" 2>/dev/null; then - echo "AI Job Application server is already running (PID: $PID)." - echo "Access it at http://localhost:3000" - exit 0 - else - rm -f "$PID_FILE" - fi +# Clean up stale processes +PIDS=$(pgrep -f "tsx server.ts") +if [ -n "$PIDS" ]; then + kill -9 $PIDS 2>/dev/null fi +rm -f "$PID_FILE" echo "Starting AI Job Application server..." cd "$APP_DIR" || exit 1 -nohup npm run dev > "$LOG_FILE" 2>&1 & +nohup npx tsx server.ts > "$LOG_FILE" 2>&1 & SERVER_PID=$! echo "$SERVER_PID" > "$PID_FILE" -sleep 2 +sleep 3 if kill -0 "$SERVER_PID" 2>/dev/null; then echo "✓ Server successfully started (PID: $SERVER_PID)." echo "✓ App running at: http://localhost:3000" @@ -32,3 +28,4 @@ else rm -f "$PID_FILE" exit 1 fi +