GenAI - Python Package "GeAI" Documentation

Last update: 2024/01/20

Utilizing Generative Artificial Intelligence models like "GPT-4" and "Gemini Pro" as coding and writing assistants for "Python" users. Through these models, "GeAI" offers a variety of functions, encompassing text generation, code optimization, natural language processing, chat, and image interpretation. The goal is to aid "Python" users in streamlining laborious coding and language processing tasks.

⚠️ NOTICE for Python package "GeAI" ⚠️
This documentation is not complete. The Python package is currently in the development phase. Please exercise caution when using it, as it may not be entirely stable or free of potential issues.


Prerequisites

Prior to utilizing the GenAI package, several prerequisites must be met.

  1. Ensure that you possess an eligible device equipped with Python.

  2. Access to the internet is essential to generate text or engage in chat through GenAI.

  3. Obtain an API key from the selected Generative AI service provider. GenAI currently supports Generative AI models from both Google and OpenAI.

    • To acquire an API key for Google's models, refer to: Get an API key
    • To acquire an API key for OpenAI's models, refer to: Account setup

Installation

1. Install the package from The Python Package Index (PyPI).

pip install GeAI

2. Install the package from GenAI official website.

pip install -i https://genai.gd.edu.kg/release/Python/GeAI-latest-py3-none-any.whl GeAI

Setup

The "Setup" section provides functions to explore available Generative AI models. The available.models function fetches information about supported models, while the connect.genai function establishes a connection to a specific model using key parameters like service provider, model, version, and API key.


GeAI.available_models
Open in GitHub

Get supported Generative AI models

Usage
GeAI.available_models()
Value

If successful, the function returns a dictionary containing Generative AI service providers and their corresponding models. If the function encounters an error, it will halt execution and provide an error message.

Description

This function sends a request to database to retrieve information about available Generative AI models.

Detail

The function utilizes the GenAI database API to fetch the latest information about available Generative AI models. The retrieved data includes details about different models offered by various service providers.


GeAI.connect
Open in GitHub

Set up and connect to a Generative AI model

Usage
GeAI.connect(provider, 
             model, 
             version, 
             api, 
             proxy = False)
Arguments
  • provider: A character string representing the Generative AI service provider (e.g., "google", "openai").

  • model: A character string representing the specific model offered by the selected provider (e.g., "gpt-3.5-turbo", "gemini-pro").

  • version: A character string representing the version of the chosen model.

  • api: A character string representing the API key required for accessing the model.

  • proxy: A boolean value indicating whether to use a proxy for accessing the API URL (default is False). If your local internet cannot access the APIs, set this parameter to True.

Value

If successful, the function returns a dictionary containing information about the chosen Generative AI service provider, model, version, API key, and proxy status. If the API response indicates an error, the function halts execution and provides an error message.

Description

This function establishes a connection to a Generative AI model by providing essential parameters such as the service provider, model, version, API key, and proxy status.

Detail

It is crucial to provide accurate and valid information for each parameter to ensure a successful connection to the Generative AI model. If any of the provided parameters are incorrect, the function will respond with an error message based on the information received from the API. Use the function available.models to see all supported Generative AI models.