Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coslynx/openai-python-wrapper
Streamlined API for simplified OpenAI requests, enabling efficient AI integration... Created at https://coslynx.com
https://github.com/coslynx/openai-python-wrapper
ai-integration api-client asynchronous-programming code-generation data-validation database-integration developer-tools devops error-handling fastapi machine-learning model-selection mvp mvp-development openai-library openai-wrapper python python-api software-development text-generation
Last synced: 15 days ago
JSON representation
Streamlined API for simplified OpenAI requests, enabling efficient AI integration... Created at https://coslynx.com
- Host: GitHub
- URL: https://github.com/coslynx/openai-python-wrapper
- Owner: coslynx
- Created: 2024-10-30T18:15:46.000Z (16 days ago)
- Default Branch: main
- Last Pushed: 2024-10-30T18:18:50.000Z (16 days ago)
- Last Synced: 2024-10-30T19:24:04.237Z (16 days ago)
- Topics: ai-integration, api-client, asynchronous-programming, code-generation, data-validation, database-integration, developer-tools, devops, error-handling, fastapi, machine-learning, model-selection, mvp, mvp-development, openai-library, openai-wrapper, python, python-api, software-development, text-generation
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
OpenAI Python WrapperA Python backend service for seamless OpenAI API integration.
Developed with the software and tools below.
## ๐ Table of Contents
- ๐ Overview
- ๐ฆ Features
- ๐ Structure
- ๐ป Installation
- ๐๏ธ Usage
- ๐ Hosting
- ๐ License
- ๐ Authors## ๐ Overview
This repository contains the backend code for the OpenAI Python Wrapper, a Python service designed to simplify the use of OpenAI's API for developers. This service offers a user-friendly interface for sending requests to OpenAI's API and receiving structured responses, making it easier for developers to integrate AI capabilities into their Python applications.
## ๐ฆ Features
| | Feature | Description |
|----|--------------------|--------------------------------------------------------------------------------------------------------------------|
| โ๏ธ | **Architecture** | The service follows a modular architectural pattern with separate directories for different functionalities, ensuring easier maintenance and scalability. |
| ๐ | **Documentation** | This repository includes a README file that provides a detailed overview of the project, its dependencies, and usage instructions. |
| ๐ | **Dependencies** | The codebase relies on various external libraries and packages such as `fastapi`, `uvicorn`, `openai`, `pydantic`, and `sqlalchemy`, which are essential for building and managing the API, interacting with OpenAI, and managing data. |
| ๐งฉ | **Modularity** | The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities such as services, routes, models, and utilities. |
| ๐งช | **Testing** | Unit tests using `pytest` are implemented to ensure the reliability and robustness of the codebase. |
| โก๏ธ | **Performance** | The service is optimized for efficiency, leveraging asynchronous operations with FastAPI. |
| ๐ | **Security** | Security is enhanced by implementing measures such as API key handling through environment variables and input validation using Pydantic. |
| ๐ | **Version Control**| Utilizes Git for version control. |
| ๐ | **Integrations** | The service seamlessly integrates with the OpenAI API and leverages the `openai` library for efficient interaction. |
| ๐ถ | **Scalability** | Designed for scalability, using a framework like FastAPI which supports asynchronous operations and can easily handle increased user load and data volume. |## ๐ Structure
```text
openai-python-wrapper/
โโโ requirements.txt
โโโ .env
โโโ main.py
โโโ models/
โ โโโ base.py
โโโ services/
โ โโโ openai_service.py
โโโ utils/
โ โโโ openai_utils.py
โโโ routes/
โ โโโ api_routes.py
โโโ tests/
โ โโโ test_routes.py
โ โโโ test_models.py
โ โโโ test_utils.py
โ โโโ test_services.py
โโโ commands.json
โโโ startup.sh
โโโ logging.conf
โโโ .gitignore```
## ๐ป Installation
### ๐ง Prerequisites
- Python 3.9+
- `pip` package manager
- PostgreSQL (optional)### ๐ Setup Instructions
1. **Clone the repository:**
```bash
git clone https://github.com/coslynx/OpenAI-Python-Wrapper.git
cd OpenAI-Python-Wrapper
```2. **Install dependencies:**
```bash
pip install -r requirements.txt
```3. **Set up environment variables:**
- Create a `.env` file in the project root and fill in the required values:
```bash
OPENAI_API_KEY=YOUR_OPENAI_API_KEY_HERE
DATABASE_URL=postgresql://user:password@host:port/database
```4. **(Optional) Set up the PostgreSQL database:**
- Follow the instructions for setting up PostgreSQL on your system.
- Update the `DATABASE_URL` in the `.env` file with your PostgreSQL connection details.## ๐๏ธ Usage
### ๐โโ๏ธ Running the MVP
1. **Start the development server:**
```bash
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
```## ๐ Hosting
### ๐ Deployment Instructions
#### Deploying to Heroku
1. Install the Heroku CLI:
```bash
npm install -g heroku
```2. Login to Heroku:
```bash
heroku login
```3. Create a new Heroku app:
```bash
heroku create OpenAI-Python-Wrapper-production
```4. Set up environment variables:
```bash
heroku config:set OPENAI_API_KEY=YOUR_OPENAI_API_KEY_HERE
heroku config:set DATABASE_URL=your_database_url_here
```5. Deploy the code:
```bash
git push heroku main
```6. Run database migrations (if applicable):
```bash
heroku run python manage.py migrate
```### ๐ Environment Variables
- `OPENAI_API_KEY`: Your OpenAI API key.
- `DATABASE_URL`: Connection string for your PostgreSQL database (if applicable).## ๐ API Documentation
### ๐ Endpoints
- **POST /api/generate_text**
- Description: Generates text using OpenAI's API.
- Body:
```json
{
"prompt": "Write a short story about a cat.",
"model": "text-davinci-003",
"max_tokens": 100
}
```
- Response:
```json
{
"text": "Once upon a time, there was a fluffy cat named Mittens..."
}
```- **POST /api/translate_text**
- Description: Translates text between languages using OpenAI's API.
- Body:
```json
{
"text": "Hello, world!",
"target_language": "fr"
}
```
- Response:
```json
{
"translation": "Bonjour le monde !"
}
```- **POST /api/complete_code**
- Description: Completes code snippets using OpenAI's API.
- Body:
```json
{
"prompt": "def greet(name):\n print("
}
```
- Response:
```json
{
"code": "def greet(name):\n print(f\"Hello, {name}!\")"
}
```## ๐ License & Attribution
### ๐ License
This Minimum Viable Product (MVP) is licensed under the [GNU AGPLv3](https://choosealicense.com/licenses/agpl-3.0/) license.
### ๐ค AI-Generated MVP
This MVP was entirely generated using artificial intelligence through [CosLynx.com](https://coslynx.com).
No human was directly involved in the coding process of the repository: OpenAI-Python-Wrapper
### ๐ Contact
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: [CosLynx.com](https://coslynx.com)
- Twitter: [@CosLynxAI](https://x.com/CosLynxAI)
๐ CosLynx.com
Create Your Custom MVP in Minutes With CosLynxAI!