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

Custom Model Client support #1345

Merged
merged 55 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
10a6d06
add client interface, response protocol, and move code into openai cl…
olgavrou Jan 18, 2024
d313fa3
add ability to register custom client
olgavrou Jan 18, 2024
340508b
tidy up code
olgavrou Jan 18, 2024
655e972
adding checks and errors, and more unit tests
olgavrou Jan 18, 2024
32a9ce3
remove code
olgavrou Jan 18, 2024
29ca179
fix error msg
olgavrou Jan 18, 2024
64863f2
add use_docer False in notebook
olgavrou Jan 18, 2024
e9fcab2
merge from main
olgavrou Jan 18, 2024
7bd1026
better error message
olgavrou Jan 18, 2024
8e0e276
add another example to custom model notebook
olgavrou Jan 18, 2024
c202b5d
rename and have register_client take model name too
olgavrou Jan 19, 2024
8e8fe93
make Client protocol and remove inheritance
olgavrou Jan 19, 2024
0ab378c
Merge branch 'main' into custom_client
olgavrou Jan 23, 2024
865fa5d
renames
olgavrou Jan 19, 2024
b89893a
Merge branch 'main' into custom_client
olgavrou Jan 24, 2024
4bd1ba1
update notebook
olgavrou Jan 25, 2024
b4dcb0f
Merge branch 'main' into custom_client
olgavrou Jan 25, 2024
2127eff
add link
olgavrou Jan 25, 2024
20fc193
Merge branch 'main' into custom_client
olgavrou Jan 25, 2024
fe57334
rename and more error checking for registered agents
olgavrou Jan 25, 2024
8396e30
adding message retrieval to client protocol for more flexible response
olgavrou Jan 26, 2024
1aa74df
fix failing openai test
olgavrou Jan 26, 2024
67ad1d3
api_type req made model_client_cls requirement
olgavrou Jan 26, 2024
7f196ac
Merge branch 'main' into custom_client
olgavrou Jan 26, 2024
69c1ab5
notebook cleanup and added blog
olgavrou Jan 25, 2024
7888a7c
remove raise error if client list is empty - client list will never b…
olgavrou Jan 26, 2024
ac7eed1
rename Client -> ModelClient
olgavrou Jan 26, 2024
95d127b
add forgotten file
olgavrou Jan 26, 2024
26d45de
fix test by fetching internal client
olgavrou Jan 27, 2024
f13443d
Merge branch 'main' into custom_client
olgavrou Jan 29, 2024
fe0ffb5
Update autogen/oai/client.py
olgavrou Jan 29, 2024
b553d4d
Merge branch 'main' into custom_client
olgavrou Jan 30, 2024
021dc9f
Merge branch 'custom_client' of github.com:olgavrou/autogen into cust…
olgavrou Jan 26, 2024
a8563a2
don't add retrieval function to cache
olgavrou Jan 30, 2024
777b6ba
Merge branch 'main' into custom_client
olgavrou Jan 30, 2024
ed06d75
added placeholder cllient class during initial client init, and rewro…
olgavrou Jan 30, 2024
d7cb813
Merge branch 'custom_client' of github.com:olgavrou/autogen into cust…
olgavrou Jan 30, 2024
a737045
fix spelling
olgavrou Jan 26, 2024
335e286
Merge branch 'main' into custom_client
olgavrou Jan 30, 2024
f682695
Merge branch 'main' into custom_client
sonichi Jan 31, 2024
4e6d65c
Update autogen/agentchat/conversable_agent.py
olgavrou Jan 31, 2024
da11c36
Merge branch 'main' into custom_client
sonichi Jan 31, 2024
4dc5321
Merge branch 'custom_client' of github.com:olgavrou/autogen into cust…
olgavrou Jan 26, 2024
054bb80
Merge branch 'main' into custom_client
olgavrou Jan 31, 2024
2364bc6
Merge branch 'main' into custom_client
olgavrou Jan 31, 2024
a688530
Merge branch 'custom_client' of github.com:olgavrou/autogen into cust…
olgavrou Jan 26, 2024
b179933
Merge branch 'main' into custom_client
olgavrou Jan 31, 2024
2fe020c
Merge branch 'main' into custom_client
olgavrou Feb 1, 2024
dc7605e
type hints, small fixes, docstr comment
olgavrou Jan 27, 2024
381423a
Merge branch 'main' into custom_client
sonichi Feb 2, 2024
1ea55cc
Merge branch 'main' into custom_client
olgavrou Feb 2, 2024
479696c
Merge branch 'custom_client' of github.com:olgavrou/autogen into cust…
olgavrou Jan 27, 2024
e91bb43
Merge branch 'main' into custom_client
olgavrou Feb 2, 2024
f9bca4e
fix api type checking
olgavrou Jan 27, 2024
443d57b
Merge branch 'main' into custom_client
olgavrou Feb 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/gpt_assistant_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
oai_wrapper = OpenAIWrapper(**llm_config)
if len(oai_wrapper._clients) > 1:
logger.warning("GPT Assistant only supports one OpenAI client. Using the first client in the list.")
self._openai_client = oai_wrapper._clients[0]
self._openai_client = oai_wrapper._clients[0]._oai_client
openai_assistant_id = llm_config.get("assistant_id", None)
if openai_assistant_id is None:
# try to find assistant by name first
Expand Down
11 changes: 10 additions & 1 deletion autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Any, Awaitable, Callable, Dict, List, Literal, Optional, Tuple, Type, TypeVar, Union
import warnings

from .. import OpenAIWrapper
from .. import OpenAIWrapper, ModelClient
from ..cache.cache import Cache
from ..code_utils import (
DEFAULT_MODEL,
Expand Down Expand Up @@ -1946,6 +1946,15 @@ def _decorator(func: F) -> F:

return _decorator

def register_model_client(self, model_client_cls: ModelClient, **kwargs):
"""Register a model client.

Args:
model_client_cls: A custom client class that follows the Client interface
**kwargs: The kwargs for the custom client class to be initialized with
"""
self.client.register_model_client(model_client_cls, **kwargs)

def register_hook(self, hookable_method: Callable, hook: Callable):
"""
Registers a hook to be called by a hookable method, in order to add a capability to the agent.
Expand Down
3 changes: 2 additions & 1 deletion autogen/oai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from autogen.oai.client import OpenAIWrapper
from autogen.oai.client import OpenAIWrapper, ModelClient
from autogen.oai.completion import Completion, ChatCompletion
from autogen.oai.openai_utils import (
get_config_list,
Expand All @@ -12,6 +12,7 @@

__all__ = [
"OpenAIWrapper",
"ModelClient",
"Completion",
"ChatCompletion",
"get_config_list",
Expand Down
571 changes: 354 additions & 217 deletions autogen/oai/client.py

Large diffs are not rendered by default.

Loading
Loading