Skip to content

Commit

Permalink
Rename OpenAI to OpenAIChatCompletionClient (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored Jun 25, 2024
1 parent f5f4c39 commit f24278c
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions python/docs/src/guides/azure-openai-with-aad-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ pip install azure-identity
## Using the Model Client

```python
from agnext.components.models import AzureOpenAI
from agnext.components.models import AzureOpenAIChatCompletionClient
from azure.identity import DefaultAzureCredential, get_bearer_token_provider

# Create the token provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
)

client = AzureOpenAI(
client = AzureOpenAIChatCompletionClient(
model="{your-azure-deployment}",
api_version="2024-02-01",
azure_endpoint="https://{your-custom-endpoint}.openai.azure.com/",
Expand Down
6 changes: 3 additions & 3 deletions python/docs/src/guides/group-chat-coder-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from agnext.chat.agents import ChatCompletionAgent
from agnext.chat.memory import BufferedChatMemory
from agnext.chat.patterns import GroupChatManager
from agnext.chat.types import TextMessage
from agnext.components.models import OpenAI, SystemMessage
from agnext.components.models import OpenAIChatCompletionClient, SystemMessage
```

Next, let's create the runtime:
Expand All @@ -49,7 +49,7 @@ coder = runtime.register_and_get_proxy(
"Work with the reviewer to improve your code."
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=BufferedChatMemory(buffer_size=10),
),
)
Expand All @@ -69,7 +69,7 @@ reviewer = runtime.register_and_get_proxy(
"Suggested Changes: <Your comments>"
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=BufferedChatMemory(buffer_size=10),
),
)
Expand Down
4 changes: 2 additions & 2 deletions python/examples/core/one_agent_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from agnext.components import TypeRoutedAgent, message_handler
from agnext.components.models import (
ChatCompletionClient,
OpenAI,
OpenAIChatCompletionClient,
SystemMessage,
UserMessage,
)
Expand Down Expand Up @@ -34,7 +34,7 @@ async def handle_user_message(self, message: Message, cancellation_token: Cancel
async def main() -> None:
runtime = SingleThreadedAgentRuntime()
agent = runtime.register_and_get(
"chat_agent", lambda: ChatCompletionAgent("Chat agent", OpenAI(model="gpt-3.5-turbo"))
"chat_agent", lambda: ChatCompletionAgent("Chat agent", OpenAIChatCompletionClient(model="gpt-3.5-turbo"))
)

# Send a message to the agent.
Expand Down
6 changes: 3 additions & 3 deletions python/examples/core/two_agents_pub_sub_termination.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
AssistantMessage,
ChatCompletionClient,
LLMMessage,
OpenAI,
OpenAIChatCompletionClient,
SystemMessage,
UserMessage,
)
Expand Down Expand Up @@ -90,7 +90,7 @@ async def main() -> None:
"Jack",
lambda: ChatCompletionAgent(
description="Jack a comedian",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
system_messages=[
SystemMessage("You are a comedian likes to make jokes. " "When you are done talking, say 'TERMINATE'.")
],
Expand All @@ -101,7 +101,7 @@ async def main() -> None:
"Cathy",
lambda: ChatCompletionAgent(
description="Cathy a poet",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
system_messages=[
SystemMessage("You are a poet likes to write poems. " "When you are done talking, say 'TERMINATE'.")
],
Expand Down
8 changes: 4 additions & 4 deletions python/examples/demos/chat_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from agnext.chat.utils import convert_messages_to_llm_messages
from agnext.components import TypeRoutedAgent, message_handler
from agnext.components.memory import ChatMemory
from agnext.components.models import ChatCompletionClient, OpenAI, SystemMessage
from agnext.components.models import ChatCompletionClient, OpenAIChatCompletionClient, SystemMessage
from agnext.core import AgentRuntime, CancellationToken

sys.path.append(os.path.abspath(os.path.dirname(__file__)))
Expand Down Expand Up @@ -101,7 +101,7 @@ def chat_room(runtime: AgentRuntime, app: TextualChatApp) -> None:
description="Alice in the chat room.",
background_story="Alice is a software engineer who loves to code.",
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)
bob = runtime.register_and_get_proxy(
Expand All @@ -111,7 +111,7 @@ def chat_room(runtime: AgentRuntime, app: TextualChatApp) -> None:
description="Bob in the chat room.",
background_story="Bob is a data scientist who loves to analyze data.",
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)
charlie = runtime.register_and_get_proxy(
Expand All @@ -121,7 +121,7 @@ def chat_room(runtime: AgentRuntime, app: TextualChatApp) -> None:
description="Charlie in the chat room.",
background_story="Charlie is a designer who loves to create art.",
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)
app.welcoming_notice = f"""Welcome to the chat room demo with the following participants:
Expand Down
6 changes: 3 additions & 3 deletions python/examples/demos/chess_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from agnext.chat.memory import BufferedChatMemory
from agnext.chat.patterns._group_chat_manager import GroupChatManager
from agnext.chat.types import TextMessage
from agnext.components.models import OpenAI, SystemMessage
from agnext.components.models import OpenAIChatCompletionClient, SystemMessage
from agnext.components.tools import FunctionTool
from agnext.core import AgentRuntime
from chess import BLACK, SQUARE_NAMES, WHITE, Board, Move
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_board_text() -> Annotated[str, "The current board state"]:
),
],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
tools=black_tools,
),
)
Expand All @@ -180,7 +180,7 @@ def get_board_text() -> Annotated[str, "The current board state"]:
),
],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
tools=white_tools,
),
)
Expand Down
6 changes: 3 additions & 3 deletions python/examples/demos/illustrator_critics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from agnext.chat.agents import ChatCompletionAgent, ImageGenerationAgent
from agnext.chat.memory import BufferedChatMemory
from agnext.chat.patterns._group_chat_manager import GroupChatManager
from agnext.components.models import OpenAI, SystemMessage
from agnext.components.models import OpenAIChatCompletionClient, SystemMessage
from agnext.core import AgentRuntime

sys.path.append(os.path.abspath(os.path.dirname(__file__)))
Expand Down Expand Up @@ -41,7 +41,7 @@ def illustrator_critics(runtime: AgentRuntime, app: TextualChatApp) -> None:
),
],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo", max_tokens=500),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo", max_tokens=500),
),
)
illustrator = runtime.register_and_get_proxy(
Expand Down Expand Up @@ -69,7 +69,7 @@ def illustrator_critics(runtime: AgentRuntime, app: TextualChatApp) -> None:
),
],
memory=BufferedChatMemory(buffer_size=2),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)
runtime.register(
Expand Down
12 changes: 6 additions & 6 deletions python/examples/demos/software_consultancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from agnext.chat.agents import ChatCompletionAgent
from agnext.chat.memory import HeadAndTailChatMemory
from agnext.chat.patterns._group_chat_manager import GroupChatManager
from agnext.components.models import OpenAI, SystemMessage
from agnext.components.models import OpenAIChatCompletionClient, SystemMessage
from agnext.components.tools import FunctionTool
from agnext.core import AgentRuntime
from markdownify import markdownify # type: ignore
Expand Down Expand Up @@ -126,7 +126,7 @@ def software_consultancy(runtime: AgentRuntime, app: TextualChatApp) -> None: #
"Be concise and deliver now."
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=HeadAndTailChatMemory(head_size=1, tail_size=10),
tools=[
FunctionTool(
Expand Down Expand Up @@ -166,7 +166,7 @@ def software_consultancy(runtime: AgentRuntime, app: TextualChatApp) -> None: #
"Be VERY concise."
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=HeadAndTailChatMemory(head_size=1, tail_size=10),
tools=[
FunctionTool(
Expand Down Expand Up @@ -194,7 +194,7 @@ def software_consultancy(runtime: AgentRuntime, app: TextualChatApp) -> None: #
"Be concise and deliver now."
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=HeadAndTailChatMemory(head_size=1, tail_size=10),
tools=[
FunctionTool(
Expand Down Expand Up @@ -226,7 +226,7 @@ def software_consultancy(runtime: AgentRuntime, app: TextualChatApp) -> None: #
"Be concise and deliver now."
)
],
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
memory=HeadAndTailChatMemory(head_size=1, tail_size=10),
tools=[
FunctionTool(
Expand All @@ -243,7 +243,7 @@ def software_consultancy(runtime: AgentRuntime, app: TextualChatApp) -> None: #
lambda: GroupChatManager(
description="A group chat manager.",
memory=HeadAndTailChatMemory(head_size=1, tail_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
participants=[developer, product_manager, ux_designer, illustrator, user_agent],
),
)
Expand Down
10 changes: 5 additions & 5 deletions python/examples/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from agnext.chat.memory import BufferedChatMemory
from agnext.chat.patterns._orchestrator_chat import OrchestratorChat
from agnext.chat.types import TextMessage
from agnext.components.models import OpenAI, SystemMessage
from agnext.components.models import OpenAIChatCompletionClient, SystemMessage
from agnext.components.tools import BaseTool
from agnext.core import AgentRuntime, CancellationToken
from pydantic import BaseModel, Field
Expand Down Expand Up @@ -57,7 +57,7 @@ def software_development(runtime: AgentRuntime) -> OrchestratorChat: # type: ig
description="A developer that writes code.",
system_messages=[SystemMessage("You are a Python developer.")],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)

Expand Down Expand Up @@ -88,7 +88,7 @@ def software_development(runtime: AgentRuntime) -> OrchestratorChat: # type: ig
SystemMessage("You can use the search tool to find information on the web."),
],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
tools=[SearchTool()],
),
)
Expand All @@ -99,7 +99,7 @@ def software_development(runtime: AgentRuntime) -> OrchestratorChat: # type: ig
description="A planner that organizes and schedules tasks.",
system_messages=[SystemMessage("You are a planner of complex tasks.")],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)

Expand All @@ -111,7 +111,7 @@ def software_development(runtime: AgentRuntime) -> OrchestratorChat: # type: ig
SystemMessage("You are an orchestrator that coordinates the team to complete a complex task.")
],
memory=BufferedChatMemory(buffer_size=10),
model_client=OpenAI(model="gpt-4-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-4-turbo"),
),
)

Expand Down
6 changes: 3 additions & 3 deletions python/examples/patterns/coder_reviewer_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
AssistantMessage,
ChatCompletionClient,
LLMMessage,
OpenAI,
OpenAIChatCompletionClient,
SystemMessage,
UserMessage,
)
Expand Down Expand Up @@ -197,14 +197,14 @@ async def main() -> None:
"ReviewerAgent",
lambda: ReviewerAgent(
description="Code Reviewer",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)
coder = runtime.register_and_get(
"CoderAgent",
lambda: CoderAgent(
description="Coder",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
reviewer=reviewer,
),
)
Expand Down
6 changes: 3 additions & 3 deletions python/examples/patterns/coder_reviewer_pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
AssistantMessage,
ChatCompletionClient,
LLMMessage,
OpenAI,
OpenAIChatCompletionClient,
SystemMessage,
UserMessage,
)
Expand Down Expand Up @@ -272,14 +272,14 @@ async def main() -> None:
"ReviewerAgent",
lambda: ReviewerAgent(
description="Code Reviewer",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)
runtime.register(
"CoderAgent",
lambda: CoderAgent(
description="Coder",
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)
runtime.register(
Expand Down
8 changes: 4 additions & 4 deletions python/examples/patterns/group_chat_pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
AssistantMessage,
ChatCompletionClient,
LLMMessage,
OpenAI,
OpenAIChatCompletionClient,
SystemMessage,
UserMessage,
)
Expand Down Expand Up @@ -120,23 +120,23 @@ async def main() -> None:
lambda: GroupChatParticipant(
description="A data scientist",
system_messages=[SystemMessage("You are a data scientist.")],
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)
agent2 = runtime.register_and_get(
"Engineer",
lambda: GroupChatParticipant(
description="An engineer",
system_messages=[SystemMessage("You are an engineer.")],
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)
agent3 = runtime.register_and_get(
"Artist",
lambda: GroupChatParticipant(
description="An artist",
system_messages=[SystemMessage("You are an artist.")],
model_client=OpenAI(model="gpt-3.5-turbo"),
model_client=OpenAIChatCompletionClient(model="gpt-3.5-turbo"),
),
)

Expand Down
Loading

0 comments on commit f24278c

Please sign in to comment.