An open API service indexing awesome lists of open source software.

https://github.com/coslynx/openai-request-executor-mvp

AI-powered tool to execute OpenAI requests and provide responses efficiently... Created at https://coslynx.com
https://github.com/coslynx/openai-request-executor-mvp

ai-request-executor code-generation developer-tools devops fastapi machine-learning mvp mvp-development natural-language-processing openai-api-wrapper openai-integration openai-library postgresql python python-backend requests response-formatter software-development sqlalchemy uvicorn

Last synced: 28 days ago
JSON representation

AI-powered tool to execute OpenAI requests and provide responses efficiently... Created at https://coslynx.com

Awesome Lists containing this project

README

          




OpenAI-Request-Executor-MVP


A Python backend service for effortless OpenAI API interactions with natural language requests.


Developed with the software and tools below.



Framework-FastAPI
Backend-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) called "OpenAI-Request-Executor-MVP." It's a Python-based backend service that acts as a user-friendly interface for interacting with OpenAI's APIs. The service accepts natural language requests, translates them into appropriate OpenAI API calls, executes them, and delivers formatted responses.

## ๐Ÿ“ฆ Features

| | Feature | Description |
|----|--------------------|--------------------------------------------------------------------------------------------------------------------|
| โš™๏ธ | **Architecture** | The service employs a layered architecture, separating the presentation, business logic, and data access layers for improved maintainability and scalability. |
| ๐Ÿ“„ | **Documentation** | The repository includes a README file that provides a detailed overview of the MVP, its dependencies, and usage instructions.|
| ๐Ÿ”— | **Dependencies** | Essential Python packages are used, including FastAPI, Pydantic, uvicorn, psycopg2-binary, SQLAlchemy, requests, PyJWT, and OpenAI for API interaction, authentication, and database operations.|
| ๐Ÿงฉ | **Modularity** | The code is organized into modules for efficient development and maintenance, including `models`, `services`, and `utils`.|
| ๐Ÿงช | **Testing** | The MVP includes unit tests for core modules (`main.py`, `services/openai_service.py`, `models/request.py`) using Pytest, ensuring code quality and functionality. |
| โšก๏ธ | **Performance** | The backend is optimized for efficient request processing and response retrieval, utilizing asynchronous programming with asyncio and caching for improved speed and responsiveness.|
| ๐Ÿ” | **Security** | Security measures include secure communication with HTTPS, authentication with JWTs, and data encryption. |
| ๐Ÿ”€ | **Version Control**| Utilizes Git for version control, allowing for tracking changes and collaborative development. |
| ๐Ÿ”Œ | **Integrations** | Seamlessly integrates with OpenAI's API using the `openai` Python library, PostgreSQL database using SQLAlchemy, and leverages the `requests` library for communication. |
| ๐Ÿ“ถ | **Scalability** | The service is designed for scalability, utilizing cloud-based hosting like AWS or GCP, and optimized for handling increasing request volumes. |

## ๐Ÿ“‚ Structure

```text
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ models
โ”‚ โ””โ”€โ”€ request.py
โ”œโ”€โ”€ services
โ”‚ โ””โ”€โ”€ openai_service.py
โ”œโ”€โ”€ utils
โ”‚ โ””โ”€โ”€ logger.py
โ”œโ”€โ”€ tests
โ”‚ โ”œโ”€โ”€ test_main.py
โ”‚ โ”œโ”€โ”€ test_openai_service.py
โ”‚ โ””โ”€โ”€ test_models.py
โ”œโ”€โ”€ startup.sh
โ”œโ”€โ”€ commands.json
โ””โ”€โ”€ requirements.txt
```

## ๐Ÿ’ป Installation

### ๐Ÿ”ง Prerequisites
- Python 3.9+
- PostgreSQL 14+
- Docker 20.10+

### ๐Ÿš€ Setup Instructions

1. **Clone the repository:**
```bash
git clone https://github.com/coslynx/OpenAI-Request-Executor-MVP.git
cd OpenAI-Request-Executor-MVP
```

2. **Install dependencies:**
```bash
pip install -r requirements.txt
```

3. **Set up the database:**
- Create a database:
```bash
createdb openai_executor
```
- Connect to the database and create an extension for encryption:
```bash
psql -U postgres -d openai_executor -c "CREATE EXTENSION IF NOT EXISTS pgcrypto"
```

4. **Configure environment variables:**
- Create a `.env` file:
```bash
cp .env.example .env
```
- Fill in the environment variables with your OpenAI API key, PostgreSQL database connection string, and JWT secret key.

5. **Start the application (using Docker):**
```bash
docker-compose up -d
```

## ๐Ÿ—๏ธ Usage

### ๐Ÿƒโ€โ™‚๏ธ Running the MVP

- The application will be accessible at `http://localhost:8000`.
- Use a tool like `curl` or `Postman` to send requests to the `/requests/` endpoint:

```bash
curl -X POST http://localhost:8000/requests/ \
-H "Content-Type: application/json" \
-d '{"text": "Write a short story about a cat"}'
```

- The response will contain a request ID and status:

```json
{
"request_id": 1,
"status": "completed"
}
```

- To retrieve the generated response, use the `/responses/{request_id}` endpoint:

```bash
curl -X GET http://localhost:8000/responses/1
```

- The response will contain the generated text:

```json
{
"response": "Once upon a time, in a cozy little cottage..."
}
```

## ๐ŸŒ Hosting

### ๐Ÿš€ Deployment Instructions

#### Deploying to Heroku (Example)

1. **Create a Heroku app:**
```bash
heroku create openai-request-executor-mvp-production
```

2. **Set up environment variables:**
```bash
heroku config:set OPENAI_API_KEY=your_openai_api_key
heroku config:set DATABASE_URL=postgresql://your_user:your_password@your_host:your_port/your_database_name
heroku config:set JWT_SECRET=your_secret_key
```

3. **Deploy the code:**
```bash
git push heroku main
```

4. **Run database migrations (if applicable):**
- You'll need to set up database migrations for your PostgreSQL database.

5. **Start the application:**
- Heroku will automatically start your application based on the `Procfile`.

## ๐Ÿ“„ 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-Request-Executor-MVP

### ๐Ÿ“ž Contact
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: [CosLynx.com](https://coslynx.com)
- Twitter: [@CosLynxAI](https://twitter.com/CosLynxAI)


๐ŸŒ CosLynx.com


Create Your Custom MVP in Minutes With CosLynxAI!








```

This README.md file utilizes the provided Minimum Viable Product (MVP) idea and tech stack information to create a polished and visually appealing document. It incorporates advanced markdown formatting, code blocks, and shield.io badges to enhance readability and aesthetics.

Remember to replace the placeholders like "your_openai_api_key" and "your_database_url" with your actual values. The provided hosting instructions are an example, and you might need to adjust them based on your chosen hosting platform.