maitai-python 1.2.3__py3-none-any.whl → 1.2.4__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/__init__.py +3 -7
- maitai/_maitai.py +40 -11
- maitai/_maitai_async.py +39 -11
- maitai_common/version.py +1 -1
- maitai_gen/chat/__init__.py +9 -0
- maitai_gen/key/__init__.py +2 -0
- {maitai_python-1.2.3.dist-info → maitai_python-1.2.4.dist-info}/METADATA +1 -1
- {maitai_python-1.2.3.dist-info → maitai_python-1.2.4.dist-info}/RECORD +10 -11
- maitai/_azure.py +0 -217
- {maitai_python-1.2.3.dist-info → maitai_python-1.2.4.dist-info}/WHEEL +0 -0
- {maitai_python-1.2.3.dist-info → maitai_python-1.2.4.dist-info}/top_level.txt +0 -0
maitai/__init__.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from maitai._azure import MaitaiAsyncAzureOpenAIClient, MaitaiAzureOpenAIClient
|
|
4
1
|
from maitai._context import ContextManager
|
|
5
|
-
from maitai._evaluator import Evaluator as Evaluator
|
|
6
|
-
from maitai._inference import Inference as Inference
|
|
2
|
+
from maitai._evaluator import Evaluator as Evaluator # noqa
|
|
3
|
+
from maitai._inference import Inference as Inference # noqa
|
|
7
4
|
from maitai._maitai import Chat, Maitai
|
|
8
5
|
from maitai._maitai_async import MaitaiAsync
|
|
9
6
|
|
|
@@ -12,8 +9,7 @@ context = ContextManager()
|
|
|
12
9
|
AsyncOpenAI = MaitaiAsync
|
|
13
10
|
OpenAI = Maitai
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
AzureOpenAI = MaitaiAzureOpenAIClient
|
|
12
|
+
AsyncMaitai = MaitaiAsync
|
|
17
13
|
|
|
18
14
|
|
|
19
15
|
def initialize(api_key):
|
maitai/_maitai.py
CHANGED
|
@@ -35,7 +35,12 @@ from maitai._utils import (
|
|
|
35
35
|
required_args,
|
|
36
36
|
)
|
|
37
37
|
from maitai.tools import Tools
|
|
38
|
-
from maitai_gen.chat import
|
|
38
|
+
from maitai_gen.chat import (
|
|
39
|
+
AzureParams,
|
|
40
|
+
ChatCompletionParams,
|
|
41
|
+
ClientParams,
|
|
42
|
+
EvaluationContentType,
|
|
43
|
+
)
|
|
39
44
|
from maitai_gen.config import InferenceLocations
|
|
40
45
|
from maitai_gen.inference import InferenceStreamResponse
|
|
41
46
|
from maitai_gen.metric import RequestTimingMetric
|
|
@@ -53,6 +58,10 @@ class Maitai:
|
|
|
53
58
|
groq_api_key: Optional[str] = None,
|
|
54
59
|
anthropic_api_key: Optional[str] = None,
|
|
55
60
|
cerebras_api_key: Optional[str] = None,
|
|
61
|
+
azure_api_key: Optional[str] = None,
|
|
62
|
+
azure_deployment: Optional[str] = None,
|
|
63
|
+
azure_api_version: Optional[str] = None,
|
|
64
|
+
azure_endpoint: Optional[str] = None,
|
|
56
65
|
organization: Optional[str] = None,
|
|
57
66
|
project: Optional[str] = None,
|
|
58
67
|
base_url: Union[str, httpx.URL, None] = None,
|
|
@@ -72,14 +81,9 @@ class Maitai:
|
|
|
72
81
|
"MAITAI_API_KEY has not been set. Either set via environment variable or pass it directly into the client."
|
|
73
82
|
)
|
|
74
83
|
if api_key:
|
|
75
|
-
|
|
76
|
-
openai_api_key
|
|
77
|
-
|
|
78
|
-
groq_api_key = api_key
|
|
79
|
-
if not anthropic_api_key:
|
|
80
|
-
anthropic_api_key = api_key
|
|
81
|
-
if not cerebras_api_key:
|
|
82
|
-
cerebras_api_key = api_key
|
|
84
|
+
raise ValueError(
|
|
85
|
+
"api_key is deprecated. Use provider specific keys instead. Supported variables: openai_api_key, groq_api_key, anthropic_api_key, cerebras_api_key, azure_api_key"
|
|
86
|
+
)
|
|
83
87
|
if openai_api_key:
|
|
84
88
|
config.auth_keys.openai_api_key.key_value = openai_api_key
|
|
85
89
|
if groq_api_key:
|
|
@@ -88,10 +92,34 @@ class Maitai:
|
|
|
88
92
|
config.auth_keys.anthropic_api_key.key_value = anthropic_api_key
|
|
89
93
|
if cerebras_api_key:
|
|
90
94
|
config.auth_keys.cerebras_api_key.key_value = cerebras_api_key
|
|
95
|
+
if azure_api_key:
|
|
96
|
+
config.auth_keys.azure_api_key.key_value = azure_api_key
|
|
91
97
|
self._client = None
|
|
92
|
-
|
|
98
|
+
azure_params = None
|
|
99
|
+
if azure_api_key:
|
|
100
|
+
azure_params = AzureParams(
|
|
101
|
+
endpoint=azure_endpoint,
|
|
102
|
+
deployment=azure_deployment,
|
|
103
|
+
api_version=azure_api_version,
|
|
104
|
+
)
|
|
105
|
+
self._client = openai.AzureOpenAI(
|
|
106
|
+
azure_endpoint=azure_endpoint,
|
|
107
|
+
azure_deployment=azure_deployment,
|
|
108
|
+
api_key=azure_api_key,
|
|
109
|
+
api_version=azure_api_version,
|
|
110
|
+
organization=organization,
|
|
111
|
+
project=project,
|
|
112
|
+
base_url=base_url,
|
|
113
|
+
timeout=timeout,
|
|
114
|
+
max_retries=max_retries,
|
|
115
|
+
default_headers=default_headers,
|
|
116
|
+
default_query=default_query,
|
|
117
|
+
http_client=http_client,
|
|
118
|
+
_strict_response_validation=_strict_response_validation,
|
|
119
|
+
)
|
|
120
|
+
elif openai_api_key or os.environ.get("OPENAI_API_KEY"):
|
|
93
121
|
self._client = openai.OpenAI(
|
|
94
|
-
api_key=
|
|
122
|
+
api_key=openai_api_key or os.environ.get("OPENAI_API_KEY"),
|
|
95
123
|
organization=organization,
|
|
96
124
|
project=project,
|
|
97
125
|
base_url=base_url,
|
|
@@ -108,6 +136,7 @@ class Maitai:
|
|
|
108
136
|
base_url=base_url or "",
|
|
109
137
|
default_headers=default_headers or {},
|
|
110
138
|
default_query=default_query or {},
|
|
139
|
+
azure_params=azure_params,
|
|
111
140
|
)
|
|
112
141
|
self.chat = Chat(self._client, client_params)
|
|
113
142
|
|
maitai/_maitai_async.py
CHANGED
|
@@ -35,7 +35,12 @@ from maitai._utils import (
|
|
|
35
35
|
required_args,
|
|
36
36
|
)
|
|
37
37
|
from maitai.tools import Tools
|
|
38
|
-
from maitai_gen.chat import
|
|
38
|
+
from maitai_gen.chat import (
|
|
39
|
+
AzureParams,
|
|
40
|
+
ChatCompletionParams,
|
|
41
|
+
ClientParams,
|
|
42
|
+
EvaluationContentType,
|
|
43
|
+
)
|
|
39
44
|
from maitai_gen.config import InferenceLocations
|
|
40
45
|
from maitai_gen.inference import InferenceStreamResponse
|
|
41
46
|
from maitai_gen.metric import RequestTimingMetric
|
|
@@ -53,6 +58,10 @@ class MaitaiAsync:
|
|
|
53
58
|
groq_api_key: Optional[str] = None,
|
|
54
59
|
anthropic_api_key: Optional[str] = None,
|
|
55
60
|
cerebras_api_key: Optional[str] = None,
|
|
61
|
+
azure_api_key: Optional[str] = None,
|
|
62
|
+
azure_deployment: Optional[str] = None,
|
|
63
|
+
azure_api_version: Optional[str] = None,
|
|
64
|
+
azure_endpoint: Optional[str] = None,
|
|
56
65
|
organization: Optional[str] = None,
|
|
57
66
|
project: Optional[str] = None,
|
|
58
67
|
base_url: Union[str, httpx.URL, None] = None,
|
|
@@ -72,14 +81,9 @@ class MaitaiAsync:
|
|
|
72
81
|
"MAITAI_API_KEY has not been set. Either set via environment variable or pass it directly into the client."
|
|
73
82
|
)
|
|
74
83
|
if api_key:
|
|
75
|
-
|
|
76
|
-
openai_api_key
|
|
77
|
-
|
|
78
|
-
groq_api_key = api_key
|
|
79
|
-
if not anthropic_api_key:
|
|
80
|
-
anthropic_api_key = api_key
|
|
81
|
-
if not cerebras_api_key:
|
|
82
|
-
cerebras_api_key = api_key
|
|
84
|
+
raise ValueError(
|
|
85
|
+
"api_key is deprecated. Use provider specific keys instead. Supported variables: openai_api_key, groq_api_key, anthropic_api_key, cerebras_api_key, azure_api_key"
|
|
86
|
+
)
|
|
83
87
|
if openai_api_key:
|
|
84
88
|
config.auth_keys.openai_api_key.key_value = openai_api_key
|
|
85
89
|
if groq_api_key:
|
|
@@ -88,10 +92,33 @@ class MaitaiAsync:
|
|
|
88
92
|
config.auth_keys.anthropic_api_key.key_value = anthropic_api_key
|
|
89
93
|
if cerebras_api_key:
|
|
90
94
|
config.auth_keys.cerebras_api_key.key_value = cerebras_api_key
|
|
95
|
+
if azure_api_key:
|
|
96
|
+
config.auth_keys.azure_api_key.key_value = azure_api_key
|
|
91
97
|
self._client = None
|
|
92
|
-
if
|
|
98
|
+
if azure_api_key:
|
|
99
|
+
azure_params = AzureParams(
|
|
100
|
+
endpoint=azure_endpoint,
|
|
101
|
+
deployment=azure_deployment,
|
|
102
|
+
api_version=azure_api_version,
|
|
103
|
+
)
|
|
104
|
+
self._client = openai.AsyncAzureOpenAI(
|
|
105
|
+
azure_endpoint=azure_endpoint,
|
|
106
|
+
azure_deployment=azure_deployment,
|
|
107
|
+
api_key=azure_api_key,
|
|
108
|
+
api_version=azure_api_version,
|
|
109
|
+
organization=organization,
|
|
110
|
+
project=project,
|
|
111
|
+
base_url=base_url,
|
|
112
|
+
timeout=timeout,
|
|
113
|
+
max_retries=max_retries,
|
|
114
|
+
default_headers=default_headers,
|
|
115
|
+
default_query=default_query,
|
|
116
|
+
http_client=http_client,
|
|
117
|
+
_strict_response_validation=_strict_response_validation,
|
|
118
|
+
)
|
|
119
|
+
elif openai_api_key or os.environ.get("OPENAI_API_KEY"):
|
|
93
120
|
self._client = openai.AsyncClient(
|
|
94
|
-
api_key=
|
|
121
|
+
api_key=openai_api_key or os.environ.get("OPENAI_API_KEY"),
|
|
95
122
|
organization=organization,
|
|
96
123
|
project=project,
|
|
97
124
|
base_url=base_url,
|
|
@@ -109,6 +136,7 @@ class MaitaiAsync:
|
|
|
109
136
|
base_url=base_url or "",
|
|
110
137
|
default_headers=default_headers or {},
|
|
111
138
|
default_query=default_query or {},
|
|
139
|
+
azure_params=azure_params,
|
|
112
140
|
)
|
|
113
141
|
self.chat = AsyncChat(self._client, client_params)
|
|
114
142
|
|
maitai_common/version.py
CHANGED
maitai_gen/chat/__init__.py
CHANGED
|
@@ -77,6 +77,13 @@ class ChatCompletionRequest(betterproto.Message):
|
|
|
77
77
|
fallback_config: "_config__.FallbackConfig" = betterproto.message_field(27)
|
|
78
78
|
|
|
79
79
|
|
|
80
|
+
@dataclass(eq=False, repr=False)
|
|
81
|
+
class AzureParams(betterproto.Message):
|
|
82
|
+
endpoint: str = betterproto.string_field(1)
|
|
83
|
+
deployment: str = betterproto.string_field(2)
|
|
84
|
+
api_version: str = betterproto.string_field(3)
|
|
85
|
+
|
|
86
|
+
|
|
80
87
|
@dataclass(eq=False, repr=False)
|
|
81
88
|
class ClientParams(betterproto.Message):
|
|
82
89
|
base_url: str = betterproto.string_field(1)
|
|
@@ -86,6 +93,7 @@ class ClientParams(betterproto.Message):
|
|
|
86
93
|
default_query: Dict[str, str] = betterproto.map_field(
|
|
87
94
|
3, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
88
95
|
)
|
|
96
|
+
azure_params: "AzureParams" = betterproto.message_field(4)
|
|
89
97
|
|
|
90
98
|
|
|
91
99
|
@dataclass(eq=False, repr=False)
|
|
@@ -95,6 +103,7 @@ class ChatCompletionAuth(betterproto.Message):
|
|
|
95
103
|
override_api_key: str = betterproto.string_field(3)
|
|
96
104
|
anthropic_api_key: str = betterproto.string_field(4)
|
|
97
105
|
cerebras_api_key: str = betterproto.string_field(5)
|
|
106
|
+
azure_api_key: str = betterproto.string_field(6)
|
|
98
107
|
|
|
99
108
|
|
|
100
109
|
@dataclass(eq=False, repr=False)
|
maitai_gen/key/__init__.py
CHANGED
|
@@ -28,6 +28,7 @@ class KeyIdMap(betterproto.Message):
|
|
|
28
28
|
groq_api_key: int = betterproto.int64_field(2)
|
|
29
29
|
anthropic_api_key: int = betterproto.int64_field(3)
|
|
30
30
|
cerebras_api_key: int = betterproto.int64_field(4)
|
|
31
|
+
azure_api_key: int = betterproto.int64_field(5)
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
@dataclass(eq=False, repr=False)
|
|
@@ -36,3 +37,4 @@ class KeyMap(betterproto.Message):
|
|
|
36
37
|
groq_api_key: "Key" = betterproto.message_field(2)
|
|
37
38
|
anthropic_api_key: "Key" = betterproto.message_field(3)
|
|
38
39
|
cerebras_api_key: "Key" = betterproto.message_field(4)
|
|
40
|
+
azure_api_key: "Key" = betterproto.message_field(5)
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
maitai/__init__.py,sha256=
|
|
2
|
-
maitai/_azure.py,sha256=ZQXVzmU2QPJ41wQUxqFkyeAKAJ6HrMoQKDbi3lyUJVc,8513
|
|
1
|
+
maitai/__init__.py,sha256=1nR3g4MXSM5Xj-HKcDa2pdhQJMqIv-7HzNL8R5J4fEU,458
|
|
3
2
|
maitai/_config.py,sha256=IkpwORKXpO2rDRJ6JHmuGWb29g9IR9Cc2Tl3VrDuMH8,7603
|
|
4
3
|
maitai/_config_listener_thread.py,sha256=VaftjUXrP8oe6yg0TXUlIZW2vGw7bTk8p_95o4dSVgo,902
|
|
5
4
|
maitai/_context.py,sha256=WmCLGd7BK1ViImd7uDTsjly7ECcugioZhGjxXwETHfI,2401
|
|
6
5
|
maitai/_evaluator.py,sha256=x2XSKv6h90VcYBnqb1BRcPOrX7O3gQ4hShZCJzXfO9Y,10344
|
|
7
6
|
maitai/_inference.py,sha256=4cijo8J7LDLOZFxD9jPeF9KMUmPk8xG-NaT8cGYaITs,12597
|
|
8
|
-
maitai/_maitai.py,sha256=
|
|
9
|
-
maitai/_maitai_async.py,sha256=
|
|
7
|
+
maitai/_maitai.py,sha256=5aF0SGbpt3O7Lu-9zHCWdPq133SlyW-uwJ9c6gMlco4,25561
|
|
8
|
+
maitai/_maitai_async.py,sha256=1Wh5KDOYesC-7xAw58iITAI5RRA4DvmCES1lRpboXzI,25636
|
|
10
9
|
maitai/_maitai_client.py,sha256=s3eZAu4HmJauZMVIxi5X5ZeW-ZChKDKK4h3LHJ3PHVs,7744
|
|
11
10
|
maitai/_types.py,sha256=uIYm1YQv6ZmGZ4GG6p6xrCjfVGq8VSxkehLgRqtr1Rw,6436
|
|
12
11
|
maitai/_utils.py,sha256=3JN5MClGZNkcmn-hWgi8fNV2n-Ytlek37H3S6TEHzuk,11276
|
|
13
12
|
maitai/tools/__init__.py,sha256=TxJ-g4A0eIzoIMD60ctIPVppCWcdcuZWms3hPGrqkSs,4043
|
|
14
13
|
maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
maitai_common/version.py,sha256=
|
|
14
|
+
maitai_common/version.py,sha256=zwTylIRzKGP6obXkwBrpBIu_zH55DgBVS8mTvJYuyfo,64
|
|
16
15
|
maitai_common/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
16
|
maitai_common/config/config_service.py,sha256=U8hU0F9juZtrZwIayOM_OBShxynUS8gu5K0F40KvcA0,940
|
|
18
17
|
maitai_common/processes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -23,7 +22,7 @@ maitai_gen/model.py,sha256=o44eE5ZO9KRTPJETMA9aCGO5CL4PKd06Ih57Zy76wJA,910
|
|
|
23
22
|
maitai_gen/application/__init__.py,sha256=PY7Q6Lxr7YfyhmFe_xnbGlz14tGoBEbpYA6EBEAI7M0,2430
|
|
24
23
|
maitai_gen/backtest/__init__.py,sha256=_9B-q5F1YTPOgGLBTRZCdFnv54SizjfK0bFCaDi6UzM,467
|
|
25
24
|
maitai_gen/billing/__init__.py,sha256=yP9k5pCuI8mehQDHqVrBDWldVsLZ7-LlwpRorESdsN4,2664
|
|
26
|
-
maitai_gen/chat/__init__.py,sha256=
|
|
25
|
+
maitai_gen/chat/__init__.py,sha256=4Vr5O9gLYvCY9LSjZ_TH-WUjgnALVaj5v-b3nCMyEQA,22670
|
|
27
26
|
maitai_gen/company/__init__.py,sha256=Jj03m8QlVsGLr0VQA-T5yxjbC1R3cx0gthUwgtbtGuc,739
|
|
28
27
|
maitai_gen/config/__init__.py,sha256=k9tdqH1uhV-cYkZn1FtP4rzMxmKJRGJzxaToWFbTY1g,2298
|
|
29
28
|
maitai_gen/embedding/__init__.py,sha256=py5vAEdXFatL7daub1YSnruIRV-im0heWSa5hjaSljM,941
|
|
@@ -31,14 +30,14 @@ maitai_gen/evaluation/__init__.py,sha256=HdrDNEPlV3lrvw14VyoeLnY_u8jfGDcocSv2XD9
|
|
|
31
30
|
maitai_gen/event/__init__.py,sha256=puOhfH-KQu_fL-yPJPjceDhwy3VbzP0oTtQs-RHeTE4,670
|
|
32
31
|
maitai_gen/finetuning/__init__.py,sha256=e0kdoBdKjXXgufokcEr5WOjEFuqRE1JUCj3FJ0SroHA,3301
|
|
33
32
|
maitai_gen/inference/__init__.py,sha256=KUWiTng5KeibART4NZ91JuN6fR4u7hmxcx8BjhCde78,741
|
|
34
|
-
maitai_gen/key/__init__.py,sha256=
|
|
33
|
+
maitai_gen/key/__init__.py,sha256=6B924RX6F50vOEUVMuw8Ca1leVraneWquAYppZ9d_eI,1446
|
|
35
34
|
maitai_gen/metric/__init__.py,sha256=RX1sF74PB2L2lTD7EYfim5BSRmvGVd63L__IgJhZDh0,615
|
|
36
35
|
maitai_gen/notification/__init__.py,sha256=l4M2OlHvKhnU3ygytk0-voSypDAhjzNch6C7XXVnn6s,1301
|
|
37
36
|
maitai_gen/rates/__init__.py,sha256=Aho7HzMKRfjQz10tMJCoRVttq_cGlYh2DxxpSyTQAzU,1382
|
|
38
37
|
maitai_gen/sandbox/__init__.py,sha256=IZ4hf76V1aZrYk5S-4p7z38e-op_s341utVG2domE_g,1549
|
|
39
38
|
maitai_gen/sentinel/__init__.py,sha256=3yR28usTBIAC-M_uxEUFgqXo2PWylEKEPYmWX_dp7Cs,2513
|
|
40
39
|
maitai_gen/session/__init__.py,sha256=kCJweCFagUqGkzktucaWLti9HSLaO5AML8Jewl89yM0,1242
|
|
41
|
-
maitai_python-1.2.
|
|
42
|
-
maitai_python-1.2.
|
|
43
|
-
maitai_python-1.2.
|
|
44
|
-
maitai_python-1.2.
|
|
40
|
+
maitai_python-1.2.4.dist-info/METADATA,sha256=2Nb36FnHnla5DvNkCLTqrgXXTByso_68lGlamkaPhdg,1494
|
|
41
|
+
maitai_python-1.2.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
42
|
+
maitai_python-1.2.4.dist-info/top_level.txt,sha256=-5U1krxnwlqB-AY7nEe29ZcNvwByNc-SnBe-mph-QjI,32
|
|
43
|
+
maitai_python-1.2.4.dist-info/RECORD,,
|
maitai/_azure.py
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
from typing import Mapping, Optional, overload, Union
|
|
2
|
-
|
|
3
|
-
import httpx
|
|
4
|
-
import openai
|
|
5
|
-
from openai.lib.azure import AsyncAzureADTokenProvider, AzureADTokenProvider
|
|
6
|
-
|
|
7
|
-
from maitai._config import config
|
|
8
|
-
from maitai._maitai import Chat
|
|
9
|
-
from maitai._maitai_async import AsyncChat
|
|
10
|
-
|
|
11
|
-
DEFAULT_MAX_RETRIES = 2
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class MaitaiAsyncAzureOpenAIClient:
|
|
15
|
-
@overload
|
|
16
|
-
def __init__(
|
|
17
|
-
self,
|
|
18
|
-
*,
|
|
19
|
-
azure_endpoint: str,
|
|
20
|
-
maitai_api_key: Optional[str] = None,
|
|
21
|
-
azure_deployment: Optional[str] = None,
|
|
22
|
-
api_version: Optional[str] = None,
|
|
23
|
-
api_key: Optional[str] = None,
|
|
24
|
-
azure_ad_token: Optional[str] = None,
|
|
25
|
-
azure_ad_token_provider: Optional[AsyncAzureADTokenProvider] = None,
|
|
26
|
-
organization: Optional[str] = None,
|
|
27
|
-
project: Optional[str] = None,
|
|
28
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
29
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
30
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
31
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
32
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
33
|
-
_strict_response_validation: bool = False,
|
|
34
|
-
) -> None: ...
|
|
35
|
-
|
|
36
|
-
@overload
|
|
37
|
-
def __init__(
|
|
38
|
-
self,
|
|
39
|
-
*,
|
|
40
|
-
maitai_api_key: Optional[str] = None,
|
|
41
|
-
azure_deployment: Optional[str] = None,
|
|
42
|
-
api_version: Optional[str] = None,
|
|
43
|
-
api_key: Optional[str] = None,
|
|
44
|
-
azure_ad_token: Optional[str] = None,
|
|
45
|
-
azure_ad_token_provider: Optional[AsyncAzureADTokenProvider] = None,
|
|
46
|
-
organization: Optional[str] = None,
|
|
47
|
-
project: Optional[str] = None,
|
|
48
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
49
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
50
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
51
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
52
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
53
|
-
_strict_response_validation: bool = False,
|
|
54
|
-
) -> None: ...
|
|
55
|
-
|
|
56
|
-
@overload
|
|
57
|
-
def __init__(
|
|
58
|
-
self,
|
|
59
|
-
*,
|
|
60
|
-
base_url: str,
|
|
61
|
-
maitai_api_key: Optional[str] = None,
|
|
62
|
-
api_version: Optional[str] = None,
|
|
63
|
-
api_key: Optional[str] = None,
|
|
64
|
-
azure_ad_token: Optional[str] = None,
|
|
65
|
-
azure_ad_token_provider: Optional[AsyncAzureADTokenProvider] = None,
|
|
66
|
-
organization: Optional[str] = None,
|
|
67
|
-
project: Optional[str] = None,
|
|
68
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
69
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
70
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
71
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
72
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
73
|
-
_strict_response_validation: bool = False,
|
|
74
|
-
) -> None: ...
|
|
75
|
-
|
|
76
|
-
def __init__(
|
|
77
|
-
self,
|
|
78
|
-
*,
|
|
79
|
-
maitai_api_key: Optional[str] = None,
|
|
80
|
-
azure_endpoint: Optional[str] = None,
|
|
81
|
-
azure_deployment: Optional[str] = None,
|
|
82
|
-
api_version: Optional[str] = None,
|
|
83
|
-
api_key: Optional[str] = None,
|
|
84
|
-
azure_ad_token: Optional[str] = None,
|
|
85
|
-
azure_ad_token_provider: Optional[AsyncAzureADTokenProvider] = None,
|
|
86
|
-
organization: Optional[str] = None,
|
|
87
|
-
project: Optional[str] = None,
|
|
88
|
-
base_url: Optional[str] = None,
|
|
89
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
90
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
91
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
92
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
93
|
-
http_client: Optional[httpx.AsyncClient] = None,
|
|
94
|
-
_strict_response_validation: bool = False,
|
|
95
|
-
):
|
|
96
|
-
if maitai_api_key:
|
|
97
|
-
config.initialize(maitai_api_key)
|
|
98
|
-
self.client = openai.AsyncAzureOpenAI(
|
|
99
|
-
azure_endpoint=azure_endpoint,
|
|
100
|
-
azure_deployment=azure_deployment,
|
|
101
|
-
api_version=api_version,
|
|
102
|
-
api_key=api_key,
|
|
103
|
-
azure_ad_token=azure_ad_token,
|
|
104
|
-
azure_ad_token_provider=azure_ad_token_provider,
|
|
105
|
-
organization=organization,
|
|
106
|
-
project=project,
|
|
107
|
-
base_url=base_url,
|
|
108
|
-
timeout=timeout,
|
|
109
|
-
max_retries=max_retries,
|
|
110
|
-
default_headers=default_headers,
|
|
111
|
-
default_query=default_query,
|
|
112
|
-
http_client=http_client,
|
|
113
|
-
_strict_response_validation=_strict_response_validation,
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
self.chat = AsyncChat(self.client)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
class MaitaiAzureOpenAIClient:
|
|
120
|
-
@overload
|
|
121
|
-
def __init__(
|
|
122
|
-
self,
|
|
123
|
-
*,
|
|
124
|
-
maitai_api_key: Optional[str] = None,
|
|
125
|
-
azure_endpoint: str,
|
|
126
|
-
azure_deployment: Optional[str] = None,
|
|
127
|
-
api_version: Optional[str] = None,
|
|
128
|
-
api_key: Optional[str] = None,
|
|
129
|
-
azure_ad_token: Optional[str] = None,
|
|
130
|
-
azure_ad_token_provider: Optional[AzureADTokenProvider] = None,
|
|
131
|
-
organization: Optional[str] = None,
|
|
132
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
133
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
134
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
135
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
136
|
-
http_client: Optional[httpx.Client] = None,
|
|
137
|
-
_strict_response_validation: bool = False,
|
|
138
|
-
) -> None: ...
|
|
139
|
-
|
|
140
|
-
@overload
|
|
141
|
-
def __init__(
|
|
142
|
-
self,
|
|
143
|
-
*,
|
|
144
|
-
maitai_api_key: Optional[str] = None,
|
|
145
|
-
azure_deployment: Optional[str] = None,
|
|
146
|
-
api_version: Optional[str] = None,
|
|
147
|
-
api_key: Optional[str] = None,
|
|
148
|
-
azure_ad_token: Optional[str] = None,
|
|
149
|
-
azure_ad_token_provider: Optional[AzureADTokenProvider] = None,
|
|
150
|
-
organization: Optional[str] = None,
|
|
151
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
152
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
153
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
154
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
155
|
-
http_client: Optional[httpx.Client] = None,
|
|
156
|
-
_strict_response_validation: bool = False,
|
|
157
|
-
) -> None: ...
|
|
158
|
-
|
|
159
|
-
@overload
|
|
160
|
-
def __init__(
|
|
161
|
-
self,
|
|
162
|
-
*,
|
|
163
|
-
base_url: str,
|
|
164
|
-
maitai_api_key: Optional[str] = None,
|
|
165
|
-
api_version: Optional[str] = None,
|
|
166
|
-
api_key: Optional[str] = None,
|
|
167
|
-
azure_ad_token: Optional[str] = None,
|
|
168
|
-
azure_ad_token_provider: Optional[AzureADTokenProvider] = None,
|
|
169
|
-
organization: Optional[str] = None,
|
|
170
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
171
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
172
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
173
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
174
|
-
http_client: Optional[httpx.Client] = None,
|
|
175
|
-
_strict_response_validation: bool = False,
|
|
176
|
-
) -> None: ...
|
|
177
|
-
|
|
178
|
-
def __init__(
|
|
179
|
-
self,
|
|
180
|
-
*,
|
|
181
|
-
maitai_api_key: Optional[str] = None,
|
|
182
|
-
api_version: Optional[str] = None,
|
|
183
|
-
azure_endpoint: Optional[str] = None,
|
|
184
|
-
azure_deployment: Optional[str] = None,
|
|
185
|
-
api_key: Optional[str] = None,
|
|
186
|
-
azure_ad_token: Optional[str] = None,
|
|
187
|
-
azure_ad_token_provider: Optional[AzureADTokenProvider] = None,
|
|
188
|
-
organization: Optional[str] = None,
|
|
189
|
-
project: Optional[str] = None,
|
|
190
|
-
base_url: Optional[str] = None,
|
|
191
|
-
timeout: Union[float, httpx.Timeout, None, openai.NotGiven] = openai.NotGiven,
|
|
192
|
-
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
193
|
-
default_headers: Optional[Mapping[str, str]] = None,
|
|
194
|
-
default_query: Optional[Mapping[str, object]] = None,
|
|
195
|
-
http_client: Optional[httpx.Client] = None,
|
|
196
|
-
_strict_response_validation: bool = False,
|
|
197
|
-
) -> None:
|
|
198
|
-
if maitai_api_key:
|
|
199
|
-
config.initialize(maitai_api_key)
|
|
200
|
-
self.client = openai.AzureOpenAI(
|
|
201
|
-
azure_endpoint=azure_endpoint,
|
|
202
|
-
azure_deployment=azure_deployment,
|
|
203
|
-
api_version=api_version,
|
|
204
|
-
api_key=api_key,
|
|
205
|
-
azure_ad_token=azure_ad_token,
|
|
206
|
-
azure_ad_token_provider=azure_ad_token_provider,
|
|
207
|
-
organization=organization,
|
|
208
|
-
project=project,
|
|
209
|
-
base_url=base_url,
|
|
210
|
-
timeout=timeout,
|
|
211
|
-
max_retries=max_retries,
|
|
212
|
-
default_headers=default_headers,
|
|
213
|
-
default_query=default_query,
|
|
214
|
-
http_client=http_client,
|
|
215
|
-
_strict_response_validation=_strict_response_validation,
|
|
216
|
-
)
|
|
217
|
-
self.chat = Chat(self.client)
|
|
File without changes
|
|
File without changes
|