maitai-python 1.2.32__py3-none-any.whl → 1.2.33__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.
- maitai_common/version.py +1 -1
- {maitai_python-1.2.32.dist-info → maitai_python-1.2.33.dist-info}/METADATA +1 -1
- {maitai_python-1.2.32.dist-info → maitai_python-1.2.33.dist-info}/RECORD +11 -5
- {maitai_python-1.2.32.dist-info → maitai_python-1.2.33.dist-info}/top_level.txt +1 -0
- maitai_workflow/__init__.py +27 -0
- maitai_workflow/agent_request.py +156 -0
- maitai_workflow/context.py +1994 -0
- maitai_workflow/datastore/__init__.py +33 -0
- maitai_workflow/datastore/filters.py +298 -0
- maitai_workflow/profile_nav.py +62 -0
- {maitai_python-1.2.32.dist-info → maitai_python-1.2.33.dist-info}/WHEEL +0 -0
maitai_common/version.py
CHANGED
|
@@ -50,7 +50,7 @@ maitai/workflow/_completions_async.py,sha256=J6kaya1PdxN5e5V7o5Rtwi6vjyW0nr3FRwZ
|
|
|
50
50
|
maitai/workflow/_local.py,sha256=2VUf5Uvc1LsbssGkLZKfqq0nUfXLZvR5jYSuHMe52bw,16991
|
|
51
51
|
maitai/workflow/_stream_http.py,sha256=4_xK8tGvECubKKax8FgY7pL_RaASRg2AAaCI5_gwghE,5971
|
|
52
52
|
maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
-
maitai_common/version.py,sha256=
|
|
53
|
+
maitai_common/version.py,sha256=k1oXK2gJ1zcq2zGQIH10qEympMDIkbLejo0e0eBye0k,65
|
|
54
54
|
maitai_common/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
55
|
maitai_common/config/config_service.py,sha256=xcbmwXr5cGZI0_wE2AEbhXQbQwurkUiv8qfFklNNlXU,1120
|
|
56
56
|
maitai_models/adapter.py,sha256=DrbFHeeo9tNI10MmZwNSivcvmNfrljqsYikyHzmTZKs,424
|
|
@@ -108,7 +108,13 @@ maitai_models/agent/base.py,sha256=gYhTQnbaQytpe-vZx7QACTIdOq64omBF9WT1-YC31uc,7
|
|
|
108
108
|
maitai_models/agent/enum.py,sha256=PVGHoC3xupKBcrmNjmQWT4V8Caa6lBWn5JCldXD6uxE,1950
|
|
109
109
|
maitai_models/agent/extended.py,sha256=MbwkcfmiLytko-_0p8riI4KclLEuWrKh-wqMjbdfKEo,22940
|
|
110
110
|
maitai_models/agent/import_manifest.py,sha256=yreDd2Le6z685YfWu0r03QyV9GN2IjzFIEEExy9qiFU,5698
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
maitai_workflow/__init__.py,sha256=ZDeaul20aqOMZyh83UAnFarmCuqqTuaF9IErFwJdy1I,346
|
|
112
|
+
maitai_workflow/agent_request.py,sha256=8YJC6bzdTy_4LKGfWL1rFpYsy-ttZ10tddyO1pM9eg4,4661
|
|
113
|
+
maitai_workflow/context.py,sha256=aGtaodFwQvpD00YlITzE74Jw5MhEMRSuiNcGgXNekbM,74675
|
|
114
|
+
maitai_workflow/profile_nav.py,sha256=i9kqAmxMQLtELGvK3X2KMOOcQzaDmbCB2HGi8dkWO7c,2012
|
|
115
|
+
maitai_workflow/datastore/__init__.py,sha256=PGdETeEJF3z7zuNroQlmjibgcBadpr388zqd1GhtfrA,477
|
|
116
|
+
maitai_workflow/datastore/filters.py,sha256=rCg9HsQG4iXt_10DeBjaqYnaT0I0hOXk9ngeHkn5stI,9604
|
|
117
|
+
maitai_python-1.2.33.dist-info/METADATA,sha256=uZphkFjZCuNvZy4pI56CVwxywbw7uAQW3lv4elVpiAg,1966
|
|
118
|
+
maitai_python-1.2.33.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
119
|
+
maitai_python-1.2.33.dist-info/top_level.txt,sha256=xogwYKin1vXFIAWRw3Myqr3hkymwsucp67TCSAWO3Rg,51
|
|
120
|
+
maitai_python-1.2.33.dist-info/RECORD,,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from maitai_workflow.context import WorkflowContext
|
|
2
|
+
from maitai_workflow.datastore import (
|
|
3
|
+
All,
|
|
4
|
+
Any,
|
|
5
|
+
Filter,
|
|
6
|
+
Not,
|
|
7
|
+
Raw,
|
|
8
|
+
Tag,
|
|
9
|
+
Text,
|
|
10
|
+
all_,
|
|
11
|
+
any_,
|
|
12
|
+
not_,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"WorkflowContext",
|
|
17
|
+
"Filter",
|
|
18
|
+
"All",
|
|
19
|
+
"Any",
|
|
20
|
+
"Not",
|
|
21
|
+
"Tag",
|
|
22
|
+
"Text",
|
|
23
|
+
"Raw",
|
|
24
|
+
"all_",
|
|
25
|
+
"any_",
|
|
26
|
+
"not_",
|
|
27
|
+
]
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Build AgentRequest objects for workflow ctx.agent_completion calls."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from maitai.models.agent.extended import AgentRequest
|
|
6
|
+
from maitai.models.chat import ChatCompletionParams, ChatMessage
|
|
7
|
+
|
|
8
|
+
# ChatCompletionParams fields accepted as top-level kwargs for ergonomics.
|
|
9
|
+
_PARAMS_KEYS = frozenset(
|
|
10
|
+
{
|
|
11
|
+
"model",
|
|
12
|
+
"max_tokens",
|
|
13
|
+
"response_format",
|
|
14
|
+
"temperature",
|
|
15
|
+
"top_p",
|
|
16
|
+
"top_k",
|
|
17
|
+
"min_p",
|
|
18
|
+
"repetition_penalty",
|
|
19
|
+
"stop",
|
|
20
|
+
"logprobs",
|
|
21
|
+
"top_logprobs",
|
|
22
|
+
"n",
|
|
23
|
+
"seed",
|
|
24
|
+
"stream",
|
|
25
|
+
"stream_options",
|
|
26
|
+
"logit_bias",
|
|
27
|
+
"presence_penalty",
|
|
28
|
+
"frequency_penalty",
|
|
29
|
+
"user",
|
|
30
|
+
"tools",
|
|
31
|
+
"tool_choice",
|
|
32
|
+
"parallel_tool_calls",
|
|
33
|
+
"reasoning_effort",
|
|
34
|
+
"reasoning",
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _messages_from_dicts(messages: List[Dict[str, Any]]) -> List[ChatMessage]:
|
|
40
|
+
out: List[ChatMessage] = []
|
|
41
|
+
for msg in messages:
|
|
42
|
+
if isinstance(msg, ChatMessage):
|
|
43
|
+
out.append(msg)
|
|
44
|
+
continue
|
|
45
|
+
out.append(
|
|
46
|
+
ChatMessage(
|
|
47
|
+
role=msg.get("role", "user"),
|
|
48
|
+
content=msg.get("content", ""),
|
|
49
|
+
name=msg.get("name"),
|
|
50
|
+
tool_calls=msg.get("tool_calls"),
|
|
51
|
+
tool_call_id=msg.get("tool_call_id"),
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
return out
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def build_workflow_agent_request(
|
|
58
|
+
*,
|
|
59
|
+
agent: str,
|
|
60
|
+
messages: List[Dict[str, Any]],
|
|
61
|
+
default_session_id: str,
|
|
62
|
+
default_application: Optional[str] = None,
|
|
63
|
+
**kwargs: Any,
|
|
64
|
+
) -> AgentRequest:
|
|
65
|
+
"""Construct AgentRequest from workflow ctx.agent_completion kwargs."""
|
|
66
|
+
if not agent or not str(agent).strip():
|
|
67
|
+
raise ValueError(
|
|
68
|
+
"Missing `agent` field. Pass an agent ref (e.g. 'agent:1451:prod') "
|
|
69
|
+
"to ctx.agent_completion."
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
agent_target = str(agent).strip()
|
|
73
|
+
session_id = kwargs.pop("session_id", None) or default_session_id
|
|
74
|
+
|
|
75
|
+
agent_id = kwargs.pop("agent_id", None)
|
|
76
|
+
application = (
|
|
77
|
+
kwargs.pop("application_ref_name", None)
|
|
78
|
+
or kwargs.pop("application", None)
|
|
79
|
+
or default_application
|
|
80
|
+
)
|
|
81
|
+
application_id = kwargs.pop("application_id", None)
|
|
82
|
+
|
|
83
|
+
params_payload = kwargs.pop("params", None)
|
|
84
|
+
if params_payload is not None and not isinstance(params_payload, dict):
|
|
85
|
+
raise ValueError(
|
|
86
|
+
"`params` must be a dict when provided to ctx.agent_completion"
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
params_kwargs: Dict[str, Any] = {"messages": _messages_from_dicts(messages)}
|
|
90
|
+
if isinstance(params_payload, dict):
|
|
91
|
+
params_kwargs.update(params_payload)
|
|
92
|
+
|
|
93
|
+
for key in list(kwargs.keys()):
|
|
94
|
+
if key in _PARAMS_KEYS:
|
|
95
|
+
params_kwargs[key] = kwargs.pop(key)
|
|
96
|
+
|
|
97
|
+
params = ChatCompletionParams(**params_kwargs)
|
|
98
|
+
|
|
99
|
+
meta = kwargs.pop("meta", None)
|
|
100
|
+
metadata = kwargs.pop("metadata", None)
|
|
101
|
+
if meta is None and metadata is not None:
|
|
102
|
+
meta = metadata
|
|
103
|
+
|
|
104
|
+
sub_agent_context = kwargs.pop("sub_agent_context", None)
|
|
105
|
+
|
|
106
|
+
request_kwargs: Dict[str, Any] = {
|
|
107
|
+
"agent": agent_target if not agent_id else None,
|
|
108
|
+
"agent_id": agent_id,
|
|
109
|
+
"application": application,
|
|
110
|
+
"application_id": application_id,
|
|
111
|
+
"params": params,
|
|
112
|
+
"session_id": str(session_id),
|
|
113
|
+
"meta": meta or {},
|
|
114
|
+
}
|
|
115
|
+
if (
|
|
116
|
+
sub_agent_context is not None
|
|
117
|
+
and "sub_agent_context" in AgentRequest.model_fields
|
|
118
|
+
):
|
|
119
|
+
request_kwargs["sub_agent_context"] = sub_agent_context
|
|
120
|
+
|
|
121
|
+
for key in (
|
|
122
|
+
"task_id",
|
|
123
|
+
"request_id",
|
|
124
|
+
"execution_mode",
|
|
125
|
+
"max_iterations",
|
|
126
|
+
"max_steps",
|
|
127
|
+
"high_performance",
|
|
128
|
+
"disable_chaining",
|
|
129
|
+
"disable_strategy",
|
|
130
|
+
"delegation_intent",
|
|
131
|
+
"config",
|
|
132
|
+
"actions",
|
|
133
|
+
"state",
|
|
134
|
+
"secrets",
|
|
135
|
+
):
|
|
136
|
+
if key in kwargs:
|
|
137
|
+
request_kwargs[key] = kwargs.pop(key)
|
|
138
|
+
|
|
139
|
+
if kwargs:
|
|
140
|
+
unknown = ", ".join(sorted(kwargs.keys()))
|
|
141
|
+
raise ValueError(f"Unknown kwargs for ctx.agent_completion: {unknown}")
|
|
142
|
+
|
|
143
|
+
return AgentRequest(**request_kwargs)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def redact_agent_log_fields(fields: Dict[str, Any]) -> Dict[str, Any]:
|
|
147
|
+
"""Return a copy safe for ctx.log (secrets redacted)."""
|
|
148
|
+
out: Dict[str, Any] = {}
|
|
149
|
+
for key, value in fields.items():
|
|
150
|
+
if key == "secrets" and isinstance(value, dict):
|
|
151
|
+
out[key] = {k: "***" for k in value}
|
|
152
|
+
elif key == "params" and isinstance(value, dict) and "messages" in value:
|
|
153
|
+
out[key] = {**value, "messages": f"<{len(value['messages'])} messages>"}
|
|
154
|
+
else:
|
|
155
|
+
out[key] = value
|
|
156
|
+
return out
|