maitai-python 1.0.40b1__tar.gz → 1.0.41__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.
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/PKG-INFO +1 -1
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_inference.py +4 -5
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/tools/__init__.py +28 -24
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/version.py +1 -1
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/chat/__init__.py +3 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/README.md +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_azure.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_config.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_context.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_evaluator.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_maitai.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_maitai_async.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_types.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai/_utils.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/config/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/model/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/setup.cfg +0 -0
- {maitai_python-1.0.40b1 → maitai_python-1.0.41}/setup.py +0 -0
|
@@ -70,8 +70,7 @@ class Inference(MaitaiClient):
|
|
|
70
70
|
}
|
|
71
71
|
response = requests.post(url, headers=headers, data=chat_request.to_json(casing=Casing.SNAKE), stream=True)
|
|
72
72
|
if response.status_code != 200:
|
|
73
|
-
|
|
74
|
-
return
|
|
73
|
+
raise InferenceException(f"Failed to send inference request. Status code: {response.status_code}. Error: {response.text}")
|
|
75
74
|
try:
|
|
76
75
|
for line in response.iter_lines():
|
|
77
76
|
if line:
|
|
@@ -96,11 +95,11 @@ class Inference(MaitaiClient):
|
|
|
96
95
|
async with session.post(url, headers=headers, data=chat_request.to_json(casing=Casing.SNAKE)) as response:
|
|
97
96
|
if response.status != 200:
|
|
98
97
|
error_text = await response.text()
|
|
99
|
-
|
|
98
|
+
exception = InferenceException(f"Failed to send inference request. Status code: {response.status}. Error: {error_text}")
|
|
100
99
|
if chunk_queue:
|
|
101
|
-
chunk_queue.put(
|
|
100
|
+
chunk_queue.put(exception)
|
|
102
101
|
if async_chunk_queue:
|
|
103
|
-
await async_chunk_queue.put(
|
|
102
|
+
await async_chunk_queue.put(exception)
|
|
104
103
|
return
|
|
105
104
|
async for line in response.content:
|
|
106
105
|
if line:
|
|
@@ -6,7 +6,7 @@ from maitai_gen.chat import Function, Tool
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def tool(func):
|
|
9
|
-
function_description =
|
|
9
|
+
function_description = func.__doc__
|
|
10
10
|
if not function_description:
|
|
11
11
|
raise ValueError("Missing docstring for tool")
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ def tool(func):
|
|
|
20
20
|
required = []
|
|
21
21
|
type_hints = get_type_hints(func)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
param_descriptions = _extract_param_details(func.__doc__)
|
|
24
24
|
for param_name, param in params.items():
|
|
25
25
|
if param_name in type_hints:
|
|
26
26
|
param_type = type_hints[param_name].__name__
|
|
@@ -28,10 +28,10 @@ def tool(func):
|
|
|
28
28
|
param_type = type(param.default).__name__
|
|
29
29
|
else:
|
|
30
30
|
param_type = "string"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
properties[param_name] = {
|
|
32
|
+
"type": _parse_type(param_type),
|
|
33
|
+
"description": param_descriptions.get(param_name, ""),
|
|
34
|
+
}
|
|
35
35
|
if param.default is param.empty:
|
|
36
36
|
required.append(param_name)
|
|
37
37
|
|
|
@@ -50,31 +50,35 @@ def tool(func):
|
|
|
50
50
|
return wrapper
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def
|
|
54
|
-
lines = docstring.split("\n")
|
|
55
|
-
description = []
|
|
56
|
-
for line in lines:
|
|
57
|
-
if not line.strip().startswith(":"):
|
|
58
|
-
description.append(line.strip())
|
|
59
|
-
else:
|
|
60
|
-
break
|
|
61
|
-
return " ".join(description).strip()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _extract_param_descriptions(docstring):
|
|
53
|
+
def _extract_param_details(docstring):
|
|
65
54
|
param_descriptions = {}
|
|
66
55
|
param_pattern = re.compile(r":param (\w+): (.+)")
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
args_pattern = re.compile(r"Args:\s*(.*?)(?=\n\S|$)", re.DOTALL)
|
|
57
|
+
arg_param_pattern = re.compile(r"(\w+): (.+)")
|
|
58
|
+
|
|
59
|
+
args_match = args_pattern.search(docstring)
|
|
60
|
+
if args_match:
|
|
61
|
+
args_section = args_match.group(1)
|
|
62
|
+
arg_lines = args_section.split("\n")
|
|
63
|
+
for line in arg_lines:
|
|
64
|
+
if line.strip():
|
|
65
|
+
param_match = arg_param_pattern.match(line.strip())
|
|
66
|
+
if param_match:
|
|
67
|
+
param_name, param_description = param_match.groups()
|
|
68
|
+
param_descriptions[param_name] = param_description.strip()
|
|
69
|
+
param_matches = param_pattern.findall(docstring)
|
|
70
|
+
for param, description in param_matches:
|
|
69
71
|
param_descriptions[param] = description.strip()
|
|
70
72
|
return param_descriptions
|
|
71
73
|
|
|
72
74
|
|
|
73
75
|
def _parse_type(type_string):
|
|
74
|
-
if type_string == "str":
|
|
76
|
+
if type_string == "str" or type_string == "string":
|
|
75
77
|
return "string"
|
|
76
|
-
if type_string == "int" or type_string == "
|
|
77
|
-
return "
|
|
78
|
-
if type_string == "bool":
|
|
78
|
+
if type_string == "int" or type_string == "integer":
|
|
79
|
+
return "integer"
|
|
80
|
+
if type_string == "bool" or type_string == "boolean":
|
|
79
81
|
return "boolean"
|
|
82
|
+
if type_string == "float" or type_string == "number":
|
|
83
|
+
return "number"
|
|
80
84
|
return "string"
|
|
@@ -185,6 +185,9 @@ class ChatMessage(betterproto.Message):
|
|
|
185
185
|
)
|
|
186
186
|
name: Optional[str] = betterproto.string_field(3, optional=True, group="_name")
|
|
187
187
|
tool_calls: List["ToolCall"] = betterproto.message_field(4)
|
|
188
|
+
tool_call_id: Optional[str] = betterproto.string_field(
|
|
189
|
+
5, optional=True, group="_tool_call_id"
|
|
190
|
+
)
|
|
188
191
|
|
|
189
192
|
|
|
190
193
|
@dataclass(eq=False, repr=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{maitai_python-1.0.40b1 → maitai_python-1.0.41}/maitai_common/processes/websocket_listener_thread.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|