1.0.0 • Published 1 year ago

llm-wrapper v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

LLM Wrapper

A flexible wrapper for interacting with various Language Model providers.

Installation

npm install llm-wrapper

Usage

import { LLMService, LLMModel, LLMConfig } from 'llm-wrapper';

const config: LLMConfig = {
  provider: 'openai',
  model: LLMModel.GPT3_5,
  apiKey: process.env.OPENAI_API_KEY
};

const llm = new LLMService(config);

async function generateResponse(prompt: string) {
  const response = await llm.generateText(prompt);
  console.log(response);
}

generateResponse("Explain quantum computing in simple terms.");

Features

  • Unified interface for multiple LLM providers (OpenAI, Claude, etc.)
  • Easy switching between different models and providers
  • Support for text generation, image generation, speech-to-text, and text-to-speech (provider-dependent)
  • Secure API key management

API Key Management

This library does not handle the storage or management of API keys. Users are responsible for securely managing their own API keys. Here are some best practices:

  • Never hardcode API keys in your source code.
  • Use environment variables or secure secret management systems to store and retrieve API keys.
  • Ensure API keys are not logged or exposed in error messages.
  • Regularly rotate your API keys as per the provider's recommendations.

Supported Providers

  • OpenAI
  • Claude (Anthropic)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This library is not officially associated with or endorsed by OpenAI, Anthropic, or any other AI company. Use at your own risk and in compliance with the terms of service of the respective AI providers.