- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
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.
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. |
βββ src
β βββ services
β β βββ openai_service.py
β βββ models
β β βββ models.py
β βββ utils
β β βββ logger.py
β βββ config
β βββ config.py
βββ main.py
βββ requirements.txt
βββ commands.json
βββ startup.sh
βββ .env
βββ .gitignore
- Python 3.9+
- pip
- PostgreSQL (optional)
- Clone the repository:
git clone https://github.com/coslynx/OpenAI-Query-Wrapper-MVP.git cd OpenAI-Query-Wrapper-MVP
- Install dependencies:
pip install -r requirements.txt
- 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.
- Configure environment variables:
cp .env.example .env # Update the environment variables in .env with your OpenAI API key and database connection string (if applicable).
- Start the development server:
uvicorn main:app --host 0.0.0.0 --port 8000
- 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.
- 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.
- Set Up Environment Variables:
- Set environment variables (like OpenAI API key and database connection string) within your cloud provider's environment.
OPENAI_API_KEY
: Your OpenAI API key.DATABASE_URL
: PostgreSQL database connection string (if applicable).PORT
: The port for running the application (default: 8000).
- 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.
- Request Payload:
This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.
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
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: CosLynx.com
- Twitter: @CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!