Skip to main content

KISS AI Stack's Server stub - Simplify AI Agent Development

Project description

KISS AI Stack Banner

KISS AI Stack - Server

The KISS AI Stack Server is an server stub designed to support RESTful and WebSocket APIs for handling AI-agent sessions with kiss-ai-stack-core tasks like agent lifecycle management, query execution, and document storage.

Features

  • REST API for authentication, session actions, queries, and document storage.
  • WebSocket API for real-time, event-driven interactions.
  • Built-in persistent and temporary session management.
  • Flexible architecture to handle server events though AI agent's lifecycle events.

Agent's session lifecycle Events

  • ON_AUTH: Authenticate a session.
  • ON_INIT: Initialize a session.
  • ON_CLOSE: Close a session.
  • ON_QUERY: Execute a query.
  • ON_STORE: Store documents.

Getting Started

Requirements

  • Python 3.12

Installation

  1. Install kiss-ai-stack-server package:

    pip install kiss-ai-stack-server
    
  2. Set environment variables file

    # .env
     ACCESS_TOKEN_SECRET_KEY = "your-secure-random-secret-key"
     ACCESS_TOKEN_ALGORITHM = "HS256"
     ACCESS_TOKEN_EXPIRE_MINUTES = 30
    
     SESSION_DB_URL="sqlite://sessions.db"
    
  3. Run the server:

    from kiss_ai_stack_server import bootstrap_session_schema, agent_server
    

REST API Endpoints

1. Authentication

Endpoint: /auth
Method: POST
Request Body:

{
  "client_id": "string",
  "client_secret": "string"
}

Response:

{
  "session_id": "string",
  "access_token": "string",
  "expires_in": 3600
}

2. Session Actions

Endpoint: /sessions?action={init|close}
Method: POST
Query Parameter:

  • action (required): Action to perform on the session (init or close).

Request Body:

{
  "session_id": "string"
}

Response: Session-related details or status.


3. Query Execution

Endpoint: /queries
Method: POST
Request Body:

{
  "query": "string",
  "parameters": {
    "key": "value"
  }
}

Response: Query results.


4. Document Storage

Endpoint: /documents
Method: POST
Request Body:

{
  "documents": [
    {
      "id": "string",
      "content": "string",
      "metadata": {}
    }
  ]
}

Response: Document storage confirmation.


WebSocket API

Endpoint: /ws

Workflow

  1. Establish a WebSocket connection:

    ws://localhost:8080/ws
    
  2. Send a message:

    {
      "event": "ON_QUERY",
      "data": {
        "query": "example query",
        "parameters": {
          "key": "value"
        }
      }
    }
    
  3. Receive a response:

    {
      "event": "ON_QUERY",
      "result": {
        "response_key": "response_value"
      }
    }
    

Contributing

Contributions are welcome! Feel free to fork the repository and submit a pull request.


License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiss_ai_stack_server-0.1.0a3.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kiss_ai_stack_server-0.1.0a3-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file kiss_ai_stack_server-0.1.0a3.tar.gz.

File metadata

  • Download URL: kiss_ai_stack_server-0.1.0a3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for kiss_ai_stack_server-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 5300f5ef5c8f0afd3762e3be0a7be99757c6b524b72cd30bab670ff395a8f2e2
MD5 3a93f4d85204a898984aa3ffab0601df
BLAKE2b-256 81b720e56d0b609e5fece33207c24cbfc5bab9891a36fb49301de8eac9e11404

See more details on using hashes here.

File details

Details for the file kiss_ai_stack_server-0.1.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for kiss_ai_stack_server-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b96dbb0ef45f159a83ccf6a58fe05e64ef1050f62e3084bcd733acb37d06131
MD5 e2e387841fa386c8623976cc6fe25d53
BLAKE2b-256 0645c7069d559d01b6ec5786dd71c930bd213d2c21b33b5d82181e7998e818c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page