Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/coslynx/openai-request-wrapper-backend

AI-powered tool for crafting and sending personalized messages using OpenAIs API... Created at https://coslynx.com
https://github.com/coslynx/openai-request-wrapper-backend

ai-api-client ai-request-responder code-generation coslynx developer-tools devops fastapi gpt-3-integration machine-learning minimum-viable-product mvp openai-api-request openai-python openai-wrapper pydantic python python-backend requests sqlite uvicorn

Last synced: 9 days ago
JSON representation

AI-powered tool for crafting and sending personalized messages using OpenAIs API... Created at https://coslynx.com

Awesome Lists containing this project

README

        




OpenAI-Request-Wrapper-Backend


A Python backend for simplifying OpenAI API interactions


Developed with the software and tools below.



Framework-FastAPI-blue
Language-Python-red
Database-SQLite-blue
LLMs-OpenAI-black


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 Python backend server designed to streamline interactions with OpenAI's powerful AI models. The "AI Wrapper OpenAI Request Responder" provides a user-friendly interface for developers and individuals to leverage OpenAI's technology for various applications. This MVP focuses on simplifying the process of sending requests to OpenAI and receiving responses, eliminating the need for complex manual API call management.

## ๐Ÿ“ฆ Features
| | Feature | Description |
|----|--------------------|--------------------------------------------------------------------------------------------------------------------|
| โš™๏ธ | **Architecture** | The backend utilizes a lightweight framework like Flask or FastAPI for efficient routing and API management. |
| ๐Ÿ“„ | **Documentation** | The repository includes a comprehensive README file detailing the MVP's features, usage, and deployment instructions. |
| ๐Ÿ”— | **Dependencies** | The project relies on essential packages such as FastAPI, Uvicorn, Pydantic, OpenAI, and Requests for its functionality. |
| ๐Ÿงฉ | **Modularity** | The code is structured for modularity, with separate files for handling requests, API interaction, and response processing. |
| ๐Ÿงช | **Testing** | Unit tests are implemented to ensure the code's functionality and stability. |
| โšก๏ธ | **Performance** | The backend optimizes communication with OpenAI APIs for swift responses, employing efficient request handling and response processing. |
| ๐Ÿ” | **Security** | Robust security measures protect API keys and user data, ensuring secure handling of sensitive information. |
| ๐Ÿ”€ | **Version Control**| Utilizes Git for version control, employing a branching model for efficient development and maintenance. |
| ๐Ÿ”Œ | **Integrations** | Seamless integration with various applications and platforms is achieved using a REST API. |
| ๐Ÿ“ถ | **Scalability** | The backend is designed to handle increasing request volumes efficiently. |

## ๐Ÿ“‚ Structure
```text
[object Object]
```

## ๐Ÿ’ป Installation
### ๐Ÿ”ง Prerequisites
- Python 3.10+
- `pip` package manager
- OpenAI API Key

### ๐Ÿš€ Setup Instructions
1. **Clone the repository:**
```bash
git clone https://github.com/coslynx/OpenAI-Request-Wrapper-Backend.git
cd OpenAI-Request-Wrapper-Backend
```
2. **Install dependencies:**
```bash
pip install -r requirements.txt
```
3. **Set up environment variables:**
```bash
cp .env.example .env
```
- Open `.env` and replace `YOUR_OPENAI_API_KEY_HERE` with your actual OpenAI API key.
- You can optionally set `DATABASE_URL` if you want to use a different database.

## ๐Ÿ—๏ธ Usage
### ๐Ÿƒโ€โ™‚๏ธ Running the Backend
```bash
uvicorn api.main:app --host 0.0.0.0 --port 8000
```
### โš™๏ธ Configuration
- The `utils/config.py` file handles environment variables like `OPENAI_API_KEY` and `DATABASE_URL`. You can change them in the `.env` file.
- The backend server listens on port 8000 by default. You can change this in `startup.sh` or by passing a different port to `uvicorn` when running the server.

### ๐Ÿ“š Examples
**Making a Text Generation Request**
```bash
curl -X POST http://localhost:8000/generate_text \
-H "Content-Type: application/json" \
-d '{"model": "text-davinci-003", "prompt": "Write a short story about a cat", "temperature": 0.7}'
```
**Response:**
```json
{
"response": "Once upon a time, in a cozy little cottage nestled amidst rolling hills, there lived a mischievous tabby cat named Whiskers. Whiskers was known for his playful antics and his insatiable appetite for tuna."
}
```

## ๐ŸŒ Hosting
### ๐Ÿš€ Deployment Instructions
1. **Create a virtual environment:**
```bash
python -m venv .venv
source .venv/bin/activate
```
2. **Install dependencies:**
```bash
pip install -r requirements.txt
```
3. **Set up environment variables:**
```bash
cp .env.example .env
```
4. **Run the application:**
```bash
uvicorn api.main:app --host 0.0.0.0 --port 8000
```
5. **Use a deployment platform like Heroku or AWS:**
- Follow the specific instructions for your chosen platform.
- Make sure to set up the environment variables (API keys, database credentials, etc.) as required by your chosen platform.

### ๐Ÿ”‘ Environment Variables
- `OPENAI_API_KEY`: Your OpenAI API key.
- `DATABASE_URL`: Your database connection string (if using a database).

## ๐Ÿ“œ API Documentation
### ๐Ÿ” Endpoints
- **POST /generate_text**
- Description: Generates text using OpenAI's models.
- Request Body:
```json
{
"model": "text-davinci-003", // OpenAI model to use
"prompt": "Write a short story about a cat", // Text prompt
"temperature": 0.7 // Controls randomness of the generated text
}
```
- Response:
```json
{
"response": "Once upon a time, in a cozy little cottage..." // The generated text
}
```

### ๐Ÿ”’ Authentication
- This MVP does not implement user authentication. It is designed to be used with a single OpenAI API key stored in the environment variable.

### ๐Ÿ“ Examples
[See examples above]

## ๐Ÿ“œ 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-Wrapper-Backend

### ๐Ÿ“ž 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!