kaiban-ai / KaibanJS

KaibanJS is a JavaScript-native framework for building and managing multi-agent systems with a Kanban-inspired approach.
https://www.kaibanjs.com/
MIT License
453 stars 24 forks source link

Feature/llm gateway #79

Closed darielnoel closed 1 month ago

darielnoel commented 1 month ago

Secure API Key Management and LLM Proxy Integration

Description

This PR addresses the critical issue of secure API key management in frontend applications, as outlined in Issue #78. It implements a solution that allows developers to securely handle API keys for various LLM providers without exposing them in client-side code.

Changes

  1. Enhanced BaseAgent class with improved normalizeLlmConfig method:

    • Standardizes configuration across different LLM providers
    • Supports custom apiBaseUrl for each provider
    • Maintains flexibility for rapid prototyping and production environments
  2. Integration with Kaiban LLM Proxy:

    • Demonstrates secure routing of API requests
    • Provides example implementation for OpenAI, Anthropic, Google Gemini, and Mistral

Usage Example

const agent = new Agent({
   name: 'AI Assistant',
   role: 'Helper',
   llmConfig: {
      provider: "openai",
      apiBaseUrl: "http://localhost:3000/llm/openai",
      model: "gpt-4",
   }
});

Benefits

Testing

Documentation

Related