-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Custom Model Client support #1345
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1345 +/- ##
===========================================
+ Coverage 33.12% 46.59% +13.47%
===========================================
Files 42 42
Lines 5051 5112 +61
Branches 1157 1239 +82
===========================================
+ Hits 1673 2382 +709
+ Misses 3250 2530 -720
- Partials 128 200 +72
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Just want to say I am so happy it is merged finally! |
Fantastic work, thank you |
* add client interface, response protocol, and move code into openai client class * add ability to register custom client * tidy up code * adding checks and errors, and more unit tests * remove code * fix error msg * add use_docer False in notebook * better error message * add another example to custom model notebook * rename and have register_client take model name too * make Client protocol and remove inheritance * renames * update notebook * add link * rename and more error checking for registered agents * adding message retrieval to client protocol for more flexible response * fix failing openai test * api_type req made model_client_cls requirement * notebook cleanup and added blog * remove raise error if client list is empty - client list will never be empty it will have placeholders * rename Client -> ModelClient * add forgotten file * fix test by fetching internal client * Update autogen/oai/client.py Co-authored-by: Eric Zhu <[email protected]> * don't add retrieval function to cache * added placeholder cllient class during initial client init, and rewrote registration * fix spelling * Update autogen/agentchat/conversable_agent.py Co-authored-by: Chi Wang <[email protected]> * type hints, small fixes, docstr comment * fix api type checking --------- Co-authored-by: Eric Zhu <[email protected]> Co-authored-by: Chi Wang <[email protected]>
Why are these changes needed?
This PR adds support for custom client calls to be made. The idea is that the user can specify their own custom client class and load it into the configuration (e.g. for loading local models). As long as they adhere to the
Client
class's interface and response protocol then everything should work fine with only this addition to the config (full usage shown in the unit test):So if we have the class
CustomClient
the class name (as a string) needs to be set as the api_type in the config:Then once an agent is created the custom client can be registered:
agent.register_custom_client(CustomClient, [optional other args for the constuctor of CustomClient])
Notes:
Ideally the client interface would not live under a directory called
oai
and the client wrapper wouldn't be calledOpenAIWrapper
but something more generic, but that can be examined at a later dateRelated PR
Replaces #831 and has less refactoring done so that the change is more contained
Checks