Skip to main content

A package for generating code using various AI models.

Project description

PilotHub

Pilot Aggregator is a Python package designed to streamline the aggregation of data from multiple sources. Built with efficiency and flexibility in mind, this package allows developers to easily collect, process, and manage data in a unified manner.

Features

  • Unified API Configuration: Easily configure API keys for different LLMs.
  • LLM Integration: Seamlessly switch between different LLMs (e.g., OpenAI, Gemini, Mistral) for text and code generation.
  • Code Generation: Generate Python code based on prompts using the specified LLM.
  • Text Generation: Generate detailed text responses based on prompts using the specified LLM.
  • Extensible Design: Easily add support for more LLMs in the future.

Installation

You can install the package using pip:

pip install llm-integrator

Getting Started

1. Configure API Keys

Before using the LLMs, you need to set the API keys. The package provides utility functions in config.py to set and retrieve these keys.

Example:

from llm_integrator.config import set_openai_api_key, set_google_api_key, set_mistral_api_key

# Set the OpenAI API key
set_openai_api_key('your-openai-api-key')

# Set the Google API key for Gemini
set_google_api_key('your-google-api-key')

# Set the Mistral API key
set_mistral_api_key('your-mistral-api-key')

2. Using LLMs for Code Generation

You can generate code using different LLMs by creating an instance of the corresponding generator class.

from llm_integrator.gemini_interface import GeminiCodeGenerator

# Initialize the Gemini code generator
gemini_generator = GeminiCodeGenerator()

# Generate code based on a prompt
prompt = "Create a diagram for a microservices architecture."
code = gemini_generator.generate_code(prompt)

print(code)

3. Using LLMs for Text Generation

Similar to code generation, you can also generate text responses using different LLMs.

Example:

# Generate a text response based on a prompt
text = gemini_generator.generate_text("Explain the benefits of using microservices.")

print(text)

Adding Support for New LLMs

The package is designed to be extensible. To add a new LLM:

  1. Create a new class that inherits from CodeGenerator.
  2. Implement the get_model_response method to interact with the new LLM's API.
  3. Add configuration functions for the new LLM's API key in config.py.

Example Skeleton for Adding a New LLM

from llm_integrator.commonllm import CodeGenerator
from llm_integrator.config import get_newllm_api_key
import newllm

class NewLLMCodeGenerator(CodeGenerator):
    def __init__(self):
        super().__init__('newllm')
        self.configure_api_key()

    def configure_api_key(self):
        api_key = get_newllm_api_key()
        newllm.configure(api_key=api_key)

    def get_model_response(self, full_prompt: str):
        model = newllm.GenerativeModel('newllm-model')
        response = model.generate_content(full_prompt)
        return {"text": response.text.strip()}

Code Generators Using Different AI Models

1. Gemini Code Generator

This generator uses Google's Gemini model.

from generators.gemini import GeminiCodeGenerator

generator = GeminiCodeGenerator(model_name="gemini-1.5-pro")
code = generator.generate_diagram("Create a system diagram for a web application using React, Node.js, and MongoDB.")
print(code)

2. OpenAI Code Generator

This generator uses OpenAI's models like GPT-3.5-turbo.

from generators.openai import OpenaiCodeGenerator

generator = OpenaiCodeGenerator(model_name="gpt-3.5-turbo")
code = generator.generate_code("Create a Python function that sorts a list of numbers.")
print(code)

3. Mistral Code Generator

This generator uses the Mistral model.

from generators.mistral import MistralCodeGenerator

generator = MistralCodeGenerator(model_name="codestral-mamba-latest")
code = generator.generate_diagram("Create a flowchart for an e-commerce application.")
print(code)

4. Claude Code Generator

This generator uses Anthropic's Claude model.

from generators.claude import ClaudeCodeGenerator

generator = ClaudeCodeGenerator(model_name="claude-3-5-sonnet-20240620")
code = generator.generate_diagram("Generate a UML diagram for a microservices architecture.")
print(code)

Contribution

Contributions are welcome! Please fork the repository and create a pull request with your changes.

License

This project is licensed under the MIT License.

Contact

If you have any questions, feel free to open an issue or contact the repository maintainers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pilot_py_hub_aggregator-0.0.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pilot_py_hub_aggregator-0.0.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pilot_py_hub_aggregator-0.0.1.tar.gz.

File metadata

  • Download URL: pilot_py_hub_aggregator-0.0.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pilot_py_hub_aggregator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7b8feca6ce65600595bd81c7ad466c2cdbfc7c532deab4064881d242d7230665
MD5 1f2c68876d2c1de0cf521c5990b7d51e
BLAKE2b-256 87f52b735632c673c6400f1f755f64b38eef4901f6e160f7db0027d4991ab7d9

See more details on using hashes here.

File details

Details for the file pilot_py_hub_aggregator-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pilot_py_hub_aggregator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e758fa005fb010765c0f39d136bcbfaaa9f7194ba43ec66194f552222606b17
MD5 c3f82657c02ab846c228564572b0b68c
BLAKE2b-256 43494abff8c2f35e7b21c87b8874304e3b78be191c96018b87993e3bf2934e00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page