From 20a652e0ebce6fa7235d49da7efb45b662d7ea63 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 7 Dec 2024 14:35:03 +0700 Subject: [PATCH] chore: fix openai vision models --- extensions/inference-openai-extension/package.json | 2 +- extensions/inference-openai-extension/resources/models.json | 4 +++- extensions/inference-openai-extension/src/index.ts | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/inference-openai-extension/package.json b/extensions/inference-openai-extension/package.json index 9700383d63..d5b2a1d7a6 100644 --- a/extensions/inference-openai-extension/package.json +++ b/extensions/inference-openai-extension/package.json @@ -1,7 +1,7 @@ { "name": "@janhq/inference-openai-extension", "productName": "OpenAI Inference Engine", - "version": "1.0.4", + "version": "1.0.5", "description": "This extension enables OpenAI chat completion API calls", "main": "dist/index.js", "module": "dist/module.js", diff --git a/extensions/inference-openai-extension/resources/models.json b/extensions/inference-openai-extension/resources/models.json index a34bc54604..4d19654bc5 100644 --- a/extensions/inference-openai-extension/resources/models.json +++ b/extensions/inference-openai-extension/resources/models.json @@ -67,7 +67,9 @@ "version": "1.1", "description": "OpenAI GPT 4o is a new flagship model with fast speed and high quality", "format": "api", - "settings": {}, + "settings": { + "vision_model": true + }, "parameters": { "max_tokens": 4096, "temperature": 0.7, diff --git a/extensions/inference-openai-extension/src/index.ts b/extensions/inference-openai-extension/src/index.ts index 18bc4e0aae..2612ed8153 100644 --- a/extensions/inference-openai-extension/src/index.ts +++ b/extensions/inference-openai-extension/src/index.ts @@ -74,6 +74,11 @@ export default class JanInferenceOpenAIExtension extends RemoteOAIEngine { * @returns */ transformPayload = (payload: OpenAIPayloadType): OpenAIPayloadType => { + // Remove empty stop words + if (payload.stop?.length === 0) { + const { stop, ...params } = payload + payload = params + } // Transform the payload for preview models if (this.previewModels.includes(payload.model)) { const { max_tokens, stop, ...params } = payload