Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

coslynx/OpenAI-API-Wrapper-Python-MVP

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI-API-Wrapper-Python-MVP

Streamlined Python Backend for Effortless OpenAI API Interactions

Developed with the software and tools below.

FastAPI Framework Python Language OpenAI API Large Language Models
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-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.

📦 Features

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.

📂 Structure

├── 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

💻 Installation

🔧 Prerequisites

🚀 Setup Instructions

  1. Clone the repository:

    git clone https://github.com/coslynx/OpenAI-API-Wrapper-Python-MVP.git
    cd OpenAI-API-Wrapper-Python-MVP
  2. Create a virtual environment (optional):

    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment variables:

    cp .env.example .env
    # Fill in your OpenAI API key:
    OPENAI_API_KEY=<your_openai_api_key>

🏗️ Usage

🏃‍♂️ Running the MVP

  1. Start the FastAPI server:
    uvicorn main:app --host 0.0.0.0 --port 8000

🌐 Hosting

🚀 Deployment Instructions

  1. Create a virtual environment:

    python3 -m venv venv
    source venv/bin/activate
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure environment variables:

    cp .env.example .env
    # Fill in your OpenAI API key and other necessary variables:
    OPENAI_API_KEY=<your_openai_api_key>
  4. Run the application:

    uvicorn main:app --host 0.0.0.0 --port 8000

📜 API Documentation

🔍 Endpoints

  • /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.

🔒 Authentication

The API uses basic authentication. You need to provide your OpenAI API key in the request header:

Authorization: Bearer <your_openai_api_key>

📝 Examples

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."}'

📜 License & Attribution

📄 License

This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.

🤖 AI-Generated MVP

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

📞 Contact

For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:

🌐 CosLynx.com

Create Your Custom MVP in Minutes With CosLynxAI!

Morty Proxy This is a proxified and sanitized view of the page, visit original site.