Skip to content

richiectr360/kai-ai-backend

 
 

Repository files navigation

Kai AI Platform

Static Badge Static Badge Static Badge Static Badge

Table of Contents

Folder Structure

backend/
├── app/                     # Contains the main application code
│   ├── Api/                 # Contains the API router for handling requests
│   │   └── router.py        # Endpoints for FastAPI to test features and handle incoming requests
│   ├── chats/               # Handles chat functionalities
│   ├── Features/            # Contains feature-specific modules
│   │   ├── Feature1/
│   │   │   ├── core.py
│   │   │   ├── tools.py
│   │   │   ├── Prompt/
│   │   │   └── metadata.json
│   │   ├── Feature2/
│   │   │   ├── core.py
│   │   │   ├── tools.py
│   │   │   ├── Prompt/
│   │   │   └── metadata.json
│   ├── services/            # Contains service modules
│   ├── utils/               # Contains utility modules
│   ├── app.yaml             # Application configuration file
│   ├── Dependencies.py      # Dependency management
│   ├── Main.py              # Main entry point for the application
│   └── requirements.txt     # Python dependencies
├── Dockerfile               # Dockerfile for containerizing the application
└── README.md                # Documentation file

Install all the necessary libraries:

Navigate to the app directory

cd backend/app

Create and activate Virtual Environment

python -m venv env
source env/bin/activate
pip install -r requirements.txt

To Run Locally and Test

Prerequisites

  • A Google Cloud account.
  • Access to the Google Cloud Platform console.

Steps for Authentication Setup

Step 1: Create a Google Cloud Project

  1. Navigate to the Google Cloud Console and create a new project.

Step 2: Enable the Google Cloud APIs

  1. Enable the following APIs:
    • VertexAI

Step 3: Create a new AI Studio API Key

  1. Navigate to the AI Studio API Key page and create a new API key. This will connect with your Google Cloud Project.

Step 4: Create a new .env and store the API Key

  1. Create a new file called .env in the root of the project.
  2. Copy the contents of the .env.example file into the .env file.
  3. Replace the placeholder values with your API key and project ID.
  4. Set the ENV_TYPE variable to dev.

Step 4: Run the Application with Local Shell Script

  1. Run the following command to start the application:
./local-start.sh

Docker Setup Guide

Overview

This guide is designed to help contributors set up and run the backend service using Docker. Follow these steps to ensure that your development environment is configured correctly.

Prerequisites

Before you start, ensure you have the following installed:

  • Docker
  • Python

Installation Instructions

1. Build the Docker Image

Navigate to the project's root directory and build the Docker image. Typically, this is done with the following command:

docker build -t <image_name> .

3 Run the Docker Container

Run the Docker container using the following command:

docker run -p 8000:8000 <image_name>

This command starts a detached container that maps port 8000 of the container to port 8000 on the host.

Environment Variables

The Docker container uses several key environment variables:

  • ENV_TYPE set to "dev" for development.
  • PROJECT_ID specifies your Google Cloud project ID.
  • It is possible to enable LangChain tracing by setting the following environment variables. More information can be found on LangSmith LANGCHAIN_TRACING_V2 LANGCHAIN_ENDPOINT LANGCHAIN_API_KEY LANGCHAIN_PROJECT
  • Ensure these variables are correctly configured in a .env file.

Accessing the Application

You can access the backend by visiting:

http://localhost:8000/docs

After your container starts, you should see the FastAPI landing page, indicating that the application is running successfully.

About

This is the Kai Teaching Assistant ai repo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.0%
  • Shell 2.1%
  • Dockerfile 0.9%