Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Simplified API for seamless OpenAI requests, streamlining access to AI capabilities... Created athttps://coslynx.com

NotificationsYou must be signed in to change notification settings

coslynx/OpenAI-API-Wrapper-Python-MVP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

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 FrameworkPython LanguageOpenAI APILarge Language Models
git-last-commitGitHub commit activityGitHub 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

FeatureDescription
⚙️ArchitectureThe codebase follows a modular structure, separating functionalities into distinct modules for easier maintenance and scalability.
📄DocumentationThis README.md file provides a detailed overview of the MVP, its dependencies, and usage instructions.
🔗DependenciesThe codebase relies on several external libraries and packages, includingfastapi,uvicorn,pydantic,openai, andrequests.
🧩ModularityThe modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities.
🧪TestingIncludes unit tests to ensure the codebase is reliable and robust.
⚡️PerformanceThe MVP is optimized for performance and efficiency, using asynchronous processing and other techniques.
🔐SecurityThe code implements basic security measures such as API key management and input validation.
🔀Version ControlUses Git for version control and GitHub Actions for automated builds and releases.
🔌IntegrationsIntegrates 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.gitcd OpenAI-API-Wrapper-Python-MVP
  2. Create a virtual environment (optional):

    python3 -m venv venvsource 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 venvsource 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 theGNU AGPLv3 license.

🤖 AI-Generated MVP

This MVP was entirely generated using artificial intelligence throughCosLynx.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!


[8]ページ先頭

©2009-2026 Movatter.jp