We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I got this error when I created a user defined function: TypeError: unhashable type: 'ImportFromModule'
TypeError: unhashable type: 'ImportFromModule'
My function is like this:
@with_requirements(python_packages=["requests", "urllib3"], global_imports=["requests", "os", ImportFromModule("urllib.parse", ["urlencode"])]) def search_from_web(search_keyword: str): pass
The exception is caused by this function under func_with_reqs.py:
func_with_reqs.py
def _build_python_functions_file( funcs: List[Union[FunctionWithRequirements[Any, P], Callable[..., Any], FunctionWithRequirementsStr]] ) -> str: # First collect all global imports global_imports = set() for func in funcs: if isinstance(func, (FunctionWithRequirements, FunctionWithRequirementsStr)): global_imports.update(func.global_imports) content = "\n".join(map(_import_to_str, global_imports)) + "\n\n" for func in funcs: content += _to_code(func) + "\n\n" return content
The ImportFromModule is unhashable at global_imports.update(func.global_imports)
ImportFromModule
global_imports.update(func.global_imports)
gpt-4o-mini
No response
Traceback (most recent call last): File "C:\Users\zhaoc\PycharmProjects\financal-analyst\3.function_use.py", line 15, in code_executor.initiate_chat( File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1019, in initiate_chat self.send(msg2send, recipient, silent=silent) File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 656, in send recipient.receive(message, self, request_reply, silent) File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 821, in receive self.send(reply, sender, silent=silent) File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 656, in send recipient.receive(message, self, request_reply, silent) File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 819, in receive reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1973, in generate_reply final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\agentchat\conversable_agent.py", line 1471, in _generate_code_execution_reply_using_executor code_result = self._code_executor.execute_code_blocks(code_blocks) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\coding\local_commandline_code_executor.py", line 245, in execute_code_blocks self._setup_functions() File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\coding\local_commandline_code_executor.py", line 207, in _setup_functions func_file_content = _build_python_functions_file(self._functions) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\zhaoc\miniconda3\envs\financial-analyst\Lib\site-packages\autogen\coding\func_with_reqs.py", line 165, in _build_python_functions_file global_imports.update(func.global_imports) TypeError: unhashable type: 'ImportFromModule'
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
I got this error when I created a user defined function:
TypeError: unhashable type: 'ImportFromModule'
Steps to reproduce
My function is like this:
The exception is caused by this function under
func_with_reqs.py
:The
ImportFromModule
is unhashable atglobal_imports.update(func.global_imports)
Model Used
gpt-4o-mini
Expected Behavior
No response
Screenshots and logs
The text was updated successfully, but these errors were encountered: