freegate 0.6.1 → 0.6.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +23 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freegate",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Free multi-provider LLM gateway with automatic failover. One OpenAI-compatible endpoint routes to 25 free models (Groq, Mistral, Gemini, NIM, OpenRouter, ZAI, Cerebras, DeepSeek). Never pay for LLMs.",
5
5
  "license": "MIT",
6
6
  "bin": {
package/server.js CHANGED
@@ -130,10 +130,22 @@ async function handleChatCompletion(req, res, body) {
130
130
  // text as context — so a coding model handles the fix, not vision.
131
131
  const hasImage = Array.isArray(body.messages) && body.messages.some((m) => {
132
132
  if (Array.isArray(m.content)) {
133
- return m.content.some((c) => c && (c.type === 'image_url' || c.type === 'image'));
133
+ return m.content.some((c) => c && (c.type === 'image_url' || c.type === 'image' || c.type === 'file' || c.type === 'input_image'));
134
134
  }
135
135
  return false;
136
136
  });
137
+ // Debug: log raw message keys if any mention image/attachment/file
138
+ if (!hasImage && Array.isArray(body.messages)) {
139
+ for (const m of body.messages) {
140
+ if (m && typeof m === 'object' && (m.image || m.attachments || m.file || (Array.isArray(m.content) && m.content.some(c => c && c.image)))) {
141
+ logger.info('Vision debug: обнаружено изображение в другом формате', {
142
+ keys: Object.keys(m).slice(0, 8),
143
+ contentTypes: Array.isArray(m.content) ? m.content.map(c => c && c.type) : null,
144
+ });
145
+ break;
146
+ }
147
+ }
148
+ }
137
149
  if (hasImage) {
138
150
  // Two-stage pipeline: try vision providers in order until one extracts text.
139
151
  const visionChain = ['gemini-vision', 'nim-vision', 'deepseek-vision']
@@ -530,7 +542,16 @@ const server = http.createServer(async (req, res) => {
530
542
  }
531
543
 
532
544
  if (parsedUrl.pathname === '/v1/models') {
533
- const models = Object.entries(PROVIDERS).filter(([_, p]) => p.enabled).map(([key, p]) => ({ id: p.model, object: 'model', owned_by: key }));
545
+ const models = Object.entries(PROVIDERS)
546
+ .filter(([_, p]) => p.enabled)
547
+ .map(([key, p]) => ({
548
+ id: p.model,
549
+ object: 'model',
550
+ owned_by: key,
551
+ category: p.category || 'general',
552
+ vision: p.vision === true,
553
+ latency_ms: getHealth()[key]?.latency || null,
554
+ }));
534
555
  res.writeHead(200, { 'Content-Type': 'application/json' });
535
556
  res.end(JSON.stringify({ object: 'list', data: models }));
536
557
  return;