Skip to content

AIMOverse/AIMO-Models

Repository files navigation

AIMO: Emotional Companion Language Model Backends

AIMO is a lightweight, large-language model backend designed to provide emotional companionship through conversations. It is optimized for generating empathetic and engaging responses, making it an ideal solution for emotional companion toys and applications.

Features

  • Emotional Engagement: Provides empathetic and meaningful responses to user inputs, fostering an emotional connection.
  • Lightweight and Efficient: Optimized for performance on devices with GPU or CPU, ensuring smooth interactions.
  • Customizable: Easily adaptable for specific use cases or personalized prompts, enabling tailored interactions.

Installation

Requirements

  • Python 3.6 or higher
  • CUDA 12.4 (for GPU support)

Method 1: Standard Setup

Follow the steps below to set up AIMO on your system:

# Clone the repository
git clone https://github.com/AIMOverse/AIMO-Models.git
cd AIMO-Models

# Install dependencies
pip install -r requirements.txt

Method 2: Docker Setup

AIMO can also be deployed using Docker for easier dependency management and deployment:

# Clone the repository
git clone https://github.com/AIMOverse/AIMO-Models.git
cd AIMO-Models

# Build Docker Image and pass HF_ACCESS_TOKEN
docker build --build-arg HF_ACCESS_TOKEN=<your_hf_access_token> -t aimo-models-app .

# Run the Docker container
docker run --hostname ai-model-service -p 8000:8000 -e NEBULA_API_KEY=<your_key> -e SECRET_KEY=<your_secret_key> -e ADMIN_API_KEY=<your_admin_api_key> -e DATABASE_URL=<your_database_url> aimo-models-app

Deployment on Phala Network

To deploy AIMO on Phala Network, follow these steps:

  1. Ensure you have the necessary API keys:

    • HF_ACCESS_TOKEN: For downloading Hugging Face models
  2. Build the Docker image with the required environment variables:

# Export your API keys as environment variables
export HF_ACCESS_TOKEN="your_huggingface_token_here"

# Build the Docker image
docker build --build-arg HF_ACCESS_TOKEN=$HF_ACCESS_TOKEN -t aimoverse/aimo-emotion-model .
  1. Push the image to a container registry accessible by the Phala Network:
# Tag the image for your registry
docker tag aimoverse/aimo-emotion-model your-registry/aimoverse/aimo-emotion-model:latest

# Push to registry
docker push your-registry/aimoverse/aimo-emotion-model:latest
  1. Deploy on Phala using their container deployment interface.

Environment Variables

The following environment variables are used by AIMO:

Variable Description Required Time of Requirement
HF_ACCESS_TOKEN Hugging Face access token for downloading models Yes During building Images
NEBULA_API_KEY API key for LLM service Yes During running applications
SECRET_KEY Secret Key for JWT Tokens Yes During running applications
ADMIN_API_KEY Admin Key for manage invitation codes Yes During running applications

LiteLLM Proxy Service

AIMO integrates with LiteLLM Proxy to provide multi-provider LLM support through a unified interface. This enables routing to different LLM providers (OpenAI, Anthropic, OpenRouter, local models) with automatic fallback capabilities.

Setup LiteLLM Service

  1. Configure Environment Variables

    Add the following to your .env file:

    # LiteLLM Proxy Configuration
    LLM_BASE_URL=http://localhost:4000
    LLM_API_KEY=sk-litellm-proxy-key
    LLM_MODEL_DEFAULT=prod_default
    LLM_TIMEOUT=60
    
    # LiteLLM Master Key
    LITELLM_MASTER_KEY=sk-litellm-proxy-key
    
    # Provider API Keys (add as needed)
    OPENROUTER_API_KEY=your_openrouter_key_here
  2. Start LiteLLM Proxy Service

    # Navigate to the LiteLLM directory
    cd infra/litellm
    
    # Start the LiteLLM Proxy using Docker Compose
    docker-compose -f docker-compose.litellm.yml up -d
  3. Verify LiteLLM Service

    # Check if LiteLLM Proxy is running
    curl http://localhost:4000/health
    
    # Test the new endpoints
    curl -X GET http://localhost:8000/api/v1.0.0/chat/health
    curl -X GET http://localhost:8000/api/v1.0.0/chat/models
  4. Stop LiteLLM Service

    # Stop the LiteLLM Proxy
    cd infra/litellm
    docker-compose -f docker-compose.litellm.yml down

LiteLLM Benefits

  • Multi-Provider Support: Route to different LLM providers through one interface
  • Automatic Fallbacks: Fallback to alternative models if primary fails
  • Cost Optimization: Route to cheaper models when appropriate
  • Local Model Integration: Support for local models via Ollama
  • Centralized Configuration: Manage all LLM configurations in one place

Usage

Start the AIMO server using the following command:

# If installed directly
fastapi run app/main.py
# If using Docker
docker run --hostname ai-model-service -p 8000:8000 -e NEBULA_API_KEY=your_key -e SECRET_KEY=your_secret_key -e ADMIN_API_KEY=your_admin_api_key -e DATABASE_URL=your_database_url -d aimoverse/aimo-emotion-model

Once the server is running, you can integrate it with your applications or test it through API endpoints.

Test

Please Test the server before push!!!

Test the server using the command below:

coverage run --source=app -m pytest
coverage report --show-missing
coverage html --title "${@-coverage}"

API Overview

Version: 1.0.0

The AIMO backend provides a RESTful API for interaction. The version 1.0.0 of the server has a base url of /api/v1.0.0. Below are the main endpoints:

Original AIMO Endpoint: /api/v1.0.0/chat/

Method: POST

Request Body:

{
    "messages": [
        {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_new_tokens": 100,
    "stream": false
}

LiteLLM Proxy Endpoints

Chat Completion: /api/v1.0.0/chat/completions_proxy

Method: POST

Request Body:

{
    "model": "prod_default",
    "messages": [
        {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_tokens": 100,
    "stream": false
}

Available Models: /api/v1.0.0/chat/models

Method: GET

Returns list of available LLM models configured in LiteLLM.

Health Check: /api/v1.0.0/chat/health

Method: GET

Returns LiteLLM Proxy connection status.

Response:

{
   "id": "chatcmpl-8ca23289-da13-4374-87a4-9020f5bbbebe",
   "object": "chat.completion",
   "created": 1741649537,
   "model": "aimo-chat",
   "choices": [
      {
         "index": 0,
         "message": {
            "role": "assistant",
            "content": "Hello! It's nice to meet you. How's your day going so far?"
         },
         "delta": null,
         "finish_reason": "stop"
      }
   ],
   "usage": {
      "prompt_tokens": 0,
      "completion_tokens": 0,
      "total_tokens": 0
   }
}

Contributing

We welcome contributions to improve AIMO! Please fork the repository, make changes, and submit a pull request. Ensure your code adheres to the project's coding standards.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •