Skip to content

Commit

Permalink
Merge pull request #18 from video-db/ankit/add-documentation
Browse files Browse the repository at this point in the history
Ankit/add documentation
  • Loading branch information
ashish-spext authored Oct 28, 2024
2 parents 1d81c01 + 49ea490 commit 654a124
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 11 deletions.
21 changes: 20 additions & 1 deletion backend/spielberg/entrypoint/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,52 @@


class BaseAppConfig:
"""Base configuration for the app."""

DEBUG: bool = 1
"""Debug mode for the app."""
TESTING: bool = 1
"""Testing mode for the app."""
SECRET_KEY: str = "secret"
"""Secret key for the app."""
LOGGING_CONFIG: dict = LOGGING_CONFIG
"""Logging configuration for the app."""
DB_TYPE: str = "sqlite"
"""Database type for the app."""
HOST: str = "0.0.0.0"
"""Host for the app."""
PORT: int = 8000
"""Port for the app."""
ENV_PREFIX: str = "SERVER"


class LocalAppConfig(BaseAppConfig):
"""Local configuration for the app. All the default values can be change using environment variables. e.g. `SERVER_PORT=8001`"""

TESTING: bool = 0
"""Testing mode for the app."""


class ProductionAppConfig(BaseAppConfig):
"""Production configuration for the app. All the default values can be change using environment variables. e.g. SERVER_PORT=8001"""

DEBUG: bool = 0
"""Debug mode for the app."""
TESTING: bool = 0
"""Testing mode for the app."""
SECRET_KEY: str = "production"
"""Secret key for the app."""


configs = dict(local=LocalAppConfig, production=ProductionAppConfig)


# By default, the server is configured to run in development mode. To run in production mode, set the `SERVER_ENV` environment variable to `production`.
app = create_app(app_config=configs[os.getenv("SERVER_ENV", "local")])

if __name__ == "__main__":
app.run(
host=os.getenv("SERVER_HOST", app.config["HOST"]),
port=os.getenv("SERVER_PORT", app.config["PORT"]),
reloader_type="stat"
reloader_type="stat",
)
3 changes: 3 additions & 0 deletions backend/spielberg/entrypoint/api/socket_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@


class ChatNamespace(Namespace):
"""Chat namespace for socket.io"""

def on_chat(self, message):
"""Handle chat messages"""
chat_handler = ChatHandler(
db=load_db(os.getenv("SERVER_DB_TYPE", app.config["DB_TYPE"]))
)
Expand Down
178 changes: 170 additions & 8 deletions docs/server/api.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## API Routes
# API Routes

Routes are defined in the `routes` folder.


## Agent routes
## GET /agent

### GET /agent

Return the agent information

Expand All @@ -19,35 +20,196 @@ Return the agent information
"name": "download"
},
{
"description": "Agent to get information about the pricing and usage of VideoDB, it is also helpful for running scenarios to get the estimates.",
"description": "Agent to get information about the VideoDB pricing and usage.",
"name": "pricing"
}
]
```

## Session routes

## GET /session
### GET /session

Returns all the sessions

```json
[
{
"collection_id": "c-890bd0a5-2ec3-47c0-86dc-685953995206",
"collection_id": "c-**",
"created_at": 1729092742,
"metadata": {},
"session_id": "52881f6b-7560-4844-ac35-52af41d07ab8",
"updated_at": 1729092742,
"video_id": "m-138de44f-d963-4a4c-a239-a30df4dc496a"
"video_id": "m-**"
},
{
"collection_id": "c-890bd0a5-2ec3-47c0-86dc-685953995206",
"collection_id": "c-**",
"created_at": 1729092642,
"metadata": {},
"session_id": "6bf075a7-e7d4-4aba-985c-4cf0d3dc6f5b",
"updated_at": 1729092642,
"video_id": "m-13d436a6-ad61-410d-b51c-5ebd80e87066"
"video_id": "m-**"
}
]
```

### GET /session/:session_id

Returns the session

```json
{
"collection_id": "c-**",
"conversation": [
{
"actions": [],
"agents": [],
"content": [
{
"text": "No of video in my collection?",
"type": "text"
}
],
"conv_id": "b36c0a31-3c95-4f48-a1aa-daad351a30c3",
"created_at": 1729852558,
"metadata": {},
"msg_id": "1b753948-3672-446d-a7ab-ecd623d4244a",
"msg_type": "input",
"session_id": "33a41576-ffb3-4cec-993c-eedd728c21ac",
"status": "success",
"updated_at": 1729852558
},
{
"actions": [
"Reasoning the message.."
],
"agents": [],
"content": [
{
"agent_name": null,
"status": "success",
"status_message": "Here is the summary of the response",
"text": "There are 36 videos in your collection.",
"type": "text"
}
],
"conv_id": "b36c0a31-3c95-4f48-a1aa-daad351a30c3",
"created_at": 1729852562,
"metadata": {},
"msg_id": "172985255862403.2",
"msg_type": "output",
"session_id": "33a41576-ffb3-4cec-993c-eedd728c21ac",
"status": "success",
"updated_at": 1729852562
}
],
"created_at": 1729852558,
"metadata": {},
"session_id": "33a41576-ffb3-4cec-993c-eedd728c21ac",
"updated_at": 1729852558,
"video_id": null
}
```

### DELETE /session/:session_id

Deletes the session

```json
{
"message": "Session deleted successfully."
}
```


## VideoDB routes

### GET /videodb/collection

Returns all the collections

```json
[
{
"description": "Test collection",
"id": "c-**",
"name": "Ankit Raj's collection"
},
{
"description": "Test1 collection",
"id": "c-**",
"name": "Ankit Raj's collection"
},
]
```

### GET /videodb/collection/:collection_id

Returns the collection

```json
{
"description": "Test collection",
"id": "c-**",
"name": "Ankit Raj's collection"
}
```


### GET /videodb/collection/:collection_id/video

Returns all the videos in the collection

```json
[
{
"collection_id": "c-**",
"description": null,
"id": "m-**",
"length": 1247.468844,
"name": "Test video",
"stream_url": "https://stream.videodb.io/v3/published/manifests/test.m3u8",
"thumbnail_url": null
},
{
"collection_id": "c-**",
"description": null,
"id": "m-**",
"length": 155.620136,
"name": "Test video",
"stream_url": "https://stream.videodb.io/v3/published/manifests/test.m3u8",
"thumbnail_url": null
},
]
```

### GET /videodb/collection/:collection_id/video/:video_id

Returns the video

```json
{
"collection_id": "c-**",
"description": null,
"id": "m-**",
"length": 1247.468844,
"name": "Test video",
"stream_url": "https://stream.videodb.io/v3/published/manifests/test.m3u8",
"thumbnail_url": null
}
```


## Config routes

### GET /config/check

Check the configuration

```json
{
"db_configured": true,
"llm_configured": true,
"videodb_configured": true
}
```
2 changes: 1 addition & 1 deletion docs/server/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Server is the entry point for the application. Implemented using Flask and Socke

## Server Config

::: spielberg.entrypoint.api.server.BaseAppConfig
By default, the server is configured to run in development mode. To run in production mode, set the `SERVER_ENV` environment variable to `production`.

::: spielberg.entrypoint.api.server.LocalAppConfig

Expand Down
2 changes: 1 addition & 1 deletion docs/server/socketio.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ WebSocket routes are defined in the `sockets` folder.

### Chat Namespace

<!-- ::: spielberg.entrypoint.api.socket.chat_namespace.ChatNamespace -->
::: spielberg.entrypoint.api.socket_io.ChatNamespace

0 comments on commit 654a124

Please sign in to comment.