cloudbase-agent-server 0.1.9__py3-none-any.whl
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.
- cloudbase_agent/__init__.py +8 -0
- cloudbase_agent/server/__init__.py +91 -0
- cloudbase_agent/server/app.py +371 -0
- cloudbase_agent/server/healthz/__init__.py +14 -0
- cloudbase_agent/server/healthz/handler.py +203 -0
- cloudbase_agent/server/healthz/models.py +132 -0
- cloudbase_agent/server/openai/__init__.py +14 -0
- cloudbase_agent/server/openai/converter.py +69 -0
- cloudbase_agent/server/openai/models.py +57 -0
- cloudbase_agent/server/openai/server.py +46 -0
- cloudbase_agent/server/send_message/__init__.py +20 -0
- cloudbase_agent/server/send_message/handler.py +146 -0
- cloudbase_agent/server/send_message/models.py +62 -0
- cloudbase_agent/server/send_message/server.py +93 -0
- cloudbase_agent/server/utils/__init__.py +21 -0
- cloudbase_agent/server/utils/converters.py +25 -0
- cloudbase_agent/server/utils/sse.py +32 -0
- cloudbase_agent/server/utils/types.py +73 -0
- cloudbase_agent_server-0.1.9.dist-info/METADATA +45 -0
- cloudbase_agent_server-0.1.9.dist-info/RECORD +21 -0
- cloudbase_agent_server-0.1.9.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Server-Sent Events (SSE) Utilities.
|
|
4
|
+
|
|
5
|
+
This module provides utility functions for working with Server-Sent Events
|
|
6
|
+
in streaming HTTP responses.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import AsyncGenerator
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async def async_generator_from_string(content: str) -> AsyncGenerator[str, None]:
|
|
13
|
+
r"""Create an async generator from a string.
|
|
14
|
+
|
|
15
|
+
This utility function converts a string into an async generator,
|
|
16
|
+
which is useful for creating error responses in streaming format
|
|
17
|
+
that are compatible with StreamingResponse.
|
|
18
|
+
|
|
19
|
+
:param content: The string content to yield
|
|
20
|
+
:type content: str
|
|
21
|
+
|
|
22
|
+
:yields: The input content as a single item
|
|
23
|
+
:ytype: str
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
Creating an error stream::
|
|
27
|
+
|
|
28
|
+
error_content = "data: {'error': 'Something went wrong'}\\n\\n"
|
|
29
|
+
error_stream = async_generator_from_string(error_content)
|
|
30
|
+
return StreamingResponse(error_stream, media_type="text/event-stream")
|
|
31
|
+
"""
|
|
32
|
+
yield content
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Type Definitions for Cloudbase Agent Server.
|
|
4
|
+
|
|
5
|
+
This module defines common types used throughout the Cloudbase Agent server,
|
|
6
|
+
including agent creator function signatures and result types.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Any, Awaitable, Callable, Optional, TypedDict, Union
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AgentCreatorResult(TypedDict, total=False):
|
|
13
|
+
"""Result type for agent creator functions.
|
|
14
|
+
|
|
15
|
+
This type defines the structure returned by agent creator functions,
|
|
16
|
+
which includes the agent instance and an optional cleanup callback.
|
|
17
|
+
|
|
18
|
+
:param agent: The agent instance to handle requests
|
|
19
|
+
:type agent: Any
|
|
20
|
+
:param cleanup: Optional cleanup function called after stream completes.
|
|
21
|
+
Can be sync or async function.
|
|
22
|
+
:type cleanup: Optional[Callable[[], Union[None, Awaitable[None]]]]
|
|
23
|
+
|
|
24
|
+
Example:
|
|
25
|
+
Synchronous cleanup::
|
|
26
|
+
|
|
27
|
+
def create_agent() -> AgentCreatorResult:
|
|
28
|
+
db = connect_database()
|
|
29
|
+
agent = MyAgent(db)
|
|
30
|
+
|
|
31
|
+
def cleanup():
|
|
32
|
+
db.close()
|
|
33
|
+
print("Database closed")
|
|
34
|
+
|
|
35
|
+
return {"agent": agent, "cleanup": cleanup}
|
|
36
|
+
|
|
37
|
+
Asynchronous cleanup::
|
|
38
|
+
|
|
39
|
+
async def create_agent() -> AgentCreatorResult:
|
|
40
|
+
db = await async_connect_database()
|
|
41
|
+
agent = MyAgent(db)
|
|
42
|
+
|
|
43
|
+
async def cleanup():
|
|
44
|
+
await db.close()
|
|
45
|
+
print("Database closed")
|
|
46
|
+
|
|
47
|
+
return {"agent": agent, "cleanup": cleanup}
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
agent: Any
|
|
51
|
+
cleanup: Optional[Callable[[], Union[None, Awaitable[None]]]]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Type alias for agent creator functions
|
|
55
|
+
AgentCreator = Callable[[], Union[AgentCreatorResult, Awaitable[AgentCreatorResult]]]
|
|
56
|
+
"""Type alias for agent creator functions.
|
|
57
|
+
|
|
58
|
+
Agent creator functions are responsible for creating agent instances
|
|
59
|
+
and optionally providing cleanup callbacks. They can be either
|
|
60
|
+
synchronous or asynchronous.
|
|
61
|
+
|
|
62
|
+
Example:
|
|
63
|
+
Synchronous creator::
|
|
64
|
+
|
|
65
|
+
def create_agent() -> AgentCreatorResult:
|
|
66
|
+
return {"agent": MyAgent()}
|
|
67
|
+
|
|
68
|
+
Asynchronous creator::
|
|
69
|
+
|
|
70
|
+
async def create_agent() -> AgentCreatorResult:
|
|
71
|
+
agent = await initialize_agent()
|
|
72
|
+
return {"agent": agent}
|
|
73
|
+
"""
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloudbase-agent-server
|
|
3
|
+
Version: 0.1.9
|
|
4
|
+
Summary: Cloudbase Agent Python SDK - FastAPI server implementation
|
|
5
|
+
Author-email: Cloudbase Agent Team <ag-kit@example.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: Cloudbase Agent,agent,ai,llm
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: cloudbase-agent-core
|
|
17
|
+
Requires-Dist: fastapi>=0.100.0
|
|
18
|
+
Requires-Dist: sse-starlette>=1.6.0
|
|
19
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.12.0; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# cloudbase-agent-server
|
|
28
|
+
|
|
29
|
+
Cloudbase Agent Python SDK - FastAPI server implementation
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cloudbase-agent-server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from cloudbase_agent import ...
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Apache-2.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
cloudbase_agent/__init__.py,sha256=Y6_UXMNNLTKwMpyPOXccmFjNhoBJgbN6F6ftmWVuPJo,182
|
|
2
|
+
cloudbase_agent/server/__init__.py,sha256=fRvNDgpb3Yp8yZAFKh8d1d963QvnIfkSevmchS-waLQ,3069
|
|
3
|
+
cloudbase_agent/server/app.py,sha256=s5UYJRX9IRsVA8pRtlqtOaRsVSLAWnuj3VBKxasTphE,13808
|
|
4
|
+
cloudbase_agent/server/healthz/__init__.py,sha256=oSFAw2bZt3HD8n8OTSqTtNJVgGLivFxiepzmtayCm-8,338
|
|
5
|
+
cloudbase_agent/server/healthz/handler.py,sha256=ZWDdU3AOvs217PhS-CjISPwRZGoat2Pgvyh-Hu6GSTY,6599
|
|
6
|
+
cloudbase_agent/server/healthz/models.py,sha256=XHf4GiVG4L7kDbjstbxMdadecy96klQIZpo1hIx4xHQ,4425
|
|
7
|
+
cloudbase_agent/server/openai/__init__.py,sha256=QSZOmo7M0qAhk11BIkyxwuwlzhEJDLAf2MAkUljje6E,376
|
|
8
|
+
cloudbase_agent/server/openai/converter.py,sha256=kcSWmMv8fDruHSHimQqcWAjk8nysnpEV4LOHZXL7uB0,2153
|
|
9
|
+
cloudbase_agent/server/openai/models.py,sha256=Q5VHZiBADc7VzAIC1lS1JR-rqXWvDoXuWwljMkXaiTs,1750
|
|
10
|
+
cloudbase_agent/server/openai/server.py,sha256=BZA-r0RoejUa4eDh-SFt6FkGShBBmomPMQjeX6dp4sI,1833
|
|
11
|
+
cloudbase_agent/server/send_message/__init__.py,sha256=ScHAG5JcE1gXLKTONSd8AkqZ5gnZU42NuKCFx92K_Z4,551
|
|
12
|
+
cloudbase_agent/server/send_message/handler.py,sha256=JtW-QsiVPblIKaqY-37Lgq50LlwtxyyRij0D6rJOQsg,5606
|
|
13
|
+
cloudbase_agent/server/send_message/models.py,sha256=WoKgrffIZ3hTzvI1_zoH3STKHiRuQJsLCA0y3n25vaE,1330
|
|
14
|
+
cloudbase_agent/server/send_message/server.py,sha256=nucOzHkCbhPSIJquyOjEyH3ZQK6oikSg4ZAwIT0nu6A,3288
|
|
15
|
+
cloudbase_agent/server/utils/__init__.py,sha256=B8svvS8Dz0ajhMyyqB_ZP3OHBHAXZ1L_uuuKLjF6nyk,577
|
|
16
|
+
cloudbase_agent/server/utils/converters.py,sha256=7G-njOCWZHKHlETlL61whrCPtQZTQlzKdJ7LNYCL2TI,575
|
|
17
|
+
cloudbase_agent/server/utils/sse.py,sha256=-H0SLEDb8q-mnNNKSK6aGqvbDS2oZxGGQfxwdX_OAu8,992
|
|
18
|
+
cloudbase_agent/server/utils/types.py,sha256=3ceCpEUkW2W-CNjP4wFwC0tB7CsAJUaQCW_8AiaaFlg,2274
|
|
19
|
+
cloudbase_agent_server-0.1.9.dist-info/METADATA,sha256=YcD33l-pG6RalNjMeW9p-jGFY0ytau7CEVT-dN5Mc2M,1238
|
|
20
|
+
cloudbase_agent_server-0.1.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
21
|
+
cloudbase_agent_server-0.1.9.dist-info/RECORD,,
|