fix: add max_tokens default and mock web-search endpoint for demo
- Inject max_tokens: 4096 in Claude API proxy when AIUI omits it - Add /aiui/api/web-search stub returning empty results (no search backend in demo) - Add nginx proxy rule for web-search endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,14 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
# Proxy AIUI API requests (web-search, claude) to backend
|
||||
location /aiui/api/web-search {
|
||||
proxy_pass http://neode-backend:5959;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
# Proxy Claude API requests to backend (which handles API key + streaming)
|
||||
location /aiui/api/claude/ {
|
||||
proxy_pass http://neode-backend:5959;
|
||||
|
||||
@@ -1017,6 +1017,12 @@ app.get('/app/filebrowser/api/raw/*', (req, res) => {
|
||||
})
|
||||
|
||||
// =============================================================================
|
||||
// AIUI Web Search stub (demo mode — no real search backend)
|
||||
// =============================================================================
|
||||
app.get('/aiui/api/web-search', (req, res) => {
|
||||
res.json({ results: [] })
|
||||
})
|
||||
|
||||
// Claude API Proxy (reads ANTHROPIC_API_KEY from environment)
|
||||
// =============================================================================
|
||||
import https from 'https'
|
||||
@@ -1031,7 +1037,14 @@ app.post('/aiui/api/claude/*', (req, res) => {
|
||||
}
|
||||
|
||||
const apiPath = '/' + req.params[0]
|
||||
const bodyStr = JSON.stringify(req.body)
|
||||
|
||||
// Ensure max_tokens is set — Claude API requires it but AIUI may omit it
|
||||
const body = req.body
|
||||
if (body && !body.max_tokens) {
|
||||
body.max_tokens = 4096
|
||||
}
|
||||
|
||||
const bodyStr = JSON.stringify(body)
|
||||
|
||||
const options = {
|
||||
hostname: 'api.anthropic.com',
|
||||
@@ -1098,7 +1111,7 @@ wss.on('connection', (ws, req) => {
|
||||
const heartbeatInterval = setInterval(() => {
|
||||
if (ws.readyState === 1) {
|
||||
try {
|
||||
ws.send(JSON.stringify({ rev: Date.now(), patch: [] }))
|
||||
ws.send(JSON.stringify({ type: 'heartbeat', rev: Date.now() }))
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}, 45000) // Every 45s (client expects data within 60s)
|
||||
|
||||
Reference in New Issue
Block a user