<div style="text-align: left; margin-bottom: 20px;">
<img src="https://kiss-ai-stack.github.io/kissaistack.svg" alt="KISS AI Stack Banner" style="max-width: auto; height: 250px">
</div>
# 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:
```bash
pip install kiss-ai-stack-server
```
2. Set environment variables file
```bash
# .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:
```bash
from kiss_ai_stack_server import bootstrap_session_schema, agent_server
```
---
## REST API Endpoints
### 1. Authentication
**Endpoint:** `/auth`
**Method:** `POST`
**Request Body:**
```json
{
"client_id": "string",
"client_secret": "string"
}
```
**Response:**
```json
{
"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:**
```json
{
"session_id": "string"
}
```
**Response:** Session-related details or status.
---
### 3. Query Execution
**Endpoint:** `/queries`
**Method:** `POST`
**Request Body:**
```json
{
"query": "string",
"parameters": {
"key": "value"
}
}
```
**Response:** Query results.
---
### 4. Document Storage
**Endpoint:** `/documents`
**Method:** `POST`
**Request Body:**
```json
{
"documents": [
{
"id": "string",
"content": "string",
"metadata": {}
}
]
}
```
**Response:** Document storage confirmation.
---
## WebSocket API
**Endpoint:** `/ws`
### Workflow
1. Establish a WebSocket connection:
```bash
ws://localhost:8080/ws
```
2. Send a message:
```json
{
"event": "ON_QUERY",
"data": {
"query": "example query",
"parameters": {
"key": "value"
}
}
}
```
3. Receive a response:
```json
{
"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.
Raw data
{
"_id": null,
"home_page": null,
"name": "kiss-ai-stack-server",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "ai, agent, machine-learning, llm, document-processing",
"author": "KISS AI Stack, Lahiru Pathirage",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/27/5a/e033d0fab88227012bb299b86ea072eec4fdd162c7edee1ea5d6e886130d/kiss_ai_stack_server-0.1.0a17.tar.gz",
"platform": null,
"description": "<div style=\"text-align: left; margin-bottom: 20px;\">\n <img src=\"https://kiss-ai-stack.github.io/kissaistack.svg\" alt=\"KISS AI Stack Banner\" style=\"max-width: auto; height: 250px\">\n</div>\n\n\n# KISS AI Stack - Server\n\nThe 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.\n\n## Features\n\n- REST API for authentication, session actions, queries, and document storage.\n- WebSocket API for real-time, event-driven interactions.\n- Built-in persistent and temporary session management.\n- Flexible architecture to handle server events though AI agent's lifecycle events.\n\n---\n\n### Agent's session lifecycle Events\n\n- `ON_AUTH`: Authenticate a session.\n- `ON_INIT`: Initialize a session.\n- `ON_CLOSE`: Close a session.\n- `ON_QUERY`: Execute a query.\n- `ON_STORE`: Store documents.\n\n---\n\n## Getting Started\n\n### Requirements\n\n- Python 3.12\n\n### Installation\n\n1. Install kiss-ai-stack-server package:\n ```bash\n pip install kiss-ai-stack-server\n ```\n2. Set environment variables file\n ```bash\n # .env\n ACCESS_TOKEN_SECRET_KEY = \"your-secure-random-secret-key\"\n ACCESS_TOKEN_ALGORITHM = \"HS256\"\n ACCESS_TOKEN_EXPIRE_MINUTES = 30\n\n SESSION_DB_URL=\"sqlite://sessions.db\"\n ```\n\n3. Run the server:\n ```bash\n from kiss_ai_stack_server import bootstrap_session_schema, agent_server\n \n \n ```\n\n---\n\n## REST API Endpoints\n\n### 1. Authentication\n\n**Endpoint:** `/auth` \n**Method:** `POST` \n**Request Body:**\n```json\n{\n \"client_id\": \"string\",\n \"client_secret\": \"string\"\n}\n```\n**Response:**\n```json\n{\n \"session_id\": \"string\",\n \"access_token\": \"string\",\n \"expires_in\": 3600\n}\n```\n\n---\n\n### 2. Session Actions\n\n**Endpoint:** `/sessions?action={init|close}` \n**Method:** `POST` \n**Query Parameter:**\n- `action` (required): Action to perform on the session (`init` or `close`).\n\n**Request Body:**\n```json\n{\n \"session_id\": \"string\"\n}\n```\n**Response:** Session-related details or status.\n\n---\n\n### 3. Query Execution\n\n**Endpoint:** `/queries` \n**Method:** `POST` \n**Request Body:**\n```json\n{\n \"query\": \"string\",\n \"parameters\": {\n \"key\": \"value\"\n }\n}\n```\n**Response:** Query results.\n\n---\n\n### 4. Document Storage\n\n**Endpoint:** `/documents` \n**Method:** `POST` \n**Request Body:**\n```json\n{\n \"documents\": [\n {\n \"id\": \"string\",\n \"content\": \"string\",\n \"metadata\": {}\n }\n ]\n}\n```\n**Response:** Document storage confirmation.\n\n---\n\n## WebSocket API\n\n**Endpoint:** `/ws`\n\n### Workflow\n\n1. Establish a WebSocket connection:\n ```bash\n ws://localhost:8080/ws\n ```\n\n2. Send a message:\n ```json\n {\n \"event\": \"ON_QUERY\",\n \"data\": {\n \"query\": \"example query\",\n \"parameters\": {\n \"key\": \"value\"\n }\n }\n }\n ```\n\n3. Receive a response:\n ```json\n {\n \"event\": \"ON_QUERY\",\n \"result\": {\n \"response_key\": \"response_value\"\n }\n }\n ```\n\n\n\n## Contributing\n\nContributions are welcome! Feel free to fork the repository and submit a pull request.\n\n---\n\n## License\n\nThis project is licensed under the MIT License.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "KISS AI Stack's Server stub - Simplify AI Agent Development",
"version": "0.1.0a17",
"project_urls": {
"Documentation": "https://github.com/kiss-ai-stack/kiss-ai-stack-core/main/README.md",
"Homepage": "https://github.com/kiss-ai-stack",
"Repository": "https://github.com/kiss-ai-stack"
},
"split_keywords": [
"ai",
" agent",
" machine-learning",
" llm",
" document-processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ea7e138644af8a99da572ffec0c76708df225f643a6fe88f1614b6ffaeab4f12",
"md5": "7bc7530c9dd151abeeef2389833ae366",
"sha256": "3e923823f4e4f3feb3cae467e018d95e0e4f059f61902fbf9ca9535a224d8a61"
},
"downloads": -1,
"filename": "kiss_ai_stack_server-0.1.0a17-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7bc7530c9dd151abeeef2389833ae366",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 17839,
"upload_time": "2024-12-15T18:22:13",
"upload_time_iso_8601": "2024-12-15T18:22:13.381326Z",
"url": "https://files.pythonhosted.org/packages/ea/7e/138644af8a99da572ffec0c76708df225f643a6fe88f1614b6ffaeab4f12/kiss_ai_stack_server-0.1.0a17-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "275ae033d0fab88227012bb299b86ea072eec4fdd162c7edee1ea5d6e886130d",
"md5": "f68015d00360020a92d4f051b862a59d",
"sha256": "2a4fd53577d9f7c337c1c552c57ae8af546de8ebe67633e7c448de0b863e4a7a"
},
"downloads": -1,
"filename": "kiss_ai_stack_server-0.1.0a17.tar.gz",
"has_sig": false,
"md5_digest": "f68015d00360020a92d4f051b862a59d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 13091,
"upload_time": "2024-12-15T18:22:15",
"upload_time_iso_8601": "2024-12-15T18:22:15.977846Z",
"url": "https://files.pythonhosted.org/packages/27/5a/e033d0fab88227012bb299b86ea072eec4fdd162c7edee1ea5d6e886130d/kiss_ai_stack_server-0.1.0a17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-15 18:22:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kiss-ai-stack",
"github_project": "kiss-ai-stack-core",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiofiles",
"specs": [
[
"~=",
"24.1.0"
]
]
},
{
"name": "asyncio",
"specs": [
[
"~=",
"3.4.3"
]
]
},
{
"name": "PyYAML",
"specs": [
[
"~=",
"6.0.2"
]
]
},
{
"name": "pydantic",
"specs": [
[
"~=",
"2.10.3"
]
]
},
{
"name": "setuptools",
"specs": [
[
"~=",
"75.6.0"
]
]
},
{
"name": "unstructured",
"specs": [
[
"~=",
"0.16.8"
]
]
},
{
"name": "unstructured",
"specs": [
[
"~=",
"0.16.8"
]
]
},
{
"name": "unstructured",
"specs": [
[
"~=",
"0.16.8"
]
]
},
{
"name": "unstructured",
"specs": [
[
"~=",
"0.16.8"
]
]
},
{
"name": "unstructured",
"specs": [
[
"~=",
"0.16.8"
]
]
},
{
"name": "tiktoken",
"specs": [
[
"~=",
"0.8.0"
]
]
},
{
"name": "tokenizers",
"specs": [
[
"~=",
"0.20.3"
]
]
},
{
"name": "pandas",
"specs": [
[
"~=",
"2.2.3"
]
]
}
],
"lcname": "kiss-ai-stack-server"
}