ommlds 0.0.0.dev447__py3-none-any.whl → 0.0.0.dev448__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.
Potentially problematic release.
This version of ommlds might be problematic. Click here for more details.
- ommlds/.omlish-manifests.json +1 -1
- ommlds/minichain/backends/impls/google/stream.py +11 -2
- ommlds/minichain/stream/services.py +18 -13
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/METADATA +3 -3
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/RECORD +9 -9
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev447.dist-info → ommlds-0.0.0.dev448.dist-info}/top_level.txt +0 -0
ommlds/.omlish-manifests.json
CHANGED
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"module": ".minichain.backends.impls.google.stream",
|
|
139
139
|
"attr": null,
|
|
140
140
|
"file": "ommlds/minichain/backends/impls/google/stream.py",
|
|
141
|
-
"line":
|
|
141
|
+
"line": 36,
|
|
142
142
|
"value": {
|
|
143
143
|
"!.minichain.registries.manifests.RegistryManifest": {
|
|
144
144
|
"module": "ommlds.minichain.backends.impls.google.stream",
|
|
@@ -19,7 +19,9 @@ from ....chat.messages import UserMessage
|
|
|
19
19
|
from ....chat.stream.services import ChatChoicesStreamRequest
|
|
20
20
|
from ....chat.stream.services import ChatChoicesStreamResponse
|
|
21
21
|
from ....chat.stream.services import static_check_is_chat_choices_stream_service
|
|
22
|
+
from ....chat.stream.types import AiChoiceDelta
|
|
22
23
|
from ....chat.stream.types import AiChoiceDeltas
|
|
24
|
+
from ....chat.stream.types import AiMessageDelta
|
|
23
25
|
from ....models.configs import ModelName
|
|
24
26
|
from ....resources import UseResources
|
|
25
27
|
from ....standard import ApiKey
|
|
@@ -64,6 +66,8 @@ class GoogleChatChoicesStreamService:
|
|
|
64
66
|
AiMessage: 'assistant',
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
READ_CHUNK_SIZE = 64 * 1024
|
|
70
|
+
|
|
67
71
|
async def invoke(
|
|
68
72
|
self,
|
|
69
73
|
request: ChatChoicesStreamRequest,
|
|
@@ -87,7 +91,7 @@ class GoogleChatChoicesStreamService:
|
|
|
87
91
|
model_name = MODEL_NAMES.resolve(self._model_name.v)
|
|
88
92
|
|
|
89
93
|
http_request = http.HttpRequest(
|
|
90
|
-
f'{self.BASE_URL.rstrip("/")}/{model_name}:
|
|
94
|
+
f'{self.BASE_URL.rstrip("/")}/{model_name}:streamGenerateContent?alt=sse&key={key}',
|
|
91
95
|
headers={'Content-Type': 'application/json'},
|
|
92
96
|
data=json.dumps_compact(req_dct).encode('utf-8'),
|
|
93
97
|
method='POST',
|
|
@@ -111,6 +115,11 @@ class GoogleChatChoicesStreamService:
|
|
|
111
115
|
continue
|
|
112
116
|
if l.startswith('data: '):
|
|
113
117
|
gcr = msh.unmarshal(json.loads(l[6:]), pt.GenerateContentResponse) # noqa
|
|
114
|
-
|
|
118
|
+
cnd = check.single(check.not_none(gcr.candidates))
|
|
119
|
+
for p in check.not_none(cnd.content).parts or []:
|
|
120
|
+
await sink.emit([AiChoiceDelta(AiMessageDelta(check.not_none(p.text)))])
|
|
121
|
+
|
|
122
|
+
if not b:
|
|
123
|
+
return []
|
|
115
124
|
|
|
116
125
|
return await new_stream_response(rs, inner)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import abc
|
|
2
2
|
import itertools
|
|
3
|
+
import types
|
|
3
4
|
import typing as ta
|
|
4
5
|
|
|
5
6
|
from omlish import check
|
|
@@ -40,15 +41,11 @@ class StreamResponseSink(lang.Abstract, ta.Generic[V]):
|
|
|
40
41
|
raise NotImplementedError
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
class StreamResponseIterator(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@abc.abstractmethod
|
|
49
|
-
def __aexit__(self, exc_type, exc_val, exc_tb) -> ta.Awaitable[None]:
|
|
50
|
-
raise NotImplementedError
|
|
51
|
-
|
|
44
|
+
class StreamResponseIterator(
|
|
45
|
+
ta.AsyncContextManager['StreamResponseIterator[V, OutputT]'],
|
|
46
|
+
lang.Abstract,
|
|
47
|
+
ta.Generic[V, OutputT],
|
|
48
|
+
):
|
|
52
49
|
@property
|
|
53
50
|
@abc.abstractmethod
|
|
54
51
|
def outputs(self) -> tv.TypedValues[OutputT]:
|
|
@@ -120,7 +117,8 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
120
117
|
self._g = iter(self._a)
|
|
121
118
|
return self
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
@types.coroutine
|
|
121
|
+
def _aexit(self, exc_type, exc_val, exc_tb):
|
|
124
122
|
old_state = self._state
|
|
125
123
|
self._state = 'closed'
|
|
126
124
|
if old_state != 'running':
|
|
@@ -137,7 +135,7 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
137
135
|
if cex2 is cex:
|
|
138
136
|
break
|
|
139
137
|
raise
|
|
140
|
-
|
|
138
|
+
yield x
|
|
141
139
|
if self._cr.cr_running:
|
|
142
140
|
raise RuntimeError(f'Coroutine {self._cr!r} not terminated')
|
|
143
141
|
if self._g is not self._a:
|
|
@@ -145,13 +143,17 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
145
143
|
self._a.close()
|
|
146
144
|
self._cr.close()
|
|
147
145
|
|
|
146
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
147
|
+
return await self._aexit(exc_type, exc_val, exc_tb)
|
|
148
|
+
|
|
148
149
|
_outputs: tv.TypedValues[OutputT]
|
|
149
150
|
|
|
150
151
|
@property
|
|
151
152
|
def outputs(self) -> tv.TypedValues[OutputT]:
|
|
152
153
|
return self._outputs
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
@types.coroutine
|
|
156
|
+
def _anext(self):
|
|
155
157
|
check.state(self._state == 'running')
|
|
156
158
|
while True:
|
|
157
159
|
try:
|
|
@@ -168,7 +170,10 @@ class _StreamServiceResponse(StreamResponseIterator[V, OutputT]):
|
|
|
168
170
|
x.done = True
|
|
169
171
|
return x.value
|
|
170
172
|
|
|
171
|
-
|
|
173
|
+
yield x
|
|
174
|
+
|
|
175
|
+
async def __anext__(self) -> V:
|
|
176
|
+
return await self._anext()
|
|
172
177
|
|
|
173
178
|
|
|
174
179
|
##
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommlds
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev448
|
|
4
4
|
Summary: ommlds
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omdev==0.0.0.
|
|
18
|
-
Requires-Dist: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omdev==0.0.0.dev448
|
|
18
|
+
Requires-Dist: omlish==0.0.0.dev448
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Requires-Dist: llama-cpp-python~=0.3; extra == "all"
|
|
21
21
|
Requires-Dist: mlx~=0.29; extra == "all"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ommlds/.omlish-manifests.json,sha256=
|
|
1
|
+
ommlds/.omlish-manifests.json,sha256=s92cmVTNvGiopN6a0kMNziKvMkcePcRspm8dsIL6_SM,17984
|
|
2
2
|
ommlds/__about__.py,sha256=Z9VIVQnuNBbIYEtIm9XZU4T2QGRqMNjtmQX2OOTaUc0,1759
|
|
3
3
|
ommlds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
ommlds/huggingface.py,sha256=JfEyfKOxU3-SY_ojtXBJFNeD-NIuKjvMe3GL3e93wNA,1175
|
|
@@ -133,7 +133,7 @@ ommlds/minichain/backends/impls/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
|
|
|
133
133
|
ommlds/minichain/backends/impls/google/chat.py,sha256=Dq_PrkRt07dN5A3UPj0qwB3IMIS9caAQff6076q6kUQ,3192
|
|
134
134
|
ommlds/minichain/backends/impls/google/names.py,sha256=HxHJ31HeKZg6aW1C_Anqp-gamCXpq9pOdKj8_yVgE8Y,871
|
|
135
135
|
ommlds/minichain/backends/impls/google/search.py,sha256=5-2nAZ1QmbqHSQcwWnqqcgCM-Duy2ryctJEIv2tcpZg,3260
|
|
136
|
-
ommlds/minichain/backends/impls/google/stream.py,sha256=
|
|
136
|
+
ommlds/minichain/backends/impls/google/stream.py,sha256=8DbgK61HRovW1dq_VBXYDnjU7oVFsE2DmCfLLHoznNI,4736
|
|
137
137
|
ommlds/minichain/backends/impls/huggingface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
138
138
|
ommlds/minichain/backends/impls/huggingface/configs.py,sha256=6jsBtPNXOP57PcpxNTVLGWLc-18Iwn_lDbGouwCJTIQ,258
|
|
139
139
|
ommlds/minichain/backends/impls/huggingface/repos.py,sha256=8BDxJmra9elSQL2vzp2nr2p4Hpq56A3zTk7hTTnfJU4,861
|
|
@@ -242,7 +242,7 @@ ommlds/minichain/services/requests.py,sha256=VAfKbYu4T0CZTWVQmZ2LUmYU7DNm6IerYMN
|
|
|
242
242
|
ommlds/minichain/services/responses.py,sha256=4W6Z4Fx4_GFqKgle27OeLr0zzjVTA0pkZrlsZiFQNdo,1534
|
|
243
243
|
ommlds/minichain/services/services.py,sha256=WjkQNYIp87SflLSReOHMkG2qIVAOem6vsrs_2NxWN_M,325
|
|
244
244
|
ommlds/minichain/stream/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
245
|
-
ommlds/minichain/stream/services.py,sha256=
|
|
245
|
+
ommlds/minichain/stream/services.py,sha256=fFR1klP_PZJ3Pqmqx_SGap8gRDuthJah1fyoke6G9Ww,5328
|
|
246
246
|
ommlds/minichain/stream/wrap.py,sha256=nQC0aCi49I18nF0Yx8qiiLkhIAECV6s6o4pvOy5Kx98,2041
|
|
247
247
|
ommlds/minichain/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
248
248
|
ommlds/minichain/text/applypatch.py,sha256=YIN5JChJ0FXyK1I6OiAHQmE7BT-exHfaAMM9ay7ylyc,17705
|
|
@@ -300,9 +300,9 @@ ommlds/wiki/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
300
300
|
ommlds/wiki/utils/io.py,sha256=UKgDJGtmpnWvIqVd2mJc2QNPOqlToEY1GEveNp6_pMo,7088
|
|
301
301
|
ommlds/wiki/utils/progress.py,sha256=EhvKcMFYtsarCQhIahlO6f0SboyAKP3UwUyrnVnP-Vk,3222
|
|
302
302
|
ommlds/wiki/utils/xml.py,sha256=vVV8Ctn13aaRM9eYfs9Wd6rHn5WOCEUzQ44fIhOvJdg,3754
|
|
303
|
-
ommlds-0.0.0.
|
|
304
|
-
ommlds-0.0.0.
|
|
305
|
-
ommlds-0.0.0.
|
|
306
|
-
ommlds-0.0.0.
|
|
307
|
-
ommlds-0.0.0.
|
|
308
|
-
ommlds-0.0.0.
|
|
303
|
+
ommlds-0.0.0.dev448.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
304
|
+
ommlds-0.0.0.dev448.dist-info/METADATA,sha256=olU6t7Q0JXStieKFJ3XjgEQTA3bIlhtdzysQ_UW0ak0,3224
|
|
305
|
+
ommlds-0.0.0.dev448.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
306
|
+
ommlds-0.0.0.dev448.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
|
|
307
|
+
ommlds-0.0.0.dev448.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
|
|
308
|
+
ommlds-0.0.0.dev448.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|