You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The serialize_callable function in callable_serialization.py throws an AttributeError when the callable_handle argument is None.
Error message
AttributeError: 'NoneType' object has no attribute 'name'
File "~\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "~\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "~test.py", line 21, in <module>
main()
File "~/test.py", line 14, in main
yyy = p.dumps()
^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\site-packages\haystack\core\pipeline\pipeline.py", line 196, in dumps
return marshaller.marshal(self.to_dict())
^^^^^^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\site-packages\haystack\core\pipeline\pipeline.py", line 118, in to_dict
components[name] = component_to_dict(instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\site-packages\haystack\core\serialization.py", line 24, in component_to_dict
return obj.to_dict()
^^^^^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\site-packages\haystack_integrations\components\generators\amazon_bedrock\chat\chat_generator.py", line 223, in to_dict
streaming_callback=serialize_callable(self.streaming_callback),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\AppData\Local\Programs\Python\Python311\Lib\site-packages\haystack\utils\callable_serialization.py", line 20, in serialize_callable
full_path = callable_handle.__name__
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '__name__'. Did you mean: '__ne__'?
Expected behavior
The function should handle the case where callable_handle is None and raise a more descriptive error message. For example, it could raise a ValueError with the message "callable_handle must be a callable, not None".
Additional context
This issue occurs when trying to serialize a None value as a callable, which is not a valid operation.
to reproduce the behavior:
fromhaystack_integrations.components.generators.amazon_bedrockimport (
AmazonBedrockChatGenerator,
)
fromhaystackimportPipelinedefmain():
p=Pipeline()
p.add_component(
"generator",
# can be any chat supported modelAmazonBedrockChatGenerator(model="anthropic.claude-3-sonnet-20240229-v1:0"),
)
print(p.dumps())
if__name__=="__main__":
main()
FAQ Check
Have you had a look at our new FAQ page?
Yes
System:
OS: Windows
GPU/CPU: I7
Haystack version (commit or version number): Version: 2.0.1
amazon-bedrock-haystack version : 0.7.0
This might be affecting all the generator that uses the streaming_callable (cohere chat generator, ...)
The text was updated successfully, but these errors were encountered:
Describe the bug
The serialize_callable function in callable_serialization.py throws an AttributeError when the callable_handle argument is None.
Additional context
This issue occurs when trying to serialize a None value as a callable, which is not a valid operation.
to reproduce the behavior:
FAQ Check
Have you had a look at our new FAQ page?
Yes
System:
OS: Windows
GPU/CPU: I7
Haystack version (commit or version number): Version: 2.0.1
amazon-bedrock-haystack version : 0.7.0
This might be affecting all the generator that uses the streaming_callable (cohere chat generator, ...)
The text was updated successfully, but these errors were encountered: