Skip to content

Simplified API for querying OpenAI models with user-friendly interface... Created at https://coslynx.com

License

Notifications You must be signed in to change notification settings

coslynx/OpenAI-Query-Wrapper-MVP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenAI-Query-Wrapper-MVP

A Python backend service for simplifying OpenAI API interactions.

Developed with the software and tools below.

Framework: FastAPI Language: Python Database: PostgreSQL LLMs: OpenAI
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

  • πŸ“ Overview
  • πŸ“¦ Features
  • πŸ“‚ Structure
  • πŸ’» Installation
  • πŸ—οΈ Usage
  • 🌐 Hosting
  • πŸ“„ License
  • πŸ‘ Authors

πŸ“ Overview

This repository contains a Minimum Viable Product (MVP) for an AI wrapper designed to streamline interactions with the OpenAI API. Built with Python, FastAPI, and PostgreSQL, it aims to simplify integration with OpenAI's powerful language models for developers and businesses.

πŸ“¦ Features

Feature Description
βš™οΈ Architecture The codebase follows a modular architectural pattern with separate directories for different functionalities, ensuring easier maintenance and scalability.
πŸ“„ Documentation The repository includes a README file that provides a detailed overview of the MVP, its dependencies, and usage instructions.
πŸ”— Dependencies The codebase relies on various external libraries and packages such as fastapi, openai, pyjwt, sqlalchemy, and psycopg2, which are essential for building the API, handling OpenAI API calls, implementing JWT authentication, and interacting with the PostgreSQL database.
🧩 Modularity The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities such as services, models, utils, and configurations.
πŸ§ͺ Testing Implements unit tests using pytest to ensure the reliability and robustness of the codebase.
⚑️ Performance The performance of the system is optimized using techniques such as asynchronous programming, caching, and efficient database queries.
πŸ” Security Enhances security by implementing measures such as input validation, API key handling, and secure database connections.
πŸ”€ Version Control Utilizes Git for version control with GitHub Actions workflow files for automated build and release processes.
πŸ”Œ Integrations Interacts with external services like OpenAI API and PostgreSQL database.
πŸ“Ά Scalability Designed to handle increased user load and data volume, utilizing efficient coding practices, caching, and database optimization techniques.

πŸ“‚ Structure

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ services
β”‚   β”‚   └── openai_service.py
β”‚   β”œβ”€β”€ models
β”‚   β”‚   └── models.py
β”‚   β”œβ”€β”€ utils
β”‚   β”‚   └── logger.py
β”‚   └── config
β”‚       └── config.py
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ commands.json
β”œβ”€β”€ startup.sh
β”œβ”€β”€ .env
└── .gitignore

πŸ’» Installation

πŸ”§ Prerequisites

  • Python 3.9+
  • pip
  • PostgreSQL (optional)

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/OpenAI-Query-Wrapper-MVP.git
    cd OpenAI-Query-Wrapper-MVP
  2. Install dependencies:
    pip install -r requirements.txt
  3. Set up the database (optional):
    • Install and configure PostgreSQL.
    • Create a database and a user with appropriate permissions.
    • Update the DATABASE_URL in the .env file with your database connection string.
  4. Configure environment variables:
    cp .env.example .env
    # Update the environment variables in .env with your OpenAI API key and database connection string (if applicable).

πŸ—οΈ Usage

πŸƒβ€β™‚οΈ Running the MVP

  1. Start the development server:
    uvicorn main:app --host 0.0.0.0 --port 8000

🌐 Hosting

πŸš€ Deployment Instructions

  1. Containerize with Docker:
    • Create a Dockerfile and docker-compose.yml file to define your application's container environment.
    • Build the Docker image and run the container using docker-compose.
  2. Deploy to a Cloud Platform:
    • Choose a cloud provider like AWS, GCP, or Azure.
    • Create a virtual machine or container instance.
    • Deploy your containerized application using the cloud provider's tools.
  3. Set Up Environment Variables:
    • Set environment variables (like OpenAI API key and database connection string) within your cloud provider's environment.

πŸ”‘ Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key.
  • DATABASE_URL: PostgreSQL database connection string (if applicable).
  • PORT: The port for running the application (default: 8000).

πŸ“œ API Documentation

πŸ” Endpoints

  • POST /v1/query/: Sends a request to OpenAI's API for text generation.
    • Request Payload:
      {
        "model": "text-davinci-003",  // OpenAI model to use
        "prompt": "Write a short story about a cat.",  // Prompt for the model
        "temperature": 0.7,  // Controls the creativity of the output (optional)
        "max_tokens": 2048,  // Maximum number of tokens in the output (optional)
        "top_p": 1.0,  // Controls the randomness of the output (optional)
        "frequency_penalty": 0.0,  // Penalty for repeating words (optional)
        "presence_penalty": 0.0  // Penalty for including specific words (optional)
      }
    • Response: JSON object containing the generated text and relevant metadata.

πŸ“œ License & Attribution

πŸ“„ License

This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.

πŸ€– AI-Generated MVP

This MVP was entirely generated using artificial intelligence through CosLynx.com.

No human was directly involved in the coding process of the repository: OpenAI-Query-Wrapper-MVP

πŸ“ž Contact

For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:

🌐 CosLynx.com

Create Your Custom MVP in Minutes With CosLynxAI!

Developers: Drix10, Kais Radwan Website: CosLynx.com Backed by: Google, Microsoft & Amazon for Startups Finalist: Backdrop Build v4, v6