Skip to content
New issue

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

Gettig Error while running "autogen.UserProxyAgent" #19

Closed
Akashdawari opened this issue Sep 26, 2023 · 2 comments · Fixed by #38
Closed

Gettig Error while running "autogen.UserProxyAgent" #19

Akashdawari opened this issue Sep 26, 2023 · 2 comments · Fixed by #38

Comments

@Akashdawari
Copy link

The first response is coming right but getting an error during the code execution part

ERROR::

EXECUTING CODE BLOCK 0 (inferred language is sh)...
WARNING:root: SIGALRM is not supported on Windows. No timeout will be enforced.


FileNotFoundError Traceback (most recent call last)
Cell In[14], line 22
11 user_proxy = autogen.UserProxyAgent(
12 name="user_proxy",
13 human_input_mode="NEVER",
(...)
19 },
20 )
21 # the assistant receives a message from the user_proxy, which contains the task description
---> 22 user_proxy.initiate_chat(
23 assistant,
24 message="""build a aws cloud arctechture""",
25 )

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:521, in ConversableAgent.initiate_chat(self, recipient, clear_history, silent, **context)
507 """Initiate a chat with the recipient agent.
508
509 Reset the consecutive auto reply counter.
(...)
518 "message" needs to be provided if the generate_init_message method is not overridden.
519 """
520 self._prepare_chat(recipient, clear_history)
--> 521 self.send(self.generate_init_message(**context), recipient, silent=silent)

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:324, in ConversableAgent.send(self, message, recipient, request_reply, silent)
322 valid = self._append_oai_message(message, "assistant", recipient)
323 if valid:
--> 324 recipient.receive(message, self, request_reply, silent)
325 else:
326 raise ValueError(
327 "Message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided."
328 )

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:454, in ConversableAgent.receive(self, message, sender, request_reply, silent)
452 reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
453 if reply is not None:
--> 454 self.send(reply, sender, silent=silent)

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:324, in ConversableAgent.send(self, message, recipient, request_reply, silent)
322 valid = self._append_oai_message(message, "assistant", recipient)
323 if valid:
--> 324 recipient.receive(message, self, request_reply, silent)
325 else:
326 raise ValueError(
327 "Message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided."
328 )

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:452, in ConversableAgent.receive(self, message, sender, request_reply, silent)
450 if request_reply is False or request_reply is None and self.reply_at_receive[sender] is False:
451 return
--> 452 reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
453 if reply is not None:
454 self.send(reply, sender, silent=silent)

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:764, in ConversableAgent.generate_reply(self, messages, sender, exclude)
762 continue
763 if self._match_trigger(reply_func_tuple["trigger"], sender):
--> 764 final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
765 if final:
766 return reply

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:628, in ConversableAgent.generate_code_execution_reply(self, messages, sender, config)
623 continue
624 # code_blocks, _ = find_code(messages, sys_msg=self._oai_system_message, **self.llm_config)
625 # if len(code_blocks) == 1 and code_blocks[0][0] == UNKNOWN:
626 # return code_blocks[0][1]
627 # try to execute the code
--> 628 exitcode, logs = self.execute_code_blocks(code_blocks)
629 exitcode2str = "execution succeeded" if exitcode == 0 else "execution failed"
630 break

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:881, in ConversableAgent.execute_code_blocks(self, code_blocks)
873 print(
874 colored(
875 f"\n>>>>>>>> EXECUTING CODE BLOCK {i} (inferred language is {lang})...",
(...)
878 flush=True,
879 )
880 if lang in ["bash", "shell", "sh"]:
--> 881 exitcode, logs, image = self.run_code(code, lang=lang, **self._code_execution_config)
882 elif lang in ["python", "Python"]:
883 if code.startswith("# filename: "):

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\agentchat\conversable_agent.py:864, in ConversableAgent.run_code(self, code, **kwargs)
850 def run_code(self, code, **kwargs):
851 """Run the code and return the result.
852
853 Override this function to modify the way to run the code.
(...)
862 image (str or None): the docker image used for the code execution.
863 """
--> 864 return execute_code(code, **kwargs)

File ~\AppData\Roaming\Python\Python310\site-packages\autogen\code_utils.py:245, in execute_code(code, timeout, filename, work_dir, use_docker, lang)
243 if sys.platform == "win32":
244 logging.warning("SIGALRM is not supported on Windows. No timeout will be enforced.")
--> 245 result = subprocess.run(
246 cmd,
247 cwd=work_dir,
248 capture_output=True,
249 )
250 else:
251 signal.signal(signal.SIGALRM, timeout_handler)

File C:\ProgramData\anaconda3\lib\subprocess.py:503, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
500 kwargs['stdout'] = PIPE
501 kwargs['stderr'] = PIPE
--> 503 with Popen(*popenargs, **kwargs) as process:
504 try:
505 stdout, stderr = process.communicate(input, timeout=timeout)

File C:\ProgramData\anaconda3\lib\subprocess.py:971, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
967 if self.text_mode:
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
--> 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
982 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File C:\ProgramData\anaconda3\lib\subprocess.py:1440, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
1438 # Start the process
1439 try:
-> 1440 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1441 # no special security
1442 None, None,
1443 int(not close_fds),
1444 creationflags,
1445 env,
1446 cwd,
1447 startupinfo)
1448 finally:
1449 # Child is launched. Close the parent's copy of those pipe
1450 # handles that only the child should have open. You need
(...)
1453 # pipe will not close when the child process exits and the
1454 # ReadFile will hang.
1455 self._close_pipe_fds(p2cread, p2cwrite,
1456 c2pread, c2pwrite,
1457 errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified

@sonichi
Copy link
Contributor

sonichi commented Sep 26, 2023

The error happens because it's trying to use a linux shell in windows. One workaround is to use docker. Otherwise, some change in the _cmd function of code_utils.py is needed, and the system_message of the AssistantAgent needs to be modified about the sh code block.

@Rakly3
Copy link

Rakly3 commented Oct 12, 2023

Install Git Bash

Launch VSCode, open your workspace/folder you want to work in.
Open a terminal in VSCode.
Then in the terminal, type bash and hit Enter.

You can now use 'Linux stuff'


NOTES:

  • I'm not completely sure if you need WSL2 for this also, I already had it installed.
  • This isn't really the purpose of Git Bash, but it works!
  • You will have to install the packages here again.
    • pip install openai pyautogen

randombet pushed a commit to randombet/autogen that referenced this issue Aug 28, 2024
* license

* license change note

* SPDX Identifie

* License in setup

* license in package

* organize license

* minor

* update headers

* header wording

* owner

* extra space

* remove extra period

* remove header template

* Update README.md

Co-authored-by: Chi Wang <[email protected]>

---------

Co-authored-by: HRUSHIKESH DOKALA <[email protected]>
Co-authored-by: Chi Wang <[email protected]>
jackgerrits pushed a commit that referenced this issue Oct 2, 2024
jackgerrits added a commit that referenced this issue Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants