maitai-python 1.0.41b0__tar.gz → 1.0.42b0__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.41b0 → maitai_python-1.0.42b0}/PKG-INFO +1 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_maitai.py +2 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_maitai_async.py +2 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_utils.py +19 -15
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/tools/__init__.py +24 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/version.py +1 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/README.md +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_azure.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_config.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_context.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_evaluator.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_inference.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai/_types.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/chat/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/config/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/model/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/setup.cfg +0 -0
- {maitai_python-1.0.41b0 → maitai_python-1.0.42b0}/setup.py +0 -0
|
@@ -14,6 +14,7 @@ from maitai._evaluator import Evaluator
|
|
|
14
14
|
from maitai._inference import InferenceException, InferenceWarning
|
|
15
15
|
from maitai._types import Body, Headers, MaitaiChunk, MaitaiCompletion, Query, ToolFunction
|
|
16
16
|
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params, required_args
|
|
17
|
+
from maitai.tools import Tools
|
|
17
18
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
18
19
|
from maitai_common.utils.types import EvaluateCallback
|
|
19
20
|
from maitai_gen.chat import ChatCompletionParams, ChatCompletionRequest, ChatMessage, ClientParams, EvaluationContentType
|
|
@@ -134,7 +135,7 @@ class Completions:
|
|
|
134
135
|
stream_options: Union[Optional[openai_chat_types.ChatCompletionStreamOptionsParam], openai.NotGiven] = openai.NOT_GIVEN,
|
|
135
136
|
temperature: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
136
137
|
tool_choice: Union[openai_chat_types.ChatCompletionToolChoiceOptionParam, openai.NotGiven] = openai.NOT_GIVEN,
|
|
137
|
-
tools: Union[Iterable[Union[openai_chat_types.ChatCompletionToolParam, ToolFunction]], openai.NotGiven] = openai.NOT_GIVEN,
|
|
138
|
+
tools: Union[Tools, Iterable[Union[openai_chat_types.ChatCompletionToolParam, ToolFunction]], openai.NotGiven] = openai.NOT_GIVEN,
|
|
138
139
|
top_logprobs: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
139
140
|
top_p: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
140
141
|
user: Union[str, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -13,6 +13,7 @@ from maitai._evaluator import Evaluator
|
|
|
13
13
|
from maitai._inference import InferenceException, InferenceWarning
|
|
14
14
|
from maitai._types import Body, Headers, MaitaiChunk, MaitaiCompletion, Query, ToolFunction
|
|
15
15
|
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params, required_args
|
|
16
|
+
from maitai.tools import Tools
|
|
16
17
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
17
18
|
from maitai_common.utils.types import EvaluateCallback
|
|
18
19
|
from maitai_gen.chat import ChatCompletionParams, ChatCompletionRequest, ChatMessage, ClientParams, EvaluationContentType
|
|
@@ -132,7 +133,7 @@ class AsyncCompletions:
|
|
|
132
133
|
stream_options: Union[Optional[openai_chat_types.ChatCompletionStreamOptionsParam], openai.NotGiven] = openai.NOT_GIVEN,
|
|
133
134
|
temperature: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
134
135
|
tool_choice: Union[openai_chat_types.ChatCompletionToolChoiceOptionParam, openai.NotGiven] = openai.NOT_GIVEN,
|
|
135
|
-
tools: Union[Iterable[Union[openai_chat_types.ChatCompletionToolParam, ToolFunction]], openai.NotGiven] = openai.NOT_GIVEN, top_logprobs: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
136
|
+
tools: Union[Tools, Iterable[Union[openai_chat_types.ChatCompletionToolParam, ToolFunction]], openai.NotGiven] = openai.NOT_GIVEN, top_logprobs: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
136
137
|
top_p: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
137
138
|
user: Union[str, openai.NotGiven] = openai.NOT_GIVEN,
|
|
138
139
|
extra_headers: Optional[Headers] = None,
|
|
@@ -10,6 +10,7 @@ from openai.types import ChatModel
|
|
|
10
10
|
|
|
11
11
|
import maitai_gen.chat as chat_types
|
|
12
12
|
from maitai._types import ToolFunction
|
|
13
|
+
from maitai.tools import Tools
|
|
13
14
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
14
15
|
from maitai_common.version import version
|
|
15
16
|
|
|
@@ -155,23 +156,26 @@ def get_chat_completion_params(*,
|
|
|
155
156
|
|
|
156
157
|
if tools != openai.NOT_GIVEN:
|
|
157
158
|
params.tools = []
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
159
|
+
if isinstance(tools, Tools):
|
|
160
|
+
params.tools = tools.get_tool_definitions()
|
|
161
|
+
else:
|
|
162
|
+
for tool in tools:
|
|
163
|
+
if isinstance(tool, Callable) and not isinstance(tool, ToolFunction):
|
|
164
|
+
raise TypeError(f"Method passed into tools missing @tool decorator")
|
|
165
|
+
if isinstance(tool, ToolFunction):
|
|
166
|
+
params.tools.append(tool.__tool__)
|
|
167
|
+
continue
|
|
168
|
+
function = tool.get("function")
|
|
169
|
+
params.tools.append(
|
|
170
|
+
chat_types.Tool(
|
|
171
|
+
type=tool["type"],
|
|
172
|
+
function=chat_types.Function(
|
|
173
|
+
name=function.get("name"),
|
|
174
|
+
description=function.get("description"),
|
|
175
|
+
parameters=function.get("parameters")
|
|
176
|
+
)
|
|
172
177
|
)
|
|
173
178
|
)
|
|
174
|
-
)
|
|
175
179
|
return params
|
|
176
180
|
|
|
177
181
|
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import inspect
|
|
2
|
+
import json
|
|
2
3
|
import re
|
|
3
4
|
from typing import get_type_hints
|
|
4
5
|
|
|
5
|
-
from
|
|
6
|
+
from maitai._types import ToolFunction
|
|
7
|
+
from maitai_gen.chat import Function, Tool, ToolCall
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Tools:
|
|
11
|
+
def __init__(self, *tools):
|
|
12
|
+
self.available_functions = {}
|
|
13
|
+
self.definitions = []
|
|
14
|
+
for func in tools:
|
|
15
|
+
if not isinstance(func, ToolFunction):
|
|
16
|
+
raise TypeError(f"Method passed into tools missing @tool decorator")
|
|
17
|
+
tool_call = func.__tool__
|
|
18
|
+
self.available_functions[tool_call.function.name] = func
|
|
19
|
+
self.definitions.append(tool_call)
|
|
20
|
+
|
|
21
|
+
def get_tool_definitions(self):
|
|
22
|
+
return self.definitions
|
|
23
|
+
|
|
24
|
+
def invoke(self, tool_call: ToolCall):
|
|
25
|
+
function_to_call = self.available_functions[tool_call.function.name]
|
|
26
|
+
function_args = json.loads(tool_call.function.arguments)
|
|
27
|
+
function_response = function_to_call(**function_args)
|
|
28
|
+
return function_response
|
|
6
29
|
|
|
7
30
|
|
|
8
31
|
def tool(func):
|
|
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
|
|
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.41b0 → maitai_python-1.0.42b0}/maitai_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|