← Back to index

waifu chat api

Table of Contents

  1. Project Description and Purpose
  2. Installation and Setup Instructions
  3. API Documentation
  4. Configuration
  5. Troubleshooting

Project Description and Purpose

This project is a Flask-based API for interacting with a conversational AI waifu character. It provides endpoints for user management, dialog management, and server status checks.

This project provides a backend API for a conversational AI. It allows users to interact with the AI, manage their dialog history, and check the server status. The API is designed to be flexible and extensible, allowing for future integration with different AI models and front-end applications.

Installation and Setup Instructions

  1. Clone the repository:

    bash git clone <repository_url> cd waifu-chat-api 2. Install dependencies: bash pip install -r requirements.txt --user You may create a requirements.txt by running: bash pip freeze > requirements.txt

  2. Set environment variables:

    The API relies on environment variables for configuration. You can set these variables directly in your terminal or, preferably, using a .env file.

    Example using a .env file (recommended):

    1. Create a .env file in the project root:

      DATABASE_FILE=dialogs.db MODEL_URL=http://localhost:80/path/ DEFAULT_RESPONSE="I'm sorry, I'm having trouble connecting to the AI model." DEFAULT_GENRE="Fantasy" 2. Install python-dotenv: bash pip install python-dotenv --user 3. Add the following lines to the top of src/waifuapi.py to load the environment variables: python from dotenv import load_dotenv load_dotenv()

  3. Run the application:

    bash python src/waifuapi.py The default port is 5000. You can specify a different port by setting the PORT environment variable.

    To run the application in different environments:

    Note: The API uses the current-user header to identify the user making the request. This header is used to distinguish between different WaifuAPI users, allowing each user to have their own set of users and dialog history. If this header is not provided, the API defaults to a generic user ID.

API Documentation

The API provides the following endpoints:

User Management

Dialog Management

Server Status

HTTP Methods

The API uses the following HTTP methods:

Configuration

The API can be configured using environment variables. The following environment variables are supported:

Troubleshooting