Skip to content

Commit

Permalink
Organize model client (autogenhub#24)
Browse files Browse the repository at this point in the history
* Organize model client

* update patterns
  • Loading branch information
jackgerrits authored May 26, 2024
1 parent 39400e7 commit b6dd861
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ pip install -e ".[docs]"
sphinx-build docs/src docs/build

# To view the docs:
python -m http.server -d docs/build/html
python -m http.server -d docs/build
```
2 changes: 1 addition & 1 deletion examples/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any

import openai
from agnext.agent_components.models_clients.openai_client import OpenAI
from agnext.agent_components.model_client import OpenAI
from agnext.application_components.single_threaded_agent_runtime import (
SingleThreadedAgentRuntime,
)
Expand Down
24 changes: 24 additions & 0 deletions src/agnext/agent_components/model_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from ._model_client import ModelCapabilities, ModelClient
from ._openai_client import (
AsyncAzureADTokenProvider,
AzureOpenAI,
AzureOpenAIClientConfiguration,
BaseOpenAIClientConfiguration,
CreateArguments,
OpenAI,
OpenAIClientConfiguration,
ResponseFormat,
)

__all__ = [
"AzureOpenAI",
"OpenAI",
"OpenAIClientConfiguration",
"AzureOpenAIClientConfiguration",
"ResponseFormat",
"CreateArguments",
"AsyncAzureADTokenProvider",
"BaseOpenAIClientConfiguration",
"ModelCapabilities",
"ModelClient",
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Union,
)

from .types import CreateResult, FunctionDefinition, LLMMessage, RequestUsage
from ..types import CreateResult, FunctionDefinition, LLMMessage, RequestUsage


class ModelCapabilities(TypedDict, total=False):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict

from ..model_client import ModelCapabilities
from ._model_client import ModelCapabilities

# Based on: https://platform.openai.com/docs/models/continuous-model-upgrades
# This is a moving target, so correctness is checked by the model value returned by openai against expected values at runtime``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

# from ..._pydantic import type2schema
from ..image import Image
from ..model_client import ModelCapabilities, ModelClient
from ..types import (
AssistantMessage,
CreateResult,
Expand All @@ -45,7 +44,8 @@
SystemMessage,
UserMessage,
)
from . import model_info
from . import _model_info
from ._model_client import ModelCapabilities, ModelClient

openai_init_kwargs = set(inspect.getfullargspec(AsyncOpenAI.__init__).kwonlyargs)
aopenai_init_kwargs = set(inspect.getfullargspec(AsyncAzureOpenAI.__init__).kwonlyargs)
Expand Down Expand Up @@ -273,13 +273,13 @@ def __init__(
if model_capabilities is None and isinstance(client, AsyncAzureOpenAI):
raise ValueError("AzureOpenAI requires explicit model capabilities")
elif model_capabilities is None:
self._model_capabilities = model_info.get_capabilties(create_args["model"])
self._model_capabilities = _model_info.get_capabilties(create_args["model"])
else:
self._model_capabilities = model_capabilities

self._resolved_model: Optional[str] = None
if "model" in create_args:
self._resolved_model = model_info.resolve_model(create_args["model"])
self._resolved_model = _model_info.resolve_model(create_args["model"])

if (
"response_format" in create_args
Expand Down
3 changes: 0 additions & 3 deletions src/agnext/agent_components/models_clients/__init__.py

This file was deleted.

0 comments on commit b6dd861

Please sign in to comment.