Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ docker run -d -p 3000:3000 \
bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/scripts/setup.sh)
```

### Build locally and push to the remote server and running using Docker

To run the script, use the deploy-local-build.sh file located in the scripts folder as a reference. Be sure to update the environment variables and server-related information as needed.

## Synchronizing Chat Records (UpStash)

| [简体中文](./docs/synchronise-chat-logs-cn.md) | [English](./docs/synchronise-chat-logs-en.md) | [Italiano](./docs/synchronise-chat-logs-es.md) | [日本語](./docs/synchronise-chat-logs-ja.md) | [한국어](./docs/synchronise-chat-logs-ko.md)
Expand Down
15 changes: 7 additions & 8 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,11 @@ const openaiModels = [
"gpt-4-turbo-2024-04-09",
"gpt-4-1106-preview",
"dall-e-3",
"o1-mini",
"o1-preview",
"o1",
"o1-pro",
"o3-mini",
"o3",
"o3-pro",
"o4-mini",
];
Comment on lines +530 to 536
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Keep ancillary metadata in sync with the new model IDs

  1. o1, o1-pro, o3-pro, gemini-2.5-flash, gemini-2.5-pro, claude-opus-4-20250514, and claude-sonnet-4-20250514 are now surfaced to the UI but:
    KnowledgeCutOffDate lacks entries for all of these newcomers, while it still contains the now-removed o1-mini* and o1-preview*.
    VISION_MODEL_REGEXES does not cover o1*/o3-pro; if they are multimodal they will silently lose image-upload UI affordances.
    • Any downstream “preferred default model” or “fast-path fall-backs” lists (e.g. SUMMARIZE_MODEL) were not revisited.

  2. Risk: users may pick a model that later hits missing metadata branches or loses expected features; the mis-aligned regex may break vision support.

+  "o1":            "2023-10",
+  "o1-pro":        "2023-10",
+  "o3-pro":        "2023-10",
+  "gemini-2.5-flash": "2024-06",
+  "gemini-2.5-pro":   "2024-06",
+  "claude-opus-4-20250514":   "2024-06",
+  "claude-sonnet-4-20250514": "2024-06",

and extend the VISION_MODEL_REGEXES:

   /o3/,
+  /o1/,
+  /o3-pro/,

Also cull the stale o1-mini* / o1-preview* constants to avoid dead-code drift.

Also applies to: 557-559, 571-573


#!/bin/bash
# Check KnowledgeCutOffDate entries
rg -n "KnowledgeCutOffDate" -C5 app/constant.ts

# Check vision model regexes
rg -n "VISION_MODEL_REGEXES" -C5 app/constant.ts

# Check summarize model defaults/fallbacks
rg -n "SUMMARIZE_MODEL" -C5 app/constant.ts

🏁 Script executed:

# Search for KnowledgeCutOffDate entries
rg -n "KnowledgeCutOffDate" -C5 app/constant.ts

# Search for VISION_MODEL_REGEXES definitions
rg -n "VISION_MODEL_REGEXES" -C5 app/constant.ts

# Search for SUMMARIZE_MODEL defaults or fallbacks
rg -n "SUMMARIZE_MODEL" -C5 app/constant.ts

Length of output: 1989


Sync ancillary metadata & regexes for new model IDs

The UI now surfaces these new models but their metadata and vision support aren’t fully wired up. In app/constant.ts:

• In KnowledgeCutOffDate (around lines 427–462):
– Add missing entries for the new IDs with their cutoff dates:
"o1-pro": "2023-10"
"o3": "2023-10"
"o3-pro": "2023-10"
"o4-mini": "2023-10"
"gemini-2.5-flash": "2024-06"
"gemini-2.5-pro": "2024-06"
"claude-opus-4-20250514": "2024-06"
"claude-sonnet-4-20250514": "2024-06"

• In VISION_MODEL_REGEXES (around lines 478–495):
– Extend the array to cover the new IDs:
+ /o1/,
+ /o3-pro/,

• Review any “preferred default” or “fast-path” constants (e.g. SUMMARIZE_MODEL, GEMINI_SUMMARIZE_MODEL) to ensure they still make sense now that these new models are available.

🤖 Prompt for AI Agents
In app/constant.ts around lines 427 to 462, add the missing KnowledgeCutOffDate
entries for the new model IDs with their respective cutoff dates as specified.
Then, around lines 478 to 495, extend the VISION_MODEL_REGEXES array to include
regex patterns for the new model IDs like /o1/ and /o3-pro/. Finally, review and
update any preferred default or fast-path constants such as SUMMARIZE_MODEL and
GEMINI_SUMMARIZE_MODEL to ensure they remain appropriate given the addition of
these new models.


Expand All @@ -553,15 +554,11 @@ const googleModels = [
"gemini-2.0-flash-thinking-exp-01-21",
"gemini-2.0-pro-exp",
"gemini-2.0-pro-exp-02-05",
"gemini-2.5-pro-preview-06-05",
"gemini-2.5-flash",
"gemini-2.5-pro",
];

const anthropicModels = [
"claude-instant-1.2",
"claude-2.0",
"claude-2.1",
"claude-3-sonnet-20240229",
"claude-3-opus-20240229",
"claude-3-opus-latest",
"claude-3-haiku-20240307",
"claude-3-5-haiku-20241022",
Expand All @@ -571,6 +568,8 @@ const anthropicModels = [
"claude-3-5-sonnet-latest",
"claude-3-7-sonnet-20250219",
"claude-3-7-sonnet-latest",
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
];

const baiduModels = [
Expand Down
53 changes: 53 additions & 0 deletions scripts/deploy-local-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Configuration
SERVER_USER="YOUR_USERNAME" # Replace with your server's username
SERVER_IP="YOUR_SERVER_IP" # Replace with your server's IP address
IMAGE_NAME="nextchat"
TAG="latest"
TAR_FILE="nextchat-image.tar"

Comment on lines +1 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add a proper shebang and quote configurable values

Without #!/usr/bin/env bash the script’s target shell is unknown (SC2148) and may be executed by /bin/sh, breaking [[ … ]] or arrays if later added.
Unquoted variables (${SERVER_USER}, ${SERVER_IP}, ${IMAGE_NAME} …) invite word-splitting when they contain spaces or wildcard characters.

-# Configuration
+#/usr/bin/env bash
+# ---------------- Configuration ----------------
+set -euo pipefail
+
 SERVER_USER="YOUR_USERNAME"  # Replace with your server's username
 SERVER_IP="YOUR_SERVER_IP"   # Replace with your server's IP address
 IMAGE_NAME="nextchat"
 TAG="latest"
 TAR_FILE="nextchat-image.tar"

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Shellcheck (0.10.0)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

🤖 Prompt for AI Agents
In scripts/deploy-local-build.sh at lines 1 to 7, add the shebang line
#!/usr/bin/env bash at the very top to specify the script interpreter
explicitly. Also, enclose all variable assignments for SERVER_USER, SERVER_IP,
IMAGE_NAME, TAG, and TAR_FILE in double quotes to prevent word splitting and
globbing issues when these variables are used later in the script.

echo "Building NextChat Docker image locally..."

# Build the Docker image locally for AMD64 platform, change as needed
docker build --platform linux/amd64 -t ${IMAGE_NAME}:${TAG} .

if [ $? -ne 0 ]; then
echo "Docker build failed!"
exit 1
fi

echo "Saving Docker image to tar file..."
# Save the image to a tar file
docker save -o ${TAR_FILE} ${IMAGE_NAME}:${TAG}

echo "Transferring image to server..."
# Transfer the tar file to server
scp ${TAR_FILE} ${SERVER_USER}@${SERVER_IP}:/tmp/

echo "Loading image on server and running container..."
# SSH to server and load the image, then run it, change the environment variables as needed
ssh ${SERVER_USER}@${SERVER_IP} << EOF
# Load the Docker image
docker load -i /tmp/${TAR_FILE}

# Stop existing container if running
docker stop nextchat 2>/dev/null || true
docker rm nextchat 2>/dev/null || true

# Run the new container
docker run -d -p 3000:3000 \\
--name nextchat \\
-e OPENAI_API_KEY=sk-xxxx \\
-e CODE=your-password \\
${IMAGE_NAME}:${TAG}
Comment on lines +28 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Here-document expands on the local machine, not the server

Because the EOF delimiter is not quoted, every $VAR inside the block is interpolated before the SSH command is sent.
$SERVER_IP (used in the final printf) therefore becomes an empty string on the server side. If you intend expansion remotely, quote the delimiter (<<'EOF'). If you intend local expansion, remove $SERVER_IP from the remote echo.

-ssh ${SERVER_USER}@${SERVER_IP} << EOF
+ssh "${SERVER_USER}@${SERVER_IP}" <<'EOF'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ssh ${SERVER_USER}@${SERVER_IP} << EOF
# Load the Docker image
docker load -i /tmp/${TAR_FILE}
# Stop existing container if running
docker stop nextchat 2>/dev/null || true
docker rm nextchat 2>/dev/null || true
# Run the new container
docker run -d -p 3000:3000 \\
--name nextchat \\
-e OPENAI_API_KEY=sk-xxxx \\
-e CODE=your-password \\
${IMAGE_NAME}:${TAG}
ssh "${SERVER_USER}@${SERVER_IP}" <<'EOF'
# Load the Docker image
docker load -i /tmp/${TAR_FILE}
# Stop existing container if running
docker stop nextchat 2>/dev/null || true
docker rm nextchat 2>/dev/null || true
# Run the new container
docker run -d -p 3000:3000 \\
--name nextchat \\
-e OPENAI_API_KEY=sk-xxxx \\
-e CODE=your-password \\
${IMAGE_NAME}:${TAG}
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 28-28: Quote 'EOF' to make here document expansions happen on the server side rather than on the client.

(SC2087)

🤖 Prompt for AI Agents
In scripts/deploy-local-build.sh around lines 28 to 41, the here-document used
with ssh is unquoted, causing all variables inside it to be expanded locally
instead of on the remote server. To fix this, quote the EOF delimiter as <<'EOF'
to prevent local expansion and ensure variables like $SERVER_IP are expanded on
the server side. Alternatively, if local expansion is intended, remove
$SERVER_IP from the remote commands inside the here-document.


# Clean up the tar file
rm -f /tmp/${TAR_FILE}

echo "NextChat is now running on port 3000!"
echo "You can access it at: http://${SERVER_IP}:3000"
EOF

# Clean up local tar file
rm -f ${TAR_FILE}

echo "Deployment complete!"