nebu 0.1.36__py3-none-any.whl → 0.1.37__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.
- nebu/chatx/convert.py +61 -0
- {nebu-0.1.36.dist-info → nebu-0.1.37.dist-info}/METADATA +1 -1
- {nebu-0.1.36.dist-info → nebu-0.1.37.dist-info}/RECORD +6 -6
- {nebu-0.1.36.dist-info → nebu-0.1.37.dist-info}/WHEEL +0 -0
- {nebu-0.1.36.dist-info → nebu-0.1.37.dist-info}/licenses/LICENSE +0 -0
- {nebu-0.1.36.dist-info → nebu-0.1.37.dist-info}/top_level.txt +0 -0
nebu/chatx/convert.py
CHANGED
@@ -299,3 +299,64 @@ def oai_to_unsloth(
|
|
299
299
|
# else: Handle missing role or empty content if needed
|
300
300
|
|
301
301
|
return {"messages": nebu_conversation}
|
302
|
+
|
303
|
+
|
304
|
+
def oai_to_qwen(
|
305
|
+
messages_input: List[Dict[str, Any]],
|
306
|
+
) -> List[Dict[str, Any]]:
|
307
|
+
"""
|
308
|
+
Convert from an OpenAI message format to a format where image URLs
|
309
|
+
are kept as strings.
|
310
|
+
|
311
|
+
Input format example:
|
312
|
+
[
|
313
|
+
{
|
314
|
+
"role": "user",
|
315
|
+
"content": [
|
316
|
+
{"type": "text", "text": "some text"},
|
317
|
+
{"type": "image_url", "image_url": {"url": "https://..."}},
|
318
|
+
],
|
319
|
+
}
|
320
|
+
]
|
321
|
+
|
322
|
+
Output format example:
|
323
|
+
[
|
324
|
+
{
|
325
|
+
"role": "user",
|
326
|
+
"content": [
|
327
|
+
{"type": "text", "text": "some text"},
|
328
|
+
{"type": "image", "image": "https://..."},
|
329
|
+
],
|
330
|
+
}
|
331
|
+
]
|
332
|
+
"""
|
333
|
+
new_schema = []
|
334
|
+
for message in messages_input:
|
335
|
+
role = message.get("role")
|
336
|
+
input_content = message.get("content")
|
337
|
+
|
338
|
+
if not isinstance(role, str) or not isinstance(input_content, list):
|
339
|
+
# Skip malformed messages
|
340
|
+
print(f"Warning: Skipping malformed message: {message!r}")
|
341
|
+
continue
|
342
|
+
|
343
|
+
processed_content = []
|
344
|
+
for item in input_content:
|
345
|
+
item_type = item.get("type")
|
346
|
+
if item_type == "text":
|
347
|
+
text = item.get("text", "")
|
348
|
+
processed_content.append({"type": "text", "text": text})
|
349
|
+
elif item_type == "image_url":
|
350
|
+
image_url_dict = item.get("image_url", {})
|
351
|
+
url = image_url_dict.get("url")
|
352
|
+
if url:
|
353
|
+
processed_content.append({"type": "image", "image": url})
|
354
|
+
else:
|
355
|
+
print(f"Warning: image_url item missing 'url': {item!r}")
|
356
|
+
# else: Handle or ignore other types if necessary
|
357
|
+
|
358
|
+
if role and processed_content:
|
359
|
+
new_schema.append({"role": role, "content": processed_content})
|
360
|
+
# else: Handle cases with missing role or empty resulting content if needed
|
361
|
+
|
362
|
+
return new_schema
|
@@ -5,7 +5,7 @@ nebu/cache.py,sha256=1aY1plIXWOPmUY6GGq_s_QDXzIi5UMuG34XYBA8PpW8,3803
|
|
5
5
|
nebu/config.py,sha256=aZzQltkobtOLHFCGcIkpKoE3ITn3Z11Dp0E72w84TA0,5769
|
6
6
|
nebu/data.py,sha256=kIH9-JJ1-iO7P2t28bku6Gn0Y5tgQszGeTW_rpmO03A,38725
|
7
7
|
nebu/meta.py,sha256=CzFHMND9seuewzq9zNNx9WTr6JvrCBExe7BLqDSr7lM,745
|
8
|
-
nebu/chatx/convert.py,sha256=
|
8
|
+
nebu/chatx/convert.py,sha256=1x6Dz_-posZoxo-xC4QDqeKjrd5RgOkobBZT9K3Ze74,14478
|
9
9
|
nebu/chatx/openai.py,sha256=VsJvV2MbYeJj2Ita9Q9X3qj5r5F3P-aPDhpSFr-Q-dw,44950
|
10
10
|
nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,13502
|
11
11
|
nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
|
@@ -19,8 +19,8 @@ nebu/processors/processor.py,sha256=068hLQKapWabNlhb_DtzqAJ7N7MGdr5UcjfZrb_MkFo,
|
|
19
19
|
nebu/processors/remote.py,sha256=TeAIPGEMqnDIb7H1iett26IEZrBlcbPB_-DSm6jcH1E,1285
|
20
20
|
nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
|
21
21
|
nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
-
nebu-0.1.
|
23
|
-
nebu-0.1.
|
24
|
-
nebu-0.1.
|
25
|
-
nebu-0.1.
|
26
|
-
nebu-0.1.
|
22
|
+
nebu-0.1.37.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
23
|
+
nebu-0.1.37.dist-info/METADATA,sha256=gcjQbyKOX5ZvQuZ1QnJEtSEugrQIXiUuDjH4e4PJKPI,1786
|
24
|
+
nebu-0.1.37.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
25
|
+
nebu-0.1.37.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
|
26
|
+
nebu-0.1.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|