nebu 0.1.23__py3-none-any.whl → 0.1.24__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/__init__.py +0 -1
- nebu/processors/consumer.py +6 -6
- nebu/processors/decorate.py +16 -22
- nebu/processors/models.py +12 -0
- {nebu-0.1.23.dist-info → nebu-0.1.24.dist-info}/METADATA +1 -1
- {nebu-0.1.23.dist-info → nebu-0.1.24.dist-info}/RECORD +9 -9
- {nebu-0.1.23.dist-info → nebu-0.1.24.dist-info}/WHEEL +0 -0
- {nebu-0.1.23.dist-info → nebu-0.1.24.dist-info}/licenses/LICENSE +0 -0
- {nebu-0.1.23.dist-info → nebu-0.1.24.dist-info}/top_level.txt +0 -0
nebu/__init__.py
CHANGED
nebu/processors/consumer.py
CHANGED
@@ -138,9 +138,9 @@ try:
|
|
138
138
|
if stream_message_source:
|
139
139
|
try:
|
140
140
|
exec(stream_message_source, local_namespace)
|
141
|
-
print("Successfully defined
|
141
|
+
print("Successfully defined Message class")
|
142
142
|
except Exception as e:
|
143
|
-
print(f"Error defining
|
143
|
+
print(f"Error defining Message: {e}")
|
144
144
|
traceback.print_exc()
|
145
145
|
|
146
146
|
# Define content type if available
|
@@ -340,14 +340,14 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
|
|
340
340
|
print(f"Content: {content}")
|
341
341
|
|
342
342
|
# For StreamMessage, construct the proper input object
|
343
|
-
if is_stream_message and "
|
343
|
+
if is_stream_message and "Message" in local_namespace:
|
344
344
|
# If we have a content type, try to construct it
|
345
345
|
if content_type_name and content_type_name in local_namespace:
|
346
346
|
# Try to create the content type model first
|
347
347
|
try:
|
348
348
|
content_model = local_namespace[content_type_name](**content)
|
349
349
|
print(f"Content model: {content_model}")
|
350
|
-
input_obj = local_namespace["
|
350
|
+
input_obj = local_namespace["Message"](
|
351
351
|
kind=kind,
|
352
352
|
id=msg_id,
|
353
353
|
content=content_model,
|
@@ -361,7 +361,7 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
|
|
361
361
|
except Exception as e:
|
362
362
|
print(f"Error creating content type model: {e}")
|
363
363
|
# Fallback to using raw content
|
364
|
-
input_obj = local_namespace["
|
364
|
+
input_obj = local_namespace["Message"](
|
365
365
|
kind=kind,
|
366
366
|
id=msg_id,
|
367
367
|
content=content,
|
@@ -375,7 +375,7 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
|
|
375
375
|
else:
|
376
376
|
# Just use the raw content
|
377
377
|
print(f"Using raw content")
|
378
|
-
input_obj = local_namespace["
|
378
|
+
input_obj = local_namespace["Message"](
|
379
379
|
kind=kind,
|
380
380
|
id=msg_id,
|
381
381
|
content=content,
|
nebu/processors/decorate.py
CHANGED
@@ -27,8 +27,8 @@ from nebu.containers.models import (
|
|
27
27
|
)
|
28
28
|
from nebu.meta import V1ResourceMetaRequest
|
29
29
|
from nebu.processors.models import (
|
30
|
+
Message,
|
30
31
|
V1Scale,
|
31
|
-
V1StreamMessage,
|
32
32
|
)
|
33
33
|
from nebu.processors.processor import Processor
|
34
34
|
|
@@ -455,14 +455,12 @@ def processor(
|
|
455
455
|
content_type = None
|
456
456
|
|
457
457
|
# Check 1: Standard introspection
|
458
|
-
if origin is
|
458
|
+
if origin is Message or (
|
459
459
|
origin is not None
|
460
|
-
and origin.__name__ ==
|
461
|
-
and origin.__module__ ==
|
460
|
+
and origin.__name__ == Message.__name__
|
461
|
+
and origin.__module__ == Message.__module__
|
462
462
|
):
|
463
|
-
print(
|
464
|
-
"[DEBUG Decorator] Input type identified as V1StreamMessage via get_origin."
|
465
|
-
)
|
463
|
+
print("[DEBUG Decorator] Input type identified as Message via get_origin.")
|
466
464
|
is_stream_message = True
|
467
465
|
if args:
|
468
466
|
content_type = args[0]
|
@@ -471,13 +469,11 @@ def processor(
|
|
471
469
|
)
|
472
470
|
else:
|
473
471
|
print(
|
474
|
-
"[DEBUG Decorator]
|
472
|
+
"[DEBUG Decorator] Message detected, but no generic arguments found via get_args."
|
475
473
|
)
|
476
474
|
# Check 2: Direct type check
|
477
|
-
elif isinstance(param_type, type) and param_type is
|
478
|
-
print(
|
479
|
-
"[DEBUG Decorator] Input type identified as direct V1StreamMessage type."
|
480
|
-
)
|
475
|
+
elif isinstance(param_type, type) and param_type is Message:
|
476
|
+
print("[DEBUG Decorator] Input type identified as direct Message type.")
|
481
477
|
is_stream_message = True
|
482
478
|
# Check 3: Regex fallback on string representation
|
483
479
|
elif origin is None:
|
@@ -486,13 +482,11 @@ def processor(
|
|
486
482
|
)
|
487
483
|
# Use param_type_str_repr in match calls
|
488
484
|
generic_match = re.match(
|
489
|
-
r"^<class '(?:[a-zA-Z0-9_.]+\.)?
|
485
|
+
r"^<class '(?:[a-zA-Z0-9_.]+\.)?Message\[(.+?)\]'>$",
|
490
486
|
param_type_str_repr,
|
491
487
|
)
|
492
488
|
if generic_match:
|
493
|
-
print(
|
494
|
-
"[DEBUG Decorator] Regex matched generic V1StreamMessage pattern!"
|
495
|
-
)
|
489
|
+
print("[DEBUG Decorator] Regex matched generic Message pattern!")
|
496
490
|
is_stream_message = True
|
497
491
|
content_type_name_str = generic_match.group(1).strip()
|
498
492
|
print(
|
@@ -517,21 +511,21 @@ def processor(
|
|
517
511
|
else:
|
518
512
|
# Use param_type_str_repr in match calls
|
519
513
|
simple_match = re.match(
|
520
|
-
r"^<class '(?:[a-zA-Z0-9_.]+\.)?
|
514
|
+
r"^<class '(?:[a-zA-Z0-9_.]+\.)?Message'>$",
|
521
515
|
param_type_str_repr,
|
522
516
|
)
|
523
517
|
if simple_match:
|
524
518
|
print(
|
525
|
-
"[DEBUG Decorator] Regex identified direct
|
519
|
+
"[DEBUG Decorator] Regex identified direct Message (no generic) from string."
|
526
520
|
)
|
527
521
|
is_stream_message = True
|
528
522
|
else:
|
529
523
|
print(
|
530
|
-
f"[DEBUG Decorator] Regex did not match
|
524
|
+
f"[DEBUG Decorator] Regex did not match Message pattern for string '{param_type_str_repr}'. Assuming not StreamMessage."
|
531
525
|
)
|
532
526
|
else:
|
533
527
|
print(
|
534
|
-
f"[DEBUG Decorator] Input parameter '{param_name}' type ({param_type_str_repr}) identified as non-StreamMessage type (origin was not None and not
|
528
|
+
f"[DEBUG Decorator] Input parameter '{param_name}' type ({param_type_str_repr}) identified as non-StreamMessage type (origin was not None and not Message)."
|
535
529
|
)
|
536
530
|
|
537
531
|
print(
|
@@ -645,8 +639,8 @@ def processor(
|
|
645
639
|
input_model_source = None
|
646
640
|
output_model_source = None
|
647
641
|
content_type_source = None
|
648
|
-
print("[DEBUG Decorator] Getting base
|
649
|
-
stream_message_source = get_type_source(
|
642
|
+
print("[DEBUG Decorator] Getting base Message source...")
|
643
|
+
stream_message_source = get_type_source(Message, notebook_code)
|
650
644
|
|
651
645
|
if is_stream_message:
|
652
646
|
print(
|
nebu/processors/models.py
CHANGED
@@ -94,6 +94,18 @@ class V1StreamData(BaseModel):
|
|
94
94
|
wait: Optional[bool] = None
|
95
95
|
|
96
96
|
|
97
|
+
class Message(BaseModel, Generic[T]):
|
98
|
+
kind: str = "Message"
|
99
|
+
id: str
|
100
|
+
content: Optional[T] = None
|
101
|
+
created_at: int
|
102
|
+
return_stream: Optional[str] = None
|
103
|
+
user_id: Optional[str] = None
|
104
|
+
orgs: Optional[Any] = None
|
105
|
+
handle: Optional[str] = None
|
106
|
+
adapter: Optional[str] = None
|
107
|
+
|
108
|
+
|
97
109
|
class V1StreamMessage(BaseModel, Generic[T]):
|
98
110
|
kind: str = "StreamMessage"
|
99
111
|
id: str
|
@@ -1,4 +1,4 @@
|
|
1
|
-
nebu/__init__.py,sha256=
|
1
|
+
nebu/__init__.py,sha256=Frz4LWVslmGeEE_ZjCIV5riSw8RC4ZJ-gb4iQPKCOSM,299
|
2
2
|
nebu/auth.py,sha256=rApCd-7_c3GpIb7gjCB79rR7SOcmkG7MmaTE6zMbvr0,1125
|
3
3
|
nebu/config.py,sha256=XBY7uKgcJX9d1HGxqqpx87o_9DuF3maUlUnKkcpUrKU,4565
|
4
4
|
nebu/meta.py,sha256=CzFHMND9seuewzq9zNNx9WTr6JvrCBExe7BLqDSr7lM,745
|
@@ -6,15 +6,15 @@ nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,
|
|
6
6
|
nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
|
7
7
|
nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,6815
|
8
8
|
nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
|
9
|
-
nebu/processors/consumer.py,sha256=
|
10
|
-
nebu/processors/decorate.py,sha256=
|
9
|
+
nebu/processors/consumer.py,sha256=ejGgYhOMn86aEvJxQorWp7ybHVcvmo4T3nyiv7gTnhM,19687
|
10
|
+
nebu/processors/decorate.py,sha256=B2qK1B2Jm1SzO5IN9pWk32sS0z5WLqXPdJtP-y-iSO4,34563
|
11
11
|
nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
|
12
|
-
nebu/processors/models.py,sha256=
|
12
|
+
nebu/processors/models.py,sha256=y40HoW-MEzDWB2dm_tsYlUy3Nf3s6eiLC0iGO9BoNog,3956
|
13
13
|
nebu/processors/processor.py,sha256=oy2YdI-cy6qQWxrZhpZahJV46oWZlu_Im-jm811R_oo,9667
|
14
14
|
nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
|
15
15
|
nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
nebu-0.1.
|
17
|
-
nebu-0.1.
|
18
|
-
nebu-0.1.
|
19
|
-
nebu-0.1.
|
20
|
-
nebu-0.1.
|
16
|
+
nebu-0.1.24.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
17
|
+
nebu-0.1.24.dist-info/METADATA,sha256=8O-NbvrAFRRuGr3QLz2DzM08CJnbpfXi3fAIABOSho4,1678
|
18
|
+
nebu-0.1.24.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
19
|
+
nebu-0.1.24.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
|
20
|
+
nebu-0.1.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|