Skip to main content

A powerful library for managing AI-driven prompt handling and response generation, featuring structured database management and seamless Node.js integration.

Project description

Prompt-AI Library

Prompt-AI is a powerful library designed to optimize AI-driven prompt handling and response generation using the Gemini API. By introducing structured database management and efficient embedding retrieval, Prompt-AI significantly enhances performance, reduces response times, and provides a seamless solution for integrating AI models into various applications.

Getting Started

1. Generate an API Key

To begin, you’ll need to generate an API key. Follow the link below to generate your API key:

Generate API Key

Brief Summary of Gemini Model

The Gemini model is a powerful AI-driven model designed for generating contextually relevant responses to user prompts. Unlike traditional approaches where embeddings are generated on each run, Prompt-AI integrates a more efficient workflow by storing pre-generated embeddings in a NoSQL database. This allows for faster response times and reduces computational overhead, making it ideal for applications like chatbots, recommendation systems, and other AI-powered tools.

3. Setting up MongoDB (In later versions: SQL and Cloud database will be added)

  1. Create a Database in Mongo Atlas or MongoDB Compass (Which you feel good).
  2. Create collection and Documents.
  3. Set the document in this structure:
{
"id": 1,
"title": "Gork vs Chat-gpt",
"text": "In the rapidly evolving landscape of artificial inte...",
}

4. Using Prompt-AI to manage prompts and generate response

Prompt-AI provides two core functions to help you manage prompts and generate responses:

1) configure(mongo_uri: string, db_name: string, collection_name: string, columns: array, API_KEY: string, embeddings: bool)

configure(mongo_uri, db_name, collection_name, columns, API_KEY, embeddings)

This function configures the connection to your MongoDB Atlas and sets up the necessary parameters for generating embeddings.

  • mongo_uri: string
    This should contain your MongoDB Atlas connection string.
mongo_uri = 'mongoDB connection string'
  • db_name: string
    The name of your MongoDB database.
db_name = 'Database Name'
  • collection_name: string
    The name of the collection in your database where the data is stored.
collection_name = 'collection name'
  • columns: array
    An array of strings, each representing a field name present in each document of the collection. The field which contains ANSWER data must be named with 'text'.
columns = ['id', 'title', 'text', 'embeddings']
  • API_KEY: string
    The API key generated in the first step.
API_KEY = 'key generated in first step'
  • embeddings: bool
    A boolean flag indicating whether embeddings need to be created (true) or if they already exist (false).
embeddings = True or False

This function call will return datasets in form of tabular dataframe.

id          title                    text                   embeddings
1       "chat-gpt features"    "chat-gpt has..."        [4.0322, 2.3344, 1.09...]
2       "Gork vs Chat-gpt"     "Gork have plenty..."    [1.1702, 0.4184, 5.19...]

overall configure function will look like this...

uri = 'your connection string' // mongo_uri
db = 'database_name' // database_name
col = 'collection_name' // collection_name
API_KEY = 'api_key generated in first step' // API_KEY
column = ['id', 'title', 'text', 'Embeddings'] // sample input
embeddings = True
dataframe = configure(uri, db, col, API_KEY, column, embeddings)

2) generate(user_prompt, dataframe)

generate(user_prompt, dataframe)

This function processes the user’s prompt, interacts with the database, and returns the AI-generated response. dataframe will be used here inside generate() function.

@app.post("/api")
async def generate_response(request: PromptRequest):
    # Extract the prompt from the request body
    user_prompt = request.prompt

    # calling generate() function with prompt and dataframe as parameter

    response = generate(user_prompt, df)

    return {"response": response}

(Explanation and usage examples for the generate function...)


Conclusion

With Prompt-AI, you can efficiently manage AI-driven prompt handling, leveraging the Gemini model's capabilities with enhanced performance and scalability. Whether you’re building a chatbot, a recommendation system, or any other AI-powered application, Prompt-AI provides a streamlined and powerful solution.

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

prompt-ai-0.1.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

prompt_ai-0.1.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file prompt-ai-0.1.5.tar.gz.

File metadata

  • Download URL: prompt-ai-0.1.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for prompt-ai-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8d93ea2b6de2a278f821ac5f85d63624eb5e48c1d50b6812142d1cac88f17d87
MD5 4ce26ae899d380e45d05435b261efb46
BLAKE2b-256 0d2aaf8b69e3d02959b154195faadeddd8f1bc2119549e133827b76daca47e58

See more details on using hashes here.

File details

Details for the file prompt_ai-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: prompt_ai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for prompt_ai-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c73c7a13e5915a0f35419f7b4e8edb5adb839c6623e70229d63de2b2afeac97f
MD5 3e62afc753e3c43d4f10a19666e9aa2a
BLAKE2b-256 58417ad46e91d0fb3a3a8b19997b9135a7993b85129517f1a2782dcdbbde7a29

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