Skip to content

AI-powered tool that connects users to the right resources and information... Created at https://coslynx.com

Notifications You must be signed in to change notification settings

coslynx/openai-user-request-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Connector for User Requests

A Python backend that simplifies user access to OpenAI's powerful language models.

Developed with the software and tools below.

Framework: FastAPI Backend: Python Database: PostgreSQL LLMs: OpenAI
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

  • πŸ“ Overview
  • πŸ“¦ Features
  • πŸ“‚ Structure
  • πŸ’» Installation
  • πŸ—οΈ Usage
  • 🌐 Hosting
  • πŸ“„ License
  • πŸ‘ Authors

πŸ“ Overview

This repository contains the backend for the AI Connector for User Requests MVP. It provides a simple and user-friendly interface for interacting with OpenAI's powerful language models, enabling users to leverage AI capabilities without needing technical expertise.

πŸ“¦ Features

Feature Description
βš™οΈ Architecture The codebase follows a modular architectural pattern with separate directories for different functionalities, ensuring easier maintenance and scalability.
πŸ“„ Documentation The repository includes a README file that provides a detailed overview of the MVP, its dependencies, and usage instructions.
πŸ”— Dependencies The codebase relies on various external libraries and packages such as FastAPI, Uvicorn, Pydantic, SQLAlchemy, psycopg2-binary, OpenAI, python-multipart, dotenv, pytest, pytest-cov, and flake8, which are essential for building and managing the backend, interacting with the database and the OpenAI API, and handling file uploads.
🧩 Modularity The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities such as the API, models, services, utils, and tests.
πŸ§ͺ Testing Implement unit tests using frameworks like pytest to ensure the reliability and robustness of the codebase.
⚑️ Performance The performance of the system can be optimized based on factors such as the database and hardware being used. Consider implementing caching strategies and asynchronous operations for better efficiency.
πŸ” Security Enhance security by implementing measures such as input validation, API key management, data encryption, and secure communication protocols.
πŸ”€ Version Control Utilizes Git for version control with appropriate workflow files for automated build and release processes.
πŸ”Œ Integrations Interacts with external services through HTTP requests, including integrations with OpenAI's API.
πŸ“Ά Scalability Design the system to handle increased user load and data volume, utilizing caching strategies and cloud-based solutions for better scalability.

πŸ“‚ Structure

ai-connector-mvp/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── main.py
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── models.py
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── logger.py
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── openai_service.py
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ test_openai_service.py
β”‚   β”‚   └── test_api.py
β”‚   └── config/
β”‚       └── settings.py
β”œβ”€β”€ .env
β”œβ”€β”€ startup.sh
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .flake8
└── Dockerfile

πŸ’» Installation

πŸ”§ Prerequisites

  • Python 3.9+
  • pip
  • PostgreSQL (optional)
  • Docker (optional)

πŸš€ Setup Instructions

  1. Clone the repository:

    git clone https://github.com/coslynx/ai-connector-mvp.git
    cd ai-connector-mvp
  2. Create a virtual environment:

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

    pip install -r requirements.txt
  4. Set up environment variables:

    • Create a .env file in the root directory and populate it with your OpenAI API key:
    OPENAI_API_KEY=your_api_key
    
  5. (Optional) Set up PostgreSQL:

    • Install PostgreSQL if you haven't already.
    • Create a database for the application.
    • Update the DATABASE_URL in your .env file with the correct connection string.

πŸ—οΈ Usage

πŸƒβ€β™‚οΈ Running the MVP

  1. Start the application:

    uvicorn src.api.main:app --reload
  2. Access the API:

🌐 Hosting

πŸš€ Deployment Instructions

Deploying to Heroku:

  1. Create a Heroku app.
  2. Push your application code to Heroku using the Heroku CLI.
  3. Configure environment variables on Heroku (OPENAI_API_KEY, DATABASE_URL, etc.).
  4. Run migrations if you are using a database.

πŸ”‘ Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key.
  • DATABASE_URL: The connection string for your PostgreSQL database (if using a database).
  • LOG_LEVEL: The logging level for the application.

πŸ“œ API Documentation

πŸ” Endpoints

  • POST /api/v1/request:
    • Description: Sends a user request to OpenAI's API.
    • Request Body:
      {
        "text": "Summarize this text: ...", // User request
        "model": "text-davinci-003", // OpenAI model to use (optional, defaults to 'text-davinci-003')
        "max_tokens": 1024, // Maximum number of tokens in the response (optional)
        "temperature": 0.7 // Controls the creativity of the response (optional)
      }
    • Response Body:
      {
        "message": "Success", // Success message
        "response": "...", // AI-generated response
        "error": null // Error message (if any)
      }

πŸ“œ 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: ai-connector-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!