rusticai-api 0.0.5__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/PKG-INFO +9 -8
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/README.md +2 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/pyproject.toml +8 -11
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/catalog/catalog_store.py +20 -39
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/catalog/models.py +2 -7
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/catalog/router.py +32 -26
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/comms_manager.py +5 -2
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/router.py +10 -12
- rusticai_api-0.1.0/src/rustic_ai/api_server/guilds/schema.py +21 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/service.py +23 -5
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/main.py +3 -6
- rusticai_api-0.0.5/src/rustic_ai/api_server/guilds/schema.py +0 -5
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/__init__.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/api_dependency_manager.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/catalog/__init__.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/__init__.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/socket.py +1 -1
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/system_comms_manager.py +1 -1
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/logging/__init__.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/logging/config.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/logging/format.py +0 -0
- {rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/main_debug.py +0 -0
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: rusticai-api
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.1.0
|
|
4
4
|
Summary: API Server for Rustic AI
|
|
5
|
-
Home-page: https://www.rustic.ai/
|
|
6
5
|
License: Apache-2.0
|
|
7
6
|
Author: Dragonscale Industries Inc.
|
|
8
7
|
Author-email: dev@dragonscale.ai
|
|
9
|
-
Requires-Python: >=3.12,<
|
|
8
|
+
Requires-Python: >=3.12,<3.13
|
|
10
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
10
|
Classifier: Programming Language :: Python :: 3
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
12
|
Provides-Extra: test
|
|
15
13
|
Requires-Dist: fastapi (>=0.115.8,<0.116.0)
|
|
16
14
|
Requires-Dist: griffe (>=1.7.2,<2.0.0)
|
|
@@ -18,12 +16,13 @@ Requires-Dist: opentelemetry-distro (>=0.52b1,<0.53)
|
|
|
18
16
|
Requires-Dist: psycopg (>=3.2.6,<4.0.0)
|
|
19
17
|
Requires-Dist: ptvsd (>=4.3.2,<5.0.0)
|
|
20
18
|
Requires-Dist: python-multipart (>=0.0.20,<0.0.21)
|
|
21
|
-
Requires-Dist: rusticai-core (>=0.0
|
|
22
|
-
Requires-Dist: rusticai-ray (>=0.0
|
|
19
|
+
Requires-Dist: rusticai-core (>=0.1.0,<0.2.0)
|
|
20
|
+
Requires-Dist: rusticai-ray (>=0.1.0,<0.2.0)
|
|
23
21
|
Requires-Dist: starlette (>=0.45.3,<0.46.0)
|
|
24
22
|
Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
|
|
25
23
|
Requires-Dist: websockets (>=15.0.1,<16.0.0)
|
|
26
|
-
Project-URL:
|
|
24
|
+
Project-URL: Homepage, https://www.rustic.ai/
|
|
25
|
+
Project-URL: Repository, https://github.com/rustic-ai/rustic-ai
|
|
27
26
|
Project-URL: Rustic AI Core, https://pypi.org/project/rusticai-core/
|
|
28
27
|
Description-Content-Type: text/markdown
|
|
29
28
|
|
|
@@ -86,3 +85,5 @@ Traces will be visible in Zipkin UI at http://localhost:9411/zipkin/
|
|
|
86
85
|
|
|
87
86
|
Note: To stop the Zipkin server, use `./scripts/zipkin/zipkin_down.sh`
|
|
88
87
|
|
|
88
|
+
**To run with all the available `rusticai` packages, use the poetry environment from the root directory, and prefix commands with `api/` — for example, use `./api/scripts/dev_server_with_otel.sh` instead of `./scripts/dev_server_with_otel.sh`.**
|
|
89
|
+
|
|
@@ -56,3 +56,5 @@ for details.
|
|
|
56
56
|
Traces will be visible in Zipkin UI at http://localhost:9411/zipkin/
|
|
57
57
|
|
|
58
58
|
Note: To stop the Zipkin server, use `./scripts/zipkin/zipkin_down.sh`
|
|
59
|
+
|
|
60
|
+
**To run with all the available `rusticai` packages, use the poetry environment from the root directory, and prefix commands with `api/` — for example, use `./api/scripts/dev_server_with_otel.sh` instead of `./scripts/dev_server_with_otel.sh`.**
|
|
@@ -4,22 +4,22 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "rusticai-api"
|
|
7
|
-
version = "0.0
|
|
7
|
+
version = "0.1.0"
|
|
8
8
|
description = "API Server for Rustic AI"
|
|
9
9
|
authors = ["Dragonscale Industries Inc. <dev@dragonscale.ai>"]
|
|
10
10
|
license = "Apache-2.0"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
homepage = "https://www.rustic.ai/"
|
|
13
|
-
repository = "https://github.com/rustic-ai/
|
|
13
|
+
repository = "https://github.com/rustic-ai/rustic-ai"
|
|
14
14
|
packages = [{ include = "rustic_ai", from = "src" }]
|
|
15
15
|
|
|
16
16
|
[tool.poetry.urls]
|
|
17
17
|
"Rustic AI Core" = "https://pypi.org/project/rusticai-core/"
|
|
18
18
|
|
|
19
19
|
[tool.poetry.dependencies]
|
|
20
|
-
python = "
|
|
21
|
-
rusticai-core = { version = "0.0
|
|
22
|
-
rusticai-ray = { version = "0.0
|
|
20
|
+
python = ">=3.12,<3.13"
|
|
21
|
+
rusticai-core = { version = "0.1.0"}
|
|
22
|
+
rusticai-ray = { version = "0.1.0"}
|
|
23
23
|
fastapi = "^0.115.8"
|
|
24
24
|
starlette = "^0.45.3"
|
|
25
25
|
uvicorn = "^0.34.0"
|
|
@@ -45,7 +45,7 @@ isort = "^6.0.0"
|
|
|
45
45
|
mypy = "^1.15.0"
|
|
46
46
|
pytest-asyncio = "^0.25.3"
|
|
47
47
|
httpx = "^0.28.1"
|
|
48
|
-
rusticai-testing = { version = "0.0
|
|
48
|
+
rusticai-testing = { version = "0.1.0"}
|
|
49
49
|
|
|
50
50
|
[tool.poetry.extras]
|
|
51
51
|
test = ["pytest", "pytest-asyncio", "httpx", "rusticai-testing"]
|
|
@@ -77,11 +77,8 @@ explicit_package_bases = true
|
|
|
77
77
|
|
|
78
78
|
[tool.isort]
|
|
79
79
|
profile = "black"
|
|
80
|
+
force_sort_within_sections = true # For the sorting order issues
|
|
81
|
+
lines_between_sections = 1 # For the newline issue
|
|
80
82
|
known_third_party = ["pydantic"]
|
|
81
83
|
known_first_party = ["rustic_ai.core", "rustic_ai.ray"]
|
|
82
84
|
known_local_folder = ["rustic_ai.testing"]
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[tool.pytest.ini_options]
|
|
86
|
-
asyncio_mode = "auto"
|
|
87
|
-
asyncio_default_fixture_loop_scope="function"
|
|
@@ -32,7 +32,6 @@ from .models import (
|
|
|
32
32
|
BlueprintStarterPrompt,
|
|
33
33
|
BlueprintTag,
|
|
34
34
|
CatalogAgentEntry,
|
|
35
|
-
OrganizationGuild,
|
|
36
35
|
Tag,
|
|
37
36
|
UserGuild,
|
|
38
37
|
)
|
|
@@ -365,37 +364,7 @@ class CatalogStore:
|
|
|
365
364
|
|
|
366
365
|
return session.get(UserGuild, {"guild_id": guild_id, "user_id": user_id})
|
|
367
366
|
|
|
368
|
-
|
|
369
|
-
def get_org_guild(session, org_id: str, guild_id: str):
|
|
370
|
-
guild = session.get(GuildModel, guild_id)
|
|
371
|
-
if not guild:
|
|
372
|
-
raise HTTPException(status_code=404, detail=f"Guild {guild_id} not found")
|
|
373
|
-
|
|
374
|
-
return session.get(OrganizationGuild, {"guild_id": guild_id, "organization_id": org_id})
|
|
375
|
-
|
|
376
|
-
def add_org_to_guild(self, guild_id: str, org_id: str):
|
|
377
|
-
with Session(self.engine) as session:
|
|
378
|
-
existing_mapping = self.get_org_guild(session, org_id, guild_id)
|
|
379
|
-
if existing_mapping:
|
|
380
|
-
raise HTTPException(
|
|
381
|
-
status_code=409, detail=f"Organization {org_id} already associated with guild {guild_id}"
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
session.add(OrganizationGuild(guild_id=guild_id, organization_id=org_id))
|
|
385
|
-
session.commit()
|
|
386
|
-
|
|
387
|
-
def remove_org_from_guild(self, guild_id: str, org_id: str):
|
|
388
|
-
with Session(self.engine) as session:
|
|
389
|
-
existing_mapping = self.get_org_guild(session, org_id, guild_id)
|
|
390
|
-
if not existing_mapping:
|
|
391
|
-
raise HTTPException(
|
|
392
|
-
status_code=404, detail=f"Organization {org_id} is not associated with guild {guild_id}"
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
session.delete(existing_mapping)
|
|
396
|
-
session.commit()
|
|
397
|
-
|
|
398
|
-
def get_guilds_for_org(self, org_id: str) -> List[BasicGuildInfo]:
|
|
367
|
+
def get_guilds_for_org(self, org_id: str, statuses: Optional[List[str]] = None) -> List[BasicGuildInfo]:
|
|
399
368
|
with Session(self.engine) as session:
|
|
400
369
|
statement = (
|
|
401
370
|
select(
|
|
@@ -403,15 +372,17 @@ class CatalogStore:
|
|
|
403
372
|
GuildModel.name,
|
|
404
373
|
Blueprint.id.label("blueprint_id"), # type:ignore
|
|
405
374
|
Blueprint.icon,
|
|
375
|
+
GuildModel.status
|
|
406
376
|
)
|
|
407
|
-
.select_from(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
)
|
|
412
|
-
.where(OrganizationGuild.organization_id == org_id)
|
|
377
|
+
.select_from(GuildModel)
|
|
378
|
+
.outerjoin(BlueprintGuild, GuildModel.id == BlueprintGuild.guild_id) # type:ignore
|
|
379
|
+
.outerjoin(Blueprint, Blueprint.id == BlueprintGuild.blueprint_id) # type:ignore
|
|
380
|
+
.where(GuildModel.organization_id == org_id)
|
|
413
381
|
)
|
|
414
382
|
|
|
383
|
+
if statuses:
|
|
384
|
+
statement = statement.where(GuildModel.status.in_(statuses))
|
|
385
|
+
|
|
415
386
|
guilds: Sequence[BasicGuildInfo] = session.exec(statement).all() # type:ignore
|
|
416
387
|
return list(guilds)
|
|
417
388
|
|
|
@@ -433,7 +404,9 @@ class CatalogStore:
|
|
|
433
404
|
session.delete(existing_mapping)
|
|
434
405
|
session.commit()
|
|
435
406
|
|
|
436
|
-
def get_guilds_for_user(
|
|
407
|
+
def get_guilds_for_user(
|
|
408
|
+
self, user_id, org_id: Optional[str] = None, statuses: Optional[List[str]] = None
|
|
409
|
+
) -> List[BasicGuildInfo]:
|
|
437
410
|
with Session(self.engine) as session:
|
|
438
411
|
statement = (
|
|
439
412
|
select(
|
|
@@ -441,6 +414,7 @@ class CatalogStore:
|
|
|
441
414
|
GuildModel.name,
|
|
442
415
|
Blueprint.id.label("blueprint_id"), # type:ignore
|
|
443
416
|
Blueprint.icon,
|
|
417
|
+
GuildModel.status
|
|
444
418
|
)
|
|
445
419
|
.select_from(
|
|
446
420
|
join(GuildModel, UserGuild, GuildModel.id == UserGuild.guild_id) # type:ignore
|
|
@@ -449,6 +423,13 @@ class CatalogStore:
|
|
|
449
423
|
)
|
|
450
424
|
.where(UserGuild.user_id == user_id)
|
|
451
425
|
)
|
|
426
|
+
|
|
427
|
+
if org_id:
|
|
428
|
+
statement = statement.where(GuildModel.organization_id == org_id)
|
|
429
|
+
|
|
430
|
+
if statuses:
|
|
431
|
+
statement = statement.where(GuildModel.status.in_(statuses))
|
|
432
|
+
|
|
452
433
|
guilds: Sequence[BasicGuildInfo] = session.exec(statement).all() # type:ignore
|
|
453
434
|
return list(guilds)
|
|
454
435
|
|
|
@@ -2,8 +2,8 @@ from datetime import datetime, timezone
|
|
|
2
2
|
from enum import StrEnum
|
|
3
3
|
from typing import Dict, List, Optional
|
|
4
4
|
|
|
5
|
-
import shortuuid
|
|
6
5
|
from pydantic import BaseModel, JsonValue, computed_field
|
|
6
|
+
import shortuuid
|
|
7
7
|
from sqlalchemy.ext.mutable import MutableDict
|
|
8
8
|
from sqlmodel import JSON, Column, Field, Relationship, SQLModel
|
|
9
9
|
|
|
@@ -278,17 +278,12 @@ class UserGuild(SQLModel, table=True):
|
|
|
278
278
|
user_id: str = Field(primary_key=True, index=True)
|
|
279
279
|
|
|
280
280
|
|
|
281
|
-
class OrganizationGuild(SQLModel, table=True):
|
|
282
|
-
__tablename__ = "organization_guild"
|
|
283
|
-
guild_id: str = Field(foreign_key="guilds.id", primary_key=True, index=True)
|
|
284
|
-
organization_id: str = Field(primary_key=True, index=True)
|
|
285
|
-
|
|
286
|
-
|
|
287
281
|
class BasicGuildInfo(SQLModel):
|
|
288
282
|
id: str
|
|
289
283
|
name: str
|
|
290
284
|
blueprint_id: Optional[str] = Field(default=None)
|
|
291
285
|
icon: Optional[str] = Field(default=None)
|
|
286
|
+
status: str
|
|
292
287
|
|
|
293
288
|
|
|
294
289
|
class AgentIcon(SQLModel, table=True):
|
|
@@ -12,6 +12,7 @@ from rustic_ai.api_server.guilds.schema import IdInfo
|
|
|
12
12
|
from rustic_ai.core.guild.dsl import GuildSpec
|
|
13
13
|
from rustic_ai.core.guild.metaprog.agent_registry import AgentEntry
|
|
14
14
|
from rustic_ai.core.guild.metastore.database import Metastore
|
|
15
|
+
from rustic_ai.core.guild.metastore.models import GuildStatus
|
|
15
16
|
|
|
16
17
|
from .catalog_store import CatalogStore
|
|
17
18
|
from .models import (
|
|
@@ -267,8 +268,22 @@ async def add_user_to_guild(guild_id: str, user_id: str, engine: Engine = Depend
|
|
|
267
268
|
operation_id="getGuildsForUser",
|
|
268
269
|
tags=["users"],
|
|
269
270
|
)
|
|
270
|
-
async def get_guilds_for_user(
|
|
271
|
-
|
|
271
|
+
async def get_guilds_for_user(
|
|
272
|
+
user_id: str,
|
|
273
|
+
org_id: Annotated[str | None, Query()] = None,
|
|
274
|
+
statuses: Annotated[list[str] | None, Query()] = None,
|
|
275
|
+
engine: Engine = Depends(Metastore.get_engine),
|
|
276
|
+
):
|
|
277
|
+
if statuses:
|
|
278
|
+
valid_statuses = [s.value for s in GuildStatus]
|
|
279
|
+
invalid_statuses = [s for s in statuses if s not in valid_statuses]
|
|
280
|
+
if invalid_statuses:
|
|
281
|
+
raise HTTPException(
|
|
282
|
+
status_code=400,
|
|
283
|
+
detail=f"Invalid status values: {invalid_statuses}. Valid statuses are: {valid_statuses}",
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
return CatalogStore(engine).get_guilds_for_user(user_id, org_id, statuses)
|
|
272
287
|
|
|
273
288
|
|
|
274
289
|
@catalog_router.delete(
|
|
@@ -282,36 +297,27 @@ async def remove_user_from_guild(guild_id: str, user_id: str, engine: Engine = D
|
|
|
282
297
|
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
|
283
298
|
|
|
284
299
|
|
|
285
|
-
@catalog_router.post(
|
|
286
|
-
"/guilds/{guild_id}/organizations/{organization_id}",
|
|
287
|
-
status_code=status.HTTP_204_NO_CONTENT,
|
|
288
|
-
operation_id="addOrgToGuild",
|
|
289
|
-
tags=["organizations"],
|
|
290
|
-
)
|
|
291
|
-
async def add_org_to_guild(guild_id: str, organization_id: str, engine: Engine = Depends(Metastore.get_engine)):
|
|
292
|
-
CatalogStore(engine).add_org_to_guild(guild_id, organization_id)
|
|
293
|
-
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
|
294
|
-
|
|
295
|
-
|
|
296
300
|
@catalog_router.get(
|
|
297
301
|
"/organizations/{organization_id}/guilds/",
|
|
298
302
|
response_model=List[BasicGuildInfo],
|
|
299
303
|
operation_id="getGuildsForOrganization",
|
|
300
304
|
tags=["organizations"],
|
|
301
305
|
)
|
|
302
|
-
async def get_guilds_for_organization(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
306
|
+
async def get_guilds_for_organization(
|
|
307
|
+
organization_id: str,
|
|
308
|
+
statuses: Annotated[list[str] | None, Query()] = None,
|
|
309
|
+
engine: Engine = Depends(Metastore.get_engine),
|
|
310
|
+
):
|
|
311
|
+
if statuses:
|
|
312
|
+
valid_statuses = [s.value for s in GuildStatus]
|
|
313
|
+
invalid_statuses = [s for s in statuses if s not in valid_statuses]
|
|
314
|
+
if invalid_statuses:
|
|
315
|
+
raise HTTPException(
|
|
316
|
+
status_code=400,
|
|
317
|
+
detail=f"Invalid status values: {invalid_statuses}. Valid statuses are: {valid_statuses}",
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
return CatalogStore(engine).get_guilds_for_org(organization_id, statuses)
|
|
315
321
|
|
|
316
322
|
|
|
317
323
|
@catalog_router.post(
|
|
@@ -4,10 +4,10 @@ import random
|
|
|
4
4
|
import time
|
|
5
5
|
from typing import Callable, Dict, List, Optional, Tuple
|
|
6
6
|
|
|
7
|
-
import shortuuid
|
|
8
7
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
9
8
|
from opentelemetry import trace
|
|
10
9
|
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
|
|
10
|
+
import shortuuid
|
|
11
11
|
from sqlalchemy import Engine
|
|
12
12
|
|
|
13
13
|
from rustic_ai.core.agents.system.guild_manager_agent import UserAgentCreationRequest
|
|
@@ -20,7 +20,7 @@ from rustic_ai.core.messaging.client.message_tracking_client import (
|
|
|
20
20
|
MessageTrackingClient,
|
|
21
21
|
)
|
|
22
22
|
from rustic_ai.core.messaging.core.client import Client
|
|
23
|
-
from rustic_ai.core.messaging.core.message import AgentTag, Message
|
|
23
|
+
from rustic_ai.core.messaging.core.message import AgentTag, Message, ProcessEntry
|
|
24
24
|
from rustic_ai.core.messaging.core.messaging_interface import MessagingInterface
|
|
25
25
|
from rustic_ai.core.utils.basic_class_utils import get_qualified_class_name
|
|
26
26
|
from rustic_ai.core.utils.gemstone_id import GemstoneGenerator
|
|
@@ -212,6 +212,8 @@ class GuildCommunicationManager:
|
|
|
212
212
|
|
|
213
213
|
data["thread"].append(data["id"])
|
|
214
214
|
data["traceparent"] = traceparent
|
|
215
|
+
history = data.get("message_history", [])
|
|
216
|
+
message_history = [ProcessEntry.model_validate(entry) for entry in history]
|
|
215
217
|
|
|
216
218
|
try:
|
|
217
219
|
logging.debug(f"Received message: {data}")
|
|
@@ -223,6 +225,7 @@ class GuildCommunicationManager:
|
|
|
223
225
|
payload=data,
|
|
224
226
|
thread=[data["id"]],
|
|
225
227
|
traceparent=traceparent,
|
|
228
|
+
message_history=message_history,
|
|
226
229
|
)
|
|
227
230
|
|
|
228
231
|
logging.debug(f"Publishing message: {message.model_dump_json()}")
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
from datetime import datetime, timezone
|
|
1
2
|
import importlib
|
|
2
3
|
import json
|
|
3
4
|
import logging
|
|
4
5
|
import mimetypes
|
|
5
|
-
from datetime import datetime, timezone
|
|
6
6
|
from typing import Dict, List, Optional
|
|
7
7
|
from urllib.parse import quote
|
|
8
8
|
|
|
9
|
-
import griffe
|
|
10
9
|
from fastapi import APIRouter, Depends, File, Form, HTTPException, Response, UploadFile
|
|
11
10
|
from fastapi.responses import JSONResponse, StreamingResponse
|
|
11
|
+
import griffe
|
|
12
12
|
from griffe import Alias, Class, Module, Object
|
|
13
13
|
from pydantic import BaseModel, ValidationError
|
|
14
14
|
from sqlalchemy import Engine
|
|
@@ -16,12 +16,11 @@ from starlette import status
|
|
|
16
16
|
|
|
17
17
|
from rustic_ai.api_server.api_dependency_manager import ApiDependencyManager
|
|
18
18
|
from rustic_ai.api_server.guilds.comms_manager import GuildCommunicationManager
|
|
19
|
-
from rustic_ai.api_server.guilds.schema import IdInfo
|
|
19
|
+
from rustic_ai.api_server.guilds.schema import GuildSpecResponse, IdInfo, LaunchGuildReq
|
|
20
20
|
from rustic_ai.api_server.guilds.service import GuildService
|
|
21
21
|
from rustic_ai.core import Agent
|
|
22
22
|
from rustic_ai.core.agents.commons.media import MediaLink
|
|
23
23
|
from rustic_ai.core.guild.agent_ext.depends.filesystem import FileSystem
|
|
24
|
-
from rustic_ai.core.guild.dsl import GuildSpec
|
|
25
24
|
from rustic_ai.core.guild.metaprog.agent_registry import AgentRegistry
|
|
26
25
|
from rustic_ai.core.guild.metastore import Metastore
|
|
27
26
|
from rustic_ai.core.messaging.core.message import Message
|
|
@@ -32,21 +31,20 @@ guild_service = GuildService()
|
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
@router.post("/guilds", response_model=IdInfo, status_code=status.HTTP_201_CREATED, operation_id="createGuild")
|
|
35
|
-
def create_guild(
|
|
34
|
+
def create_guild(launch_req: LaunchGuildReq):
|
|
36
35
|
"""
|
|
37
36
|
Creates a new guild and adds it to the database.
|
|
38
37
|
|
|
39
38
|
Args:
|
|
40
|
-
|
|
39
|
+
launch_req (LaunchGuildReq): object with spec for the new guild and the org id
|
|
41
40
|
|
|
42
41
|
Returns:
|
|
43
42
|
IdInfo: The id of the newly created guild
|
|
44
43
|
"""
|
|
45
|
-
if not
|
|
44
|
+
if not launch_req.spec:
|
|
46
45
|
raise HTTPException(status_code=400, detail="Invalid input") # pragma: no cover
|
|
47
|
-
|
|
48
46
|
try:
|
|
49
|
-
guild_id = guild_service.create_guild(Metastore.get_db_url(),
|
|
47
|
+
guild_id = guild_service.create_guild(Metastore.get_db_url(), launch_req.spec, launch_req.org_id)
|
|
50
48
|
logging.debug(f"New guild created: {guild_id}")
|
|
51
49
|
return IdInfo(id=guild_id)
|
|
52
50
|
except ValidationError as e:
|
|
@@ -55,8 +53,8 @@ def create_guild(guild_spec: GuildSpec):
|
|
|
55
53
|
raise HTTPException(status_code=500, detail=str(e)) # pragma: no cover
|
|
56
54
|
|
|
57
55
|
|
|
58
|
-
@router.get("/guilds/{guild_id}", response_model=
|
|
59
|
-
def get_guild(guild_id: str, engine=Depends(Metastore.get_engine)) ->
|
|
56
|
+
@router.get("/guilds/{guild_id}", response_model=GuildSpecResponse, operation_id="getGuildDetailsById")
|
|
57
|
+
def get_guild(guild_id: str, engine=Depends(Metastore.get_engine)) -> GuildSpecResponse:
|
|
60
58
|
"""
|
|
61
59
|
Retrieves details for a guild based on the provided guild_id.
|
|
62
60
|
|
|
@@ -64,7 +62,7 @@ def get_guild(guild_id: str, engine=Depends(Metastore.get_engine)) -> GuildSpec:
|
|
|
64
62
|
guild_id (str): The ID of the guild to retrieve details for.
|
|
65
63
|
|
|
66
64
|
Returns:
|
|
67
|
-
|
|
65
|
+
GuildSpecResponse: The retrieved guild details, or None if the guild was not found.
|
|
68
66
|
|
|
69
67
|
Raises:
|
|
70
68
|
HTTPException: If the guild is not found, raises an HTTPException with a status code of 404.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
from rustic_ai.core.guild.dsl import GuildSpec
|
|
4
|
+
from rustic_ai.core.guild.metastore.models import GuildStatus
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class IdInfo(BaseModel):
|
|
8
|
+
id: str
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LaunchGuildReq(BaseModel):
|
|
12
|
+
spec: GuildSpec
|
|
13
|
+
org_id: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GuildSpecResponse(GuildSpec):
|
|
17
|
+
"""
|
|
18
|
+
Response for a guild specification that describes its name, description, agents, routes, and status.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
status: GuildStatus
|
|
@@ -2,6 +2,7 @@ from typing import Optional
|
|
|
2
2
|
|
|
3
3
|
from sqlalchemy import Engine
|
|
4
4
|
|
|
5
|
+
from rustic_ai.api_server.guilds.schema import GuildSpecResponse
|
|
5
6
|
from rustic_ai.core.guild import GuildSpec
|
|
6
7
|
from rustic_ai.core.guild.builders import GuildBuilder, GuildHelper
|
|
7
8
|
from rustic_ai.core.guild.metastore import GuildStore
|
|
@@ -9,9 +10,17 @@ from rustic_ai.core.guild.metastore import GuildStore
|
|
|
9
10
|
|
|
10
11
|
class GuildService:
|
|
11
12
|
|
|
12
|
-
def create_guild(self, metastore_url: str, guild_spec: GuildSpec) -> str:
|
|
13
|
+
def create_guild(self, metastore_url: str, guild_spec: GuildSpec, organization_id: str) -> str:
|
|
13
14
|
"""
|
|
14
15
|
Creates a new guild and adds it to the database.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
metastore_url (str): The URL of the metastore database.
|
|
19
|
+
guild_spec (GuildSpec): The specification of the guild to create.
|
|
20
|
+
organization_id (str): The ID of the organization that owns this guild.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
str: The ID of the created guild.
|
|
15
24
|
"""
|
|
16
25
|
if guild_spec.get_messaging() is None:
|
|
17
26
|
default_messaging = GuildHelper.get_default_messaging_config()
|
|
@@ -22,18 +31,27 @@ class GuildService:
|
|
|
22
31
|
|
|
23
32
|
guild_spec.dependency_map = GuildHelper.get_guild_dependency_map(guild_spec)
|
|
24
33
|
|
|
25
|
-
guild = GuildBuilder.from_spec(guild_spec).bootstrap(metastore_url)
|
|
34
|
+
guild = GuildBuilder.from_spec(guild_spec).bootstrap(metastore_url, organization_id)
|
|
26
35
|
|
|
27
36
|
return guild.id
|
|
28
37
|
|
|
29
|
-
def get_guild(self, engine: Engine, guild_id: str) -> Optional[
|
|
38
|
+
def get_guild(self, engine: Engine, guild_id: str) -> Optional[GuildSpecResponse]:
|
|
30
39
|
"""
|
|
31
40
|
Retrieves a guild and its agents from the database.
|
|
32
|
-
"""
|
|
33
41
|
|
|
42
|
+
Args:
|
|
43
|
+
engine (Engine): The database engine.
|
|
44
|
+
guild_id (str): The ID of the guild to retrieve.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Optional[GuildSpec]: The guild specification if found, None otherwise.
|
|
48
|
+
"""
|
|
34
49
|
guild_store = GuildStore(engine)
|
|
35
50
|
guild_model = guild_store.get_guild(guild_id)
|
|
36
51
|
|
|
37
52
|
guild_spec = guild_model.to_guild_spec() if guild_model else None
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
if guild_spec is None:
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
return GuildSpecResponse(**guild_spec.model_dump(), status=guild_model.status)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
-
import uvicorn
|
|
5
4
|
from fastapi import FastAPI, HTTPException
|
|
6
5
|
from fastapi.exception_handlers import http_exception_handler
|
|
7
6
|
from fastapi.middleware.cors import CORSMiddleware
|
|
7
|
+
import ray
|
|
8
8
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
9
9
|
from starlette.requests import Request
|
|
10
|
+
import uvicorn
|
|
10
11
|
|
|
11
|
-
import ray
|
|
12
12
|
from rustic_ai.api_server import catalog, guilds
|
|
13
13
|
from rustic_ai.api_server.guilds.socket import lifespan
|
|
14
14
|
from rustic_ai.api_server.logging import LOGGING_CONFIG, RusticLogFormatter
|
|
@@ -32,10 +32,7 @@ LAUNCH_RAY_DASHBOARD = os.environ.get("RUSTIC_LAUNCH_RAY_DASHBOARD", "False").lo
|
|
|
32
32
|
if INITIALIZE_RAY_CLUSTER:
|
|
33
33
|
|
|
34
34
|
logging.info("Initializing Ray cluster")
|
|
35
|
-
ray.init(
|
|
36
|
-
include_dashboard=LAUNCH_RAY_DASHBOARD,
|
|
37
|
-
log_to_driver=False,
|
|
38
|
-
)
|
|
35
|
+
ray.init(include_dashboard=LAUNCH_RAY_DASHBOARD, log_to_driver=False, dashboard_host="0.0.0.0")
|
|
39
36
|
logging.info("Ray cluster initialized")
|
|
40
37
|
logging.info("Ray cluster details: {}".format(ray.get_runtime_context()))
|
|
41
38
|
|
|
File without changes
|
{rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/api_dependency_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_api-0.0.5 → rusticai_api-0.1.0}/src/rustic_ai/api_server/guilds/system_comms_manager.py
RENAMED
|
@@ -4,10 +4,10 @@ import random
|
|
|
4
4
|
import time
|
|
5
5
|
from typing import Callable, Dict, Optional
|
|
6
6
|
|
|
7
|
-
import shortuuid
|
|
8
7
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
9
8
|
from opentelemetry import trace
|
|
10
9
|
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
|
|
10
|
+
import shortuuid
|
|
11
11
|
from sqlalchemy import Engine
|
|
12
12
|
|
|
13
13
|
from rustic_ai.core import (
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|