Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/coslynx/openai-request-wrapper-backend
- Owner: coslynx
- Created: 2024-11-07T18:01:19.000Z (12 days ago)
- Default Branch: main
- Last Pushed: 2024-11-07T18:03:11.000Z (12 days ago)
- Last Synced: 2024-11-07T19:18:09.153Z (12 days ago)
- Topics: 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
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
OpenAI-Request-Wrapper-BackendA Python backend for simplifying OpenAI API interactions
Developed with the software and tools below.
## ๐ 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!