opencode-pollinations-plugin 5.3.3 → 5.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/proxy.js +17 -31
- package/package.json +1 -1
package/dist/server/proxy.js
CHANGED
|
@@ -301,15 +301,10 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
301
301
|
proxyBody.private = true;
|
|
302
302
|
if (proxyBody.stream_options)
|
|
303
303
|
delete proxyBody.stream_options;
|
|
304
|
-
// 3.6 STOP SEQUENCES (
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
//
|
|
308
|
-
// EXCEPTION: Azure OpenAI o1-preview/mini models do NOT support 'stop' param.
|
|
309
|
-
const isAzureO1 = actualModel.includes("o1") || actualModel.includes("azure");
|
|
310
|
-
if (!proxyBody.stop && !isAzureO1) {
|
|
311
|
-
proxyBody.stop = ["\nUser:", "\nModel:", "User:", "Model:"];
|
|
312
|
-
}
|
|
304
|
+
// 3.6 STOP SEQUENCES (-REMOVED-)
|
|
305
|
+
// We do NOT inject 'stop' automatically anymore.
|
|
306
|
+
// Azure OpenAI strictly rejects 'stop' for many models (o1, etc) and throws 400.
|
|
307
|
+
// We rely on the upstream model to handle stops, or the client to send it if needed.
|
|
313
308
|
// 3.5 PREPARE SIGNATURE HASHING
|
|
314
309
|
let currentRequestHash = null;
|
|
315
310
|
if (proxyBody.messages && proxyBody.messages.length > 0) {
|
|
@@ -331,12 +326,6 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
331
326
|
// A. AZURE/OPENAI FIXES
|
|
332
327
|
if (actualModel.includes("gpt") || actualModel.includes("openai") || actualModel.includes("azure")) {
|
|
333
328
|
proxyBody.tools = truncateTools(proxyBody.tools, 120);
|
|
334
|
-
if (actualModel.includes("o1") || actualModel.includes("azure")) {
|
|
335
|
-
if (proxyBody.stop)
|
|
336
|
-
delete proxyBody.stop; // Force remove if present
|
|
337
|
-
if (proxyBody.max_tokens)
|
|
338
|
-
delete proxyBody.max_tokens; // O1 uses max_completion_tokens
|
|
339
|
-
}
|
|
340
329
|
if (proxyBody.messages) {
|
|
341
330
|
proxyBody.messages.forEach((m) => {
|
|
342
331
|
if (m.tool_calls) {
|
|
@@ -360,32 +349,29 @@ export async function handleChatCompletion(req, res, bodyRaw) {
|
|
|
360
349
|
}
|
|
361
350
|
// B2. GEMINI FREE / FAST (CRASH FIX: STRICT SANITIZATION)
|
|
362
351
|
// Restore Tools but REMOVE conflicting ones (Search)
|
|
363
|
-
|
|
364
|
-
|
|
352
|
+
// B. GEMINI UNIFIED FIX (Free, Fast, Pro, Enterprise, Legacy)
|
|
353
|
+
// Handles: "tools" vs "grounding" conflicts, and "infinite loops" via Stop Sequences.
|
|
354
|
+
else if (actualModel.includes("gemini")) {
|
|
365
355
|
const hasFunctions = proxyBody.tools.some((t) => t.type === 'function' || t.function);
|
|
366
356
|
if (hasFunctions) {
|
|
367
|
-
// 1. Disable
|
|
357
|
+
// 1. Force Disable Built-in Grounding (Source of "Multiple tools" error if mixed)
|
|
368
358
|
proxyBody.tools_config = { google_search_retrieval: { disable: true } };
|
|
369
|
-
// 2.
|
|
359
|
+
// 2. Strict cleanup of 'google_search' tool from the functions list
|
|
360
|
+
// (If we send a function named 'google_search' AND tools_config, Vertex crashes)
|
|
370
361
|
proxyBody.tools = proxyBody.tools.filter((t) => {
|
|
371
362
|
const isFunc = t.type === 'function' || t.function;
|
|
372
363
|
const name = t.function?.name || t.name;
|
|
373
364
|
return isFunc && name !== 'google_search';
|
|
374
365
|
});
|
|
375
|
-
// 3. Ensure tools are Vertex-Compatible
|
|
376
|
-
proxyBody.tools = sanitizeToolsForVertex(proxyBody.tools);
|
|
377
|
-
log(`[Proxy] Gemini Free: Tools RESTORED but Sanitized (No Search/Grounding).`);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// B3. GEMINI ENTERPRISE 3.0+
|
|
381
|
-
else if (actualModel.includes("gemini")) {
|
|
382
|
-
const hasFunctions = proxyBody.tools.some((t) => t.type === 'function' || t.function);
|
|
383
|
-
if (hasFunctions) {
|
|
384
|
-
proxyBody.tools_config = { google_search_retrieval: { disable: true } };
|
|
385
|
-
// Keep Search Tool in List
|
|
386
|
-
proxyBody.tools = proxyBody.tools.filter((t) => t.type === 'function' || t.function);
|
|
366
|
+
// 3. Ensure tools are Vertex-Compatible (Schema Dereference)
|
|
387
367
|
proxyBody.tools = sanitizeToolsForVertex(proxyBody.tools);
|
|
368
|
+
// 4. INJECT STOP SEQUENCES (Fixes "Boucle"/Loop issues)
|
|
369
|
+
// Gemini 2.5/Flash can be chatty or ignore standard stop tokens.
|
|
370
|
+
if (!proxyBody.stop) {
|
|
371
|
+
proxyBody.stop = ["<|endoftext|>", "User:", "\nUser", "User :", "Model:"];
|
|
372
|
+
}
|
|
388
373
|
}
|
|
374
|
+
log(`[Proxy] Gemini Fix Applied: Grounding Disabled, Search Tool Removed, Stops Injected.`);
|
|
389
375
|
}
|
|
390
376
|
}
|
|
391
377
|
// C. GEMINI ID BACKTRACKING & SIGNATURE
|
package/package.json
CHANGED