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

fix: unexpected keyword arg refusal #419

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

TheChronicMonster
Copy link
Contributor

Added refusal argument to ChatMessage class.
Resolves Issue #413: #413

Fixes the TypeError exception:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "/Users/jpmiller/Projects/ChatDev/camel/utils.py", line 154, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/jpmiller/Projects/ChatDev/camel/agents/chat_agent.py", line 243, in step
    output_messages = [
  File "/Users/jpmiller/Projects/ChatDev/camel/agents/chat_agent.py", line 244, in <listcomp>
    ChatMessage(role_name=self.role_name, role_type=self.role_type,
TypeError: __init__() got an unexpected keyword argument 'refusal'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jpmiller/Projects/ChatDev/run.py", line 134, in <module>
    chat_chain.execute_chain()
  File "/Users/jpmiller/Projects/ChatDev/chatdev/chat_chain.py", line 168, in execute_chain
    self.execute_step(phase_item)
  File "/Users/jpmiller/Projects/ChatDev/chatdev/chat_chain.py", line 138, in execute_step
    self.chat_env = self.phases[phase].execute(self.chat_env,
  File "/Users/jpmiller/Projects/ChatDev/chatdev/phase.py", line 295, in execute
    self.chatting(chat_env=chat_env,
  File "/Users/jpmiller/Projects/ChatDev/chatdev/utils.py", line 79, in wrapper
    return func(*args, **kwargs)
  File "/Users/jpmiller/Projects/ChatDev/chatdev/phase.py", line 133, in chatting
    assistant_response, user_response = role_play_session.step(input_user_msg, chat_turn_limit == 1)
  File "/Users/jpmiller/Projects/ChatDev/camel/agents/role_playing.py", line 247, in step
    assistant_response = self.assistant_agent.step(user_msg_rst)
  File "/opt/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "/opt/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "/opt/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x10c4feac0 state=finished raised TypeError>]

@zhanghb18
Copy link
Collaborator

Thank you for submitting your PR. We will consider whether to include the new 'refusal' field in the future. It is recommended to use the OpenAI version recommended in requirements.txt to prevent problems caused by OpenAI version updates in the future. If you use the latest version of OpenAI, you can solve it according to the solution provided in the issue!

@thinkwee
Copy link
Collaborator

Thank you!

@thinkwee thinkwee merged commit 0e5cfc8 into OpenBMB:main Aug 28, 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 this pull request may close these issues.

3 participants