Skip to content

Commit

Permalink
Rename ModelClient to ChatCompletionClient (autogenhub#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored Jun 5, 2024
1 parent ab420cc commit 06ba5d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/agnext/chat/agents/chat_completion_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
TypeRoutedAgent,
message_handler,
)
from agnext.components.models import FunctionExecutionResult, FunctionExecutionResultMessage, ModelClient, SystemMessage
from agnext.components.models import (
ChatCompletionClient,
FunctionExecutionResult,
FunctionExecutionResultMessage,
SystemMessage,
)
from agnext.components.tools import Tool
from agnext.core import AgentRuntime, CancellationToken

Expand All @@ -29,7 +34,7 @@ def __init__(
description: str,
runtime: AgentRuntime,
system_messages: List[SystemMessage],
model_client: ModelClient,
model_client: ChatCompletionClient,
tools: Sequence[Tool] = [],
) -> None:
super().__init__(name, description, runtime)
Expand Down
4 changes: 2 additions & 2 deletions src/agnext/components/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._model_client import ModelCapabilities, ModelClient
from ._model_client import ChatCompletionClient, ModelCapabilities
from ._openai_client import (
AzureOpenAI,
OpenAI,
Expand All @@ -19,7 +19,7 @@
"AzureOpenAI",
"OpenAI",
"ModelCapabilities",
"ModelClient",
"ChatCompletionClient",
"SystemMessage",
"UserMessage",
"AssistantMessage",
Expand Down
2 changes: 1 addition & 1 deletion src/agnext/components/models/_model_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ModelCapabilities(TypedDict, total=False):


@runtime_checkable
class ModelClient(Protocol):
class ChatCompletionClient(Protocol):
# Caching has to be handled internally as they can depend on the create args that were stored in the constructor
async def create(
self,
Expand Down
6 changes: 3 additions & 3 deletions src/agnext/components/models/_openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
from ..tools import Tool
from . import _model_info
from ._model_client import ModelCapabilities, ModelClient
from ._model_client import ChatCompletionClient, ModelCapabilities
from ._types import (
AssistantMessage,
CreateResult,
Expand Down Expand Up @@ -214,7 +214,7 @@ def convert_tools(
return result


class BaseOpenAI(ModelClient):
class BaseOpenAI(ChatCompletionClient):
def __init__(
self,
client: Union[AsyncOpenAI, AsyncAzureOpenAI],
Expand Down Expand Up @@ -245,7 +245,7 @@ def __init__(
self._actual_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)

@classmethod
def create_from_config(cls, config: Dict[str, Any]) -> ModelClient:
def create_from_config(cls, config: Dict[str, Any]) -> ChatCompletionClient:
return OpenAI(**config)

async def create(
Expand Down

0 comments on commit 06ba5d3

Please sign in to comment.