dao-ai 0.1.9__py3-none-any.whl → 0.1.11__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.
- dao_ai/apps/__init__.py +24 -0
- dao_ai/{app_server.py → apps/handlers.py} +20 -39
- dao_ai/apps/model_serving.py +29 -0
- dao_ai/apps/resources.py +1072 -0
- dao_ai/apps/server.py +39 -0
- dao_ai/cli.py +51 -4
- dao_ai/config.py +34 -4
- dao_ai/memory/postgres.py +29 -4
- dao_ai/models.py +327 -370
- dao_ai/providers/databricks.py +62 -20
- dao_ai/tools/mcp.py +165 -68
- {dao_ai-0.1.9.dist-info → dao_ai-0.1.11.dist-info}/METADATA +2 -2
- {dao_ai-0.1.9.dist-info → dao_ai-0.1.11.dist-info}/RECORD +16 -13
- dao_ai/agent_as_code.py +0 -22
- {dao_ai-0.1.9.dist-info → dao_ai-0.1.11.dist-info}/WHEEL +0 -0
- {dao_ai-0.1.9.dist-info → dao_ai-0.1.11.dist-info}/entry_points.txt +0 -0
- {dao_ai-0.1.9.dist-info → dao_ai-0.1.11.dist-info}/licenses/LICENSE +0 -0
dao_ai/apps/__init__.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Databricks Apps deployment module for dao-ai.
|
|
3
|
+
|
|
4
|
+
This subpackage contains all modules related to deploying dao-ai agents
|
|
5
|
+
as Databricks Apps or Model Serving endpoints.
|
|
6
|
+
|
|
7
|
+
Modules:
|
|
8
|
+
handlers: MLflow AgentServer request handlers (@invoke, @stream)
|
|
9
|
+
server: Entry point for Databricks Apps deployment
|
|
10
|
+
resources: Databricks App resource configuration generation
|
|
11
|
+
model_serving: Entry point for Databricks Model Serving deployment
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from dao_ai.apps.resources import (
|
|
15
|
+
generate_app_resources,
|
|
16
|
+
generate_app_yaml,
|
|
17
|
+
generate_sdk_resources,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"generate_app_resources",
|
|
22
|
+
"generate_app_yaml",
|
|
23
|
+
"generate_sdk_resources",
|
|
24
|
+
]
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Agent request handlers for MLflow AgentServer.
|
|
3
3
|
|
|
4
|
-
This module
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
This module defines the invoke and stream handlers that are registered
|
|
5
|
+
with the MLflow AgentServer. These handlers delegate to the ResponsesAgent
|
|
6
|
+
created from the dao-ai configuration.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
or defaults to model_config.yaml in the current directory.
|
|
11
|
-
|
|
12
|
-
Usage:
|
|
13
|
-
# With environment variable
|
|
14
|
-
DAO_AI_CONFIG_PATH=/path/to/config.yaml python -m dao_ai.app_server
|
|
15
|
-
|
|
16
|
-
# With default model_config.yaml in current directory
|
|
17
|
-
python -m dao_ai.app_server
|
|
8
|
+
The handlers use async methods (apredict, apredict_stream) to be compatible
|
|
9
|
+
with both Databricks Model Serving and Databricks Apps environments.
|
|
18
10
|
"""
|
|
19
11
|
|
|
20
12
|
import os
|
|
@@ -22,8 +14,7 @@ from typing import AsyncGenerator
|
|
|
22
14
|
|
|
23
15
|
import mlflow
|
|
24
16
|
from dotenv import load_dotenv
|
|
25
|
-
from mlflow.genai.agent_server import
|
|
26
|
-
from mlflow.pyfunc import ResponsesAgent
|
|
17
|
+
from mlflow.genai.agent_server import invoke, stream
|
|
27
18
|
from mlflow.types.responses import (
|
|
28
19
|
ResponsesAgentRequest,
|
|
29
20
|
ResponsesAgentResponse,
|
|
@@ -32,6 +23,7 @@ from mlflow.types.responses import (
|
|
|
32
23
|
|
|
33
24
|
from dao_ai.config import AppConfig
|
|
34
25
|
from dao_ai.logging import configure_logging
|
|
26
|
+
from dao_ai.models import LanggraphResponsesAgent
|
|
35
27
|
|
|
36
28
|
# Load environment variables from .env.local if it exists
|
|
37
29
|
load_dotenv(dotenv_path=".env.local", override=True)
|
|
@@ -51,53 +43,42 @@ config: AppConfig = AppConfig.from_file(config_path)
|
|
|
51
43
|
if config.app and config.app.log_level:
|
|
52
44
|
configure_logging(level=config.app.log_level)
|
|
53
45
|
|
|
54
|
-
# Create the ResponsesAgent
|
|
55
|
-
_responses_agent:
|
|
46
|
+
# Create the ResponsesAgent - cast to LanggraphResponsesAgent to access async methods
|
|
47
|
+
_responses_agent: LanggraphResponsesAgent = config.as_responses_agent() # type: ignore[assignment]
|
|
56
48
|
|
|
57
49
|
|
|
58
50
|
@invoke()
|
|
59
|
-
def non_streaming(request: ResponsesAgentRequest) -> ResponsesAgentResponse:
|
|
51
|
+
async def non_streaming(request: ResponsesAgentRequest) -> ResponsesAgentResponse:
|
|
60
52
|
"""
|
|
61
53
|
Handle non-streaming requests by delegating to the ResponsesAgent.
|
|
62
54
|
|
|
55
|
+
Uses the async apredict() method for compatibility with both
|
|
56
|
+
Model Serving and Apps environments.
|
|
57
|
+
|
|
63
58
|
Args:
|
|
64
59
|
request: The incoming ResponsesAgentRequest
|
|
65
60
|
|
|
66
61
|
Returns:
|
|
67
62
|
ResponsesAgentResponse with the complete output
|
|
68
63
|
"""
|
|
69
|
-
return _responses_agent.
|
|
64
|
+
return await _responses_agent.apredict(request)
|
|
70
65
|
|
|
71
66
|
|
|
72
67
|
@stream()
|
|
73
|
-
def streaming(
|
|
68
|
+
async def streaming(
|
|
74
69
|
request: ResponsesAgentRequest,
|
|
75
70
|
) -> AsyncGenerator[ResponsesAgentStreamEvent, None]:
|
|
76
71
|
"""
|
|
77
72
|
Handle streaming requests by delegating to the ResponsesAgent.
|
|
78
73
|
|
|
74
|
+
Uses the async apredict_stream() method for compatibility with both
|
|
75
|
+
Model Serving and Apps environments.
|
|
76
|
+
|
|
79
77
|
Args:
|
|
80
78
|
request: The incoming ResponsesAgentRequest
|
|
81
79
|
|
|
82
80
|
Yields:
|
|
83
81
|
ResponsesAgentStreamEvent objects as they are generated
|
|
84
82
|
"""
|
|
85
|
-
|
|
86
|
-
for event in _responses_agent.predict_stream(request):
|
|
83
|
+
async for event in _responses_agent.apredict_stream(request):
|
|
87
84
|
yield event
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# Create the AgentServer instance
|
|
91
|
-
agent_server = AgentServer("ResponsesAgent", enable_chat_proxy=True)
|
|
92
|
-
|
|
93
|
-
# Define the app as a module level variable to enable multiple workers
|
|
94
|
-
app = agent_server.app
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def main() -> None:
|
|
98
|
-
"""Entry point for running the agent server."""
|
|
99
|
-
agent_server.run(app_import_string="dao_ai.app_server:app")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if __name__ == "__main__":
|
|
103
|
-
main()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Apply nest_asyncio FIRST before any other imports
|
|
2
|
+
# This allows dao-ai's async/sync patterns to work in Model Serving
|
|
3
|
+
# where there may already be an event loop running (e.g., notebook context)
|
|
4
|
+
import nest_asyncio
|
|
5
|
+
|
|
6
|
+
nest_asyncio.apply()
|
|
7
|
+
|
|
8
|
+
import mlflow # noqa: E402
|
|
9
|
+
from mlflow.models import ModelConfig # noqa: E402
|
|
10
|
+
from mlflow.pyfunc import ResponsesAgent # noqa: E402
|
|
11
|
+
|
|
12
|
+
from dao_ai.config import AppConfig # noqa: E402
|
|
13
|
+
from dao_ai.logging import configure_logging # noqa: E402
|
|
14
|
+
|
|
15
|
+
mlflow.set_registry_uri("databricks-uc")
|
|
16
|
+
mlflow.set_tracking_uri("databricks")
|
|
17
|
+
|
|
18
|
+
mlflow.langchain.autolog()
|
|
19
|
+
|
|
20
|
+
model_config: ModelConfig = ModelConfig()
|
|
21
|
+
config: AppConfig = AppConfig(**model_config.to_dict())
|
|
22
|
+
|
|
23
|
+
log_level: str = config.app.log_level
|
|
24
|
+
|
|
25
|
+
configure_logging(level=log_level)
|
|
26
|
+
|
|
27
|
+
app: ResponsesAgent = config.as_responses_agent()
|
|
28
|
+
|
|
29
|
+
mlflow.models.set_model(app)
|