diff --git a/CHANGELOG.md b/CHANGELOG.md index 804d814..edaa37f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- -## [0.8.4] - 2026-02-19 +## [0.8.4...0.8.5] - 2026-02-19 ### Added - **Visual Table Designer**: A robust, interactive UI for creating tables. Define columns, data types, constraints, and foreign keys visually without writing SQL. @@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improved - **Stability**: Fixed dashboard template loading issues to ensure reliable rendering on all platforms. +### Fixed +- https://github.com/dev-asterix/PgStudio/issues/56 - Resolved local AI model API implementation with support for http and custom port. + --- ## [0.8.3] - 2026-02-14 diff --git a/package.json b/package.json index ecd57f2..c7aa666 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "postgres-explorer", "displayName": "PgStudio (PostgreSQL Explorer)", - "version": "0.8.4", + "version": "0.8.5", "description": "PostgreSQL database explorer for VS Code with notebook support", "publisher": "ric-v", "private": false, diff --git a/src/providers/chat/AiService.ts b/src/providers/chat/AiService.ts index 6cd71bd..8cbd9c0 100644 --- a/src/providers/chat/AiService.ts +++ b/src/providers/chat/AiService.ts @@ -3,6 +3,7 @@ */ import * as vscode from 'vscode'; import * as https from 'https'; +import * as http from 'http'; import { ChatMessage } from './types'; export class AiService { @@ -212,16 +213,23 @@ Make these questions relevant to the topic discussed and progressively more adva async callDirectApi(provider: string, userMessage: string, config: vscode.WorkspaceConfiguration, customSystemPrompt?: string): Promise<{ text: string, usage?: string }> { const apiKey = config.get('aiApiKey'); - if (!apiKey) { + + // API key is required for most providers, but optional for custom endpoints + if (!apiKey && provider !== 'custom') { throw new Error(`API Key is required for ${provider} provider. Please configure postgresExplorer.aiApiKey.`); } let endpoint = ''; let model = config.get('aiModel'); let headers: any = { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${apiKey}` + 'Content-Type': 'application/json' }; + + // Only add Authorization header if API key is provided + if (apiKey) { + headers['Authorization'] = `Bearer ${apiKey}`; + } + let body: any = {}; const systemPrompt = customSystemPrompt !== undefined ? customSystemPrompt : this.buildSystemPrompt(); @@ -311,6 +319,7 @@ Make these questions relevant to the topic discussed and progressively more adva const options: https.RequestOptions = { hostname: url.hostname, + port: url.port || (url.protocol === 'https:' ? 443 : 80), path: url.pathname + url.search, method: 'POST', headers: { @@ -319,7 +328,8 @@ Make these questions relevant to the topic discussed and progressively more adva } }; - const req = https.request(options, (res) => { + const protocol = url.protocol === 'https:' ? https : http; + const req = protocol.request(options, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => {