Skip to content

feat: Add support for Ollama and Qdrant API keys - #4

Open
sealad886 wants to merge 1 commit into
anrgct:masterfrom
sealad886:master
Open

feat: Add support for Ollama and Qdrant API keys#4
sealad886 wants to merge 1 commit into
anrgct:masterfrom
sealad886:master

Conversation

@sealad886

Copy link
Copy Markdown
  • Updated package.json to include yargs and its types for argument parsing.
  • Enhanced configuration interfaces to support optional Ollama and Qdrant API keys.
  • Modified CLI argument parser to accept --ollama-api-key and --qdrant-api-key options.
  • Updated NodeConfigProvider to handle new API key configurations.
  • Enhanced CodeIndexConfigManager to store and validate Ollama API keys.
  • Updated Ollama embedder to include API key in requests.
  • Improved Qdrant client to handle API key authentication.
  • Added network capture utility to log HTTP requests to Qdrant and Ollama.
  • Implemented smoke tests for Qdrant connection and Ollama API key functionality.
  • Updated ConfigPanel to display masked API keys for security.

- Updated package.json to include yargs and its types for argument parsing.
- Enhanced configuration interfaces to support optional Ollama and Qdrant API keys.
- Modified CLI argument parser to accept --ollama-api-key and --qdrant-api-key options.
- Updated NodeConfigProvider to handle new API key configurations.
- Enhanced CodeIndexConfigManager to store and validate Ollama API keys.
- Updated Ollama embedder to include API key in requests.
- Improved Qdrant client to handle API key authentication.
- Added network capture utility to log HTTP requests to Qdrant and Ollama.
- Implemented smoke tests for Qdrant connection and Ollama API key functionality.
- Updated ConfigPanel to display masked API keys for security.
CopilotAI review requested due to automatic review settings November 21, 2025 21:15
@sealad886

Copy link
Copy Markdown
Author

Oh this also re-vamps CLI argument parsing so that it now imports yargs and uses that more common library instead of the big list of if-then checks that were there before.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for optional API key authentication for both Ollama and Qdrant services. The changes introduce CLI arguments (--ollama-api-key and --qdrant-api-key), update configuration interfaces to support API keys, and modify the HTTP clients to include Authorization headers when API keys are provided. The PR also includes smoke test utilities and updates the TUI ConfigPanel to display masked API keys for security.

Key Changes

  • Migrated CLI argument parsing from manual string parsing to yargs library for more robust argument handling
  • Added optional API key support for Ollama embeddings and Qdrant vector store with proper header configuration
  • Implemented API key masking in UI displays for security

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
FileDescription
package.jsonAdded yargs and @types/yargs dependencies for improved CLI argument parsing
package-lock.jsonUpdated lock file with yargs dependencies and transitive dependency changes
src/cli/args-parser.tsReplaced manual argument parsing with yargs library; added ollama-api-key and qdrant-api-key options
src/cli/tui-runner.tsUpdated to pass API key CLI overrides to configuration system
src/abstractions/config.tsAdded ollamaApiKey field to ConfigSnapshot interface
src/adapters/nodejs/config.tsEnhanced to handle API key CLI overrides for both Ollama and Qdrant
src/code-index/interfaces/config.tsAdded optional apiKey field to OllamaEmbedderConfig interface
src/code-index/config-manager.tsAdded ollamaApiKey storage and validation; updated restart detection logic
src/code-index/embedders/ollama.tsModified to include Authorization header when API key is provided
src/code-index/service-factory.tsUpdated to pass API key to Ollama embedder constructor
src/code-index/vector-store/qdrant-client.tsEnhanced constructor to set Authorization header for API key authentication
src/examples/tui/ConfigPanel.tsxAdded maskKey function and UI display for masked API keys
src/test-ollama-api-key.tsAdded basic smoke test for Ollama API key initialization (test doesn't verify actual behavior)
src/smoke-test-qdrant.tsAdded comprehensive smoke test for Qdrant connection with API key support
src/network-capture.tsAdded HTTP proxy utility for debugging/logging requests to Ollama and Qdrant
autodev-config.jsonUpdated example config to include apiKey and qdrantApiKey fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Create the captured request object
const captured: CapturedRequest = {
id: Math.random().toString(36).substr(2, 9),

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method substr() is deprecated. Use substring() or slice() instead.

Suggested change
id: Math.random().toString(36).substr(2,9),
id: Math.random().toString(36).slice(2,11),

Copilot uses AI. Check for mistakes.
export const ConfigPanel: React.FC<ConfigPanelProps> = ({ config, onConfigUpdate, onLog }) => {
const maskKey = (key?: string) => {
if (!key) return 'Not set';
if (key.length <= 3) return '*'.repeat(key.length);

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The masking logic exposes too much information for very short keys. For keys of length 3 or less, the entire key length is revealed through the number of asterisks. Consider using a fixed masking pattern (e.g., always show "..." or similar) to avoid leaking key length information.

Suggested change
if(key.length<=3)return'*'.repeat(key.length);
if(key.length<=3)return'**...**';

Copilot uses AI. Check for mistakes.
*/

import { createServer, IncomingMessage, ServerResponse } from 'http';
import { parse } from 'url';

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import parse.

Suggested change
import { parse } from 'url';

Copilot uses AI. Check for mistakes.

import { QdrantClient } from "@qdrant/js-client-rest";
import { fileURLToPath } from 'url';
import { dirname } from 'path';

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import dirname.

Suggested change
import { dirname } from 'path';

Copilot uses AI. Check for mistakes.
*/

import { CodeIndexOllamaEmbedder } from './code-index/embedders/ollama';
import { ApiHandlerOptions } from './shared/api';

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import ApiHandlerOptions.

Suggested change
import { ApiHandlerOptions } from './shared/api';

Copilot uses AI. Check for mistakes.

// Test 1: Initialize embedder without API key
console.log('\n📋 Test 1: Initialize embedder without API key');
const embedderWithoutKey = new CodeIndexOllamaEmbedder({

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable embedderWithoutKey.

Suggested change
constembedderWithoutKey=newCodeIndexOllamaEmbedder({
newCodeIndexOllamaEmbedder({

Copilot uses AI. Check for mistakes.

// Test 2: Initialize embedder with API key
console.log('\n📋 Test 2: Initialize embedder with API key');
const embedderWithKey = new CodeIndexOllamaEmbedder({

CopilotAINov 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable embedderWithKey.

Copilot uses AI. Check for mistakes.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@sealad886