Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ A signed-in member can pass `projectId` + `notificationId` instead of `hash`.
The gateway answers `401` for a bad or expired link, `403` for a missing
permission and `400` for a malformed request.

## End-user AI chat and project AI settings

A signed-in project user (bearer token from login) talks to the project's AI
assistant through `norbix.api.ai`. `start_end_user_chat_turn` answers at once
with a `turnId`; the answer streams over the gateway's SSE endpoint on the
user's own channel `ai-chat:{projectId}:{authId}` (events `ai.chat.turn.*`,
`ai.chat.session.*`). A subscription to another user's channel is refused with
403 and `responseStatus.errorCode = "AiChatChannelRefused"` — do not retry it.

```python
avail = norbix.api.ai.get_end_user_chat_availability()
session = norbix.api.ai.create_end_user_chat_session(title="Help")
turn = norbix.api.ai.start_end_user_chat_turn(sessionId=session["id"], message="What can you do?")
entries = norbix.api.ai.get_end_user_chat_entries(session_id=session["id"])
```

Project owners configure the assistant on the Hub: `norbix.hub.account`
(`get_project_ai_settings`, `update_project_ai_settings`,
`create_project_ai_assistant`, `update_project_ai_assistant`,
`delete_project_ai_assistant`, `get_project_ai_usage`, `set_admin_portal_enabled`)
and `norbix.hub.ai` (`get_embedding_integrations`, `save_embedding_integration`,
`get_embedding_integration`, `delete_embedding_integration`,
`test_embedding_integration`, `set_llm_integration_as_default`). Full tables:
[docs/api/ai.md](./docs/api/ai.md), [docs/hub/ai.md](./docs/hub/ai.md),
[docs/hub/account.md](./docs/hub/account.md).

## Errors

```python
Expand Down
1 change: 1 addition & 0 deletions docs/api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Module | Endpoints |
| --- | ---: |
| [`ai`](./ai.md) | 16 |
| [`database`](./database.md) | 18 |
| [`echo`](./echo.md) | 1 |
| [`files`](./files.md) | 10 |
Expand Down
24 changes: 24 additions & 0 deletions docs/api/ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# API · Ai

Access with `norbix.api.ai`. End-user AI chat for a signed-in project user (bearer token from login).

`start_end_user_chat_turn` answers at once with a `turnId`; tokens, tool calls and the final answer arrive over the gateway's SSE stream on the user's channel `ai-chat:{projectId}:{authId}` (`ai.chat.turn.started|token|tool|completed|failed`, `ai.chat.session.*`). A channel that is not the caller's is refused with 403 and `responseStatus.errorCode = "AiChatChannelRefused"` before the stream starts — do not retry it.

| Method | Verb | Path | Scope |
| --- | --- | --- | --- |
| `get_end_user_chat_availability` | `GET` | `/{version}/ai/chat/availability` | `project` |
| `list_end_user_chat_sessions` | `GET` | `/{version}/ai/chat/sessions` | `project` |
| `create_end_user_chat_session` | `POST` | `/{version}/ai/chat/sessions` | `project` |
| `get_end_user_chat_session` | `GET` | `/{version}/ai/chat/sessions/{SessionId}` | `project` |
| `rename_end_user_chat_session` | `PATCH` | `/{version}/ai/chat/sessions/{SessionId}` | `project` |
| `delete_end_user_chat_session` | `DELETE` | `/{version}/ai/chat/sessions/{SessionId}` | `project` |
| `pin_end_user_chat_session` | `PUT` | `/{version}/ai/chat/sessions/{SessionId}/pin` | `project` |
| `archive_end_user_chat_session` | `PUT` | `/{version}/ai/chat/sessions/{SessionId}/archive` | `project` |
| `get_end_user_chat_entries` | `GET` | `/{version}/ai/chat/sessions/{SessionId}/entries` | `project` |
| `set_end_user_chat_entry_feedback` | `PUT` | `/{version}/ai/chat/sessions/{SessionId}/entries/{EntryId}/feedback` | `project` |
| `list_end_user_chat_attachments` | `GET` | `/{version}/ai/chat/sessions/{SessionId}/attachments` | `project` |
| `upload_end_user_chat_attachment` | `POST` | `/{version}/ai/chat/sessions/{SessionId}/attachments` | `project` |
| `delete_end_user_chat_attachment` | `DELETE` | `/{version}/ai/chat/attachments/{AttachmentId}` | `project` |
| `list_end_user_chat_memory` | `GET` | `/{version}/ai/chat/memory` | `project` |
| `forget_end_user_chat_memory` | `DELETE` | `/{version}/ai/chat/memory/{NoteId}` | `project` |
| `start_end_user_chat_turn` | `POST` | `/{version}/ai/chat/turn` | `project` |
7 changes: 7 additions & 0 deletions docs/hub/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ Access with `norbix.hub.account`.
| `get_account_collaborators` | `GET` | `/{version}/account/collaborators` | `account` |
| `send_invite_to_team_member` | `POST` | `/{version}/account/team/member/invite` | `account` |
| `get_licenses` | `GET` | `/{version}/account/licenses` | `account` |
| `get_project_ai_settings` | `GET` | `/{version}/account/projects/{projectId}/ai/settings` | `project` |
| `update_project_ai_settings` | `PUT` | `/{version}/account/projects/{projectId}/ai/settings` | `project` |
| `create_project_ai_assistant` | `POST` | `/{version}/account/projects/{projectId}/ai/assistants` | `project` |
| `update_project_ai_assistant` | `PUT` | `/{version}/account/projects/{projectId}/ai/assistants/{assistantId}` | `project` |
| `delete_project_ai_assistant` | `DELETE` | `/{version}/account/projects/{projectId}/ai/assistants/{assistantId}` | `project` |
| `get_project_ai_usage` | `GET` | `/{version}/account/projects/{projectId}/ai/usage` | `project` |
| `set_admin_portal_enabled` | `PUT` | `/{version}/account/projects/{projectId}/admin-portal/enabled` | `project` |
6 changes: 6 additions & 0 deletions docs/hub/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ Access with `norbix.hub.ai`.
| `get_mcp_integrations` | `GET` | `/{version}/ai/integrations/mcp/integrations` | `project` |
| `save_mcp_integration` | `POST` | `/{version}/ai/integrations/mcp/` | `project` |
| `test_mcp_integration` | `POST` | `/{version}/ai/integrations/mcp/test` | `project` |
| `get_embedding_integrations` | `GET` | `/{version}/ai/integrations/embeddings` | `project` |
| `save_embedding_integration` | `POST` | `/{version}/ai/integrations/embeddings` | `project` |
| `get_embedding_integration` | `GET` | `/{version}/ai/integrations/embeddings/{Id}` | `project` |
| `delete_embedding_integration` | `DELETE` | `/{version}/ai/integrations/embeddings/{Id}` | `project` |
| `test_embedding_integration` | `POST` | `/{version}/ai/integrations/embeddings/{Id}/test` | `project` |
| `set_llm_integration_as_default` | `PUT` | `/{version}/ai/integrations/llms/{Id}/default` | `project` |
3 changes: 3 additions & 0 deletions src/norbix_python/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from ..transport import AsyncTransport, Transport
from .ai import AiModule, AsyncAiModule
from .database import AsyncDatabaseModule, DatabaseModule
from .echo import AsyncEchoModule, EchoModule
from .files import AsyncFilesModule, FilesModule
Expand All @@ -9,6 +10,7 @@

class ApiNamespace:
def __init__(self, transport: Transport) -> None:
self.ai = AiModule(transport)
self.database = DatabaseModule(transport)
self.echo = EchoModule(transport)
self.files = FilesModule(transport)
Expand All @@ -17,6 +19,7 @@ def __init__(self, transport: Transport) -> None:

class AsyncApiNamespace:
def __init__(self, transport: AsyncTransport) -> None:
self.ai = AsyncAiModule(transport)
self.database = AsyncDatabaseModule(transport)
self.echo = AsyncEchoModule(transport)
self.files = AsyncFilesModule(transport)
Expand Down
Loading
Loading