- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
This repository contains a Minimum Viable Product (MVP) called "OpenAI-API-Wrapper-Python-MVP" that simplifies interacting with OpenAI's powerful language models through a Python backend service. This MVP empowers developers to leverage AI capabilities without the complexity of directly working with the OpenAI API.
Feature | Description | |
---|---|---|
βοΈ | Architecture | The codebase follows a modular structure, separating functionalities into distinct modules for easier maintenance and scalability. |
π | Documentation | This README.md file provides a detailed overview of the MVP, its dependencies, and usage instructions. |
π | Dependencies | The codebase relies on several external libraries and packages, including fastapi , uvicorn , pydantic , openai , and requests . |
𧩠| Modularity | The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities. |
π§ͺ | Testing | Includes unit tests to ensure the codebase is reliable and robust. |
β‘οΈ | Performance | The MVP is optimized for performance and efficiency, using asynchronous processing and other techniques. |
π | Security | The code implements basic security measures such as API key management and input validation. |
π | Version Control | Uses Git for version control and GitHub Actions for automated builds and releases. |
π | Integrations | Integrates seamlessly with the OpenAI API, enabling various AI tasks like text generation, translation, question answering, and code completion. |
βββ main.py
βββ routers
β βββ models.py
β βββ generate.py
β βββ translate.py
β βββ question.py
β βββ code.py
βββ services
β βββ openai_service.py
β βββ auth_service.py
βββ models
β βββ request.py
β βββ response.py
βββ utils
β βββ logger.py
β βββ exceptions.py
β βββ config.py
β βββ auth.py
βββ tests
βββ test_main.py
- Python 3.9+
- A virtual environment (recommended)
- An OpenAI API key (obtain one from https://platform.openai.com/account/api-keys)
-
Clone the repository:
git clone https://github.com/coslynx/OpenAI-API-Wrapper-Python-MVP.git cd OpenAI-API-Wrapper-Python-MVP
-
Create a virtual environment (optional):
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
cp .env.example .env # Fill in your OpenAI API key: OPENAI_API_KEY=<your_openai_api_key>
- Start the FastAPI server:
uvicorn main:app --host 0.0.0.0 --port 8000
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
cp .env.example .env # Fill in your OpenAI API key and other necessary variables: OPENAI_API_KEY=<your_openai_api_key>
-
Run the application:
uvicorn main:app --host 0.0.0.0 --port 8000
/models
: (GET) Returns a list of available OpenAI models./generate
: (POST) Generates text using a chosen OpenAI model./translate
: (POST) Translates text between languages./question
: (POST) Answers a question using an OpenAI model./code
: (POST) Generates code in a specified programming language.
The API uses basic authentication. You need to provide your OpenAI API key in the request header:
Authorization: Bearer <your_openai_api_key>
Text Generation:
curl -X POST http://localhost:8000/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_openai_api_key>" \
-d '{"model": "text-davinci-003", "prompt": "Write a short story about a cat who goes on an adventure.", "temperature": 0.7}'
Translation:
curl -X POST http://localhost:8000/translate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_openai_api_key>" \
-d '{"source_language": "en", "target_language": "fr", "text": "Hello, world!"}'
Question Answering:
curl -X POST http://localhost:8000/question \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_openai_api_key>" \
-d '{"question": "What is the capital of France?"}'
Code Generation:
curl -X POST http://localhost:8000/code \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_openai_api_key>" \
-d '{"language": "python", "prompt": "Write a function that prints Hello World."}'
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-API-Wrapper-Python-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!