- Notifications
You must be signed in to change notification settings - Fork1
Simplified API for seamless OpenAI requests, streamlining access to AI capabilities... Created athttps://coslynx.com
coslynx/OpenAI-API-Wrapper-Python-MVP
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- 📍 Overview
- 📦 Features
- 📂 Structure
- 💻 Installation
- 🏗️ Usage
- 🌐 Hosting
- 📄 License
- 👏 Authors
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.
| 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, includingfastapi,uvicorn,pydantic,openai, andrequests. |
| 🧩 | 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. |
├── 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- Python 3.9+
- A virtual environment (recommended)
- An OpenAI API key (obtain one fromhttps://platform.openai.com/account/api-keys)
Clone the repository:
git clone https://github.com/coslynx/OpenAI-API-Wrapper-Python-MVP.gitcd OpenAI-API-Wrapper-Python-MVPCreate a virtual environment (optional):
python3 -m venv venvsource venv/bin/activateInstall dependencies:
pip install -r requirements.txt
Configure environment variables:
cp .env.example .env# Fill in your OpenAI API key:OPENAI_API_KEY=<your_openai_api_key>
- Start the FastAPI server:
uvicorn main:app --host 0.0.0.0 --port 8000
Create a virtual environment:
python3 -m venv venvsource venv/bin/activateInstall dependencies:
pip install -r requirements.txt
Configure environment variables:
cp .env.example .env# Fill in your OpenAI API key and other necessary variables:OPENAI_API_KEY=<your_openai_api_key>
Run the application:
uvicorn main:app --host 0.0.0.0 --port 8000
/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.
The API uses basic authentication. You need to provide your OpenAI API key in the request header:
Authorization: Bearer<your_openai_api_key>
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."}'
This Minimum Viable Product (MVP) is licensed under theGNU AGPLv3 license.
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
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website:CosLynx.com
- Twitter:@CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!
About
Simplified API for seamless OpenAI requests, streamlining access to AI capabilities... Created athttps://coslynx.com
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.