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 ModelClient create function signature error #1865

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Conversation

truebit
Copy link
Contributor

@truebit truebit commented Mar 5, 2024

CustomModelClient takes 1 positional argument but 2 were given if using **params

Why are these changes needed?

If we define the parameters in create fuction of custom ModelClient class using **params, it would throw an error like below:

Traceback (most recent call last):
  File "/Users/truebit/Documents/dev/uiagents/agents/agents.py", line 30, in <module>
    user_proxy.initiate_chat(assistant, message="Write python code to print Hello World!")
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 913, in initiate_chat
    self.send(self.generate_init_message(**context), recipient, silent=silent)
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 605, in send
    recipient.receive(message, self, request_reply, silent)
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 767, in receive
    reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 1740, in generate_reply
    final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 1156, in generate_oai_reply
    extracted_response = self._generate_oai_reply_from_client(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/agentchat/conversable_agent.py", line 1175, in _generate_oai_reply_from_client
    response = llm_client.create(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/truebit/mambaforge/envs/uiagents/lib/python3.11/site-packages/autogen/oai/client.py", line 624, in create
    response = client.create(params)
               ^^^^^^^^^^^^^^^^^^^^^
TypeError: CustomModelClient.create() takes 1 positional argument but 2 were given

## Related issue number

None

## Checks

- [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [x] I've made sure all auto checks have passed.

CustomModelClient takes 1 positional argument but 2 were given
if using **params
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.76%. Comparing base (685164f) to head (bb303e3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1865      +/-   ##
==========================================
+ Coverage   36.10%   43.76%   +7.65%     
==========================================
  Files          63       63              
  Lines        6658     6658              
  Branches     1470     1595     +125     
==========================================
+ Hits         2404     2914     +510     
+ Misses       4056     3506     -550     
- Partials      198      238      +40     
Flag Coverage Δ
unittests 43.69% <100.00%> (+7.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonichi sonichi enabled auto-merge March 6, 2024 19:24
@sonichi sonichi added this pull request to the merge queue Mar 6, 2024
Merged via the queue into microsoft:main with commit 676e8e1 Mar 6, 2024
46 of 57 checks passed
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
CustomModelClient takes 1 positional argument but 2 were given
if using **params

Co-authored-by: Chi Wang <[email protected]>
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.

5 participants