Skip to main content

A package for prompt processing and language model interaction

Project description

FLUTE

FLUTE: Flexible Language Unified Tuning Elixir. Provides a factory and an abstract object for LLMs, and possibly BCIs in the future.

Usage

Creating a Prompt Processor

To create a prompt processor, use the PromptProcessorFactory class and call the create_prompt_processor method with the desired model name and API key:

from PromptProcessorFactory import PromptProcessorFactory

model_name = "claude-3-haiku-20240307"
api_key = "your_api_key"

prompt_processor = PromptProcessorFactory.create_prompt_processor(model_name, api_key)

The create_prompt_processor method will return an instance of the appropriate prompt processor class based on the provided model name.

Generating a Response

To generate a response using the prompt processor, call the generate_response method with the desired parameters:

prompt = "What is the capital of France?"
response = prompt_processor.generate_response(prompt, max_tokens=100, temperature=0.8)
print(response)

The generate_response method takes various parameters to control the generation process, such as max_tokens, temperature, top_p, etc. Refer to the specific prompt processor class documentation for more details on the available parameters.

Class Diagram

classDiagram
    AbstractPromptProcessor <|-- ClaudePromptProcessor
    AbstractPromptProcessor <|-- GPTPromptProcessor
    AbstractPromptProcessor <|-- GeminiPromptProcessor
    PromptProcessorFactory ..> AbstractPromptProcessor

    class AbstractPromptProcessor {
        +api_key: str
        +generate_response(prompt: Union[str, List[str]], **kwargs) Union[str, List[str]]
        +load_api_key(env_var: str)
        +remove_special_characters(text: str) str
    }

    class ClaudePromptProcessor {
        +model: str
        +generate_response(prompt: Union[str, List[str]], **kwargs) Union[str, List[str]]
    }

    class GPTPromptProcessor {
        +organization: str
        +generate_response(prompt: Union[str, List[str]], **kwargs) Union[str, List[str]]
    }

    class GeminiPromptProcessor {
        +model: GenerativeModel
        +generate_response(prompt: Union[str, List[str]], **kwargs) Union[str, List[str]]
    }

    class PromptProcessorFactory {
        +create_prompt_processor(model_name: str, api_key: Optional[str]) AbstractPromptProcessor
    }

The class diagram shows the inheritance relationship between the abstract base class AbstractPromptProcessor and its concrete implementations ClaudePromptProcessor, GPTPromptProcessor, and GeminiPromptProcessor. The PromptProcessorFactory class is responsible for creating instances of the appropriate prompt processor based on the provided model name.

LICENSE

The repository is licensed under the latest version of Modular and Inclusive Software Advancement License Classic (MISA-CLASSIC License).

There are 4 main policies that consist of this license.

  1. Disclaimer of Liability
  2. Naming Continuity Obligation
  3. Waiver of Other Copyrights
  4. Modular Extensibility (Defines how to modify the license)

See the license document for more details.

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

FLUTE-LLM-0.1.0.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

FLUTE_LLM-0.1.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

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