Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
53a9a95
refactor: deprecate LLMConfig contextmanager, .current, .default
Lancetnik Aug 14, 2025
7fbcac1
chore: revert import utils changes
Lancetnik Aug 14, 2025
55ee206
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 14, 2025
979f861
Merge branch 'refactor/llmconfig-deprecations' of github.com:ag2ai/ag…
Lancetnik Aug 14, 2025
c5eae48
chore: remove deprecated syntax from blog
Lancetnik Aug 14, 2025
3749f92
refactor: remove old deprecated (>17 months)
Lancetnik Aug 14, 2025
f1cd3d2
chore: remove site deprecations
Lancetnik Aug 14, 2025
610bfb9
fix: gemini correct proxy passing
Lancetnik Aug 14, 2025
a662ea0
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 17, 2025
0b50121
tests: polish conftest
Lancetnik Aug 17, 2025
6d1538c
docs: remove deprecated LLMConfig usages
Lancetnik Aug 17, 2025
a5d1807
docs: remove deprecated LLMConfig usages
Lancetnik Aug 18, 2025
50a53a1
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 20, 2025
0d02fcf
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 20, 2025
c01007a
chore: reuse Entries types
Lancetnik Aug 20, 2025
801b042
Merge branch 'refactor/llmconfig-deprecations' of github.com:ag2ai/ag…
Lancetnik Aug 20, 2025
8cd76a3
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 20, 2025
a353bae
fix: #2049 not so stict `top_p` options validators
Lancetnik Aug 22, 2025
9c4faf6
Merge branch 'main' into refactor/llmconfig-deprecations
qingyun-wu Aug 23, 2025
d09b0ee
Merge branch 'main' into refactor/llmconfig-deprecations
priyansh4320 Aug 24, 2025
26bb04b
lint: fix ruff for notebook/agentchat_webscraping_with_oxylabs.ipynb …
Lancetnik Aug 24, 2025
2c6a9e8
chore: remove useless changes
Lancetnik Aug 24, 2025
bc30402
chore: remove useless comment
Lancetnik Aug 24, 2025
462ea40
chore: update gpt-4o to gpt-5 in examples
Lancetnik Aug 25, 2025
c3fce1f
Merge branch 'main' into refactor/llmconfig-deprecations
Lancetnik Aug 25, 2025
7101b9d
fix: update pydantic-ai integration
Lancetnik Aug 25, 2025
fb8f2db
Merge branch 'refactor/llmconfig-deprecations' of github.com:ag2ai/ag…
Lancetnik Aug 25, 2025
234a592
choreL touch pyproject
Lancetnik Aug 25, 2025
b1cbdad
Merge branch 'main' into refactor/llmconfig-deprecations
marklysze Aug 25, 2025
656eece
chore: resolve conflicts
Lancetnik Aug 31, 2025
9a088c7
chore: resolve conflicts
Lancetnik Sep 4, 2025
aa626c3
chore: fix ipynb markup
Lancetnik Sep 4, 2025
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
113 changes: 64 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ from autogen import AssistantAgent, UserProxyAgent, LLMConfig

llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")

assistant = AssistantAgent("assistant", llm_config=llm_config)

with llm_config:
assistant = AssistantAgent("assistant")
user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False})

user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.")
# This initiates an automated chat between the two agents to solve the task
```
Expand Down Expand Up @@ -148,22 +148,23 @@ from autogen import ConversableAgent, LLMConfig

# 2. Define our LLM configuration for OpenAI's GPT-4o mini
# uses the OPENAI_API_KEY environment variable
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")

llm_config = LLMConfig({
"api_type": "openai",
"model": "gpt-4o-mini",
})

# 3. Create our LLM agent
with llm_config:
# Create an AI agent
assistant = ConversableAgent(
name="assistant",
system_message="You are an assistant that responds concisely.",
)

# Create another AI agent
fact_checker = ConversableAgent(
name="fact_checker",
system_message="You are a fact-checking assistant.",
)
assistant = ConversableAgent(
name="assistant",
system_message="You are an assistant that responds concisely.",
llm_config=llm_config,
)

fact_checker = ConversableAgent(
name="fact_checker",
system_message="You are a fact-checking assistant.",
llm_config=llm_config,
)

# 4. Start the conversation
assistant.initiate_chat(
Expand Down Expand Up @@ -192,23 +193,29 @@ from autogen import ConversableAgent, UserProxyAgent, LLMConfig

# 2. Define our LLM configuration for OpenAI's GPT-4o mini
# uses the OPENAI_API_KEY environment variable
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")

llm_config = LLMConfig({
"api_type": "openai",
"model": "gpt-4o-mini",
})

# 3. Create our LLM agent
with llm_config:
assistant = ConversableAgent(
name="assistant",
system_message="You are a helpful assistant.",
)
assistant = ConversableAgent(
name="assistant",
system_message="You are a helpful assistant.",
llm_config=llm_config,
)

# 4. Create a human agent with manual input mode
human = ConversableAgent(
name="human",
human_input_mode="ALWAYS"
)

# or
human = UserProxyAgent(name="human", code_execution_config={"work_dir": "coding", "use_docker": False})
human = UserProxyAgent(
name="human",
code_execution_config={"work_dir": "coding", "use_docker": False},
)

# 5. Start the chat
human.initiate_chat(
Expand All @@ -232,7 +239,10 @@ Note: Before running this code, make sure to set your `OPENAI_API_KEY` as an env
from autogen import ConversableAgent, GroupChat, GroupChatManager, LLMConfig

# Put your key in the OPENAI_API_KEY environment variable
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")
llm_config = LLMConfig({
"api_type": "openai",
"model": "gpt-4o-mini",
})

planner_message = """You are a classroom lesson agent.
Given a topic, write a lesson plan for a fourth grade class.
Expand All @@ -253,18 +263,19 @@ planner_description = "Creates or revises lesson plans."
reviewer_description = """Provides one round of reviews to a lesson plan
for the lesson_planner to revise."""

with llm_config:
lesson_planner = ConversableAgent(
name="planner_agent",
system_message=planner_message,
description=planner_description,
)
lesson_planner = ConversableAgent(
name="planner_agent",
system_message=planner_message,
description=planner_description,
llm_config=llm_config,
)

lesson_reviewer = ConversableAgent(
name="reviewer_agent",
system_message=reviewer_message,
description=reviewer_description,
)
lesson_reviewer = ConversableAgent(
name="reviewer_agent",
system_message=reviewer_message,
description=reviewer_description,
llm_config=llm_config,
)

# 2. The teacher's system message can also be used as a description, so we don't define it
teacher_message = """You are a classroom teacher.
Expand All @@ -273,13 +284,13 @@ and reviewer to create and finalise lesson plans.
When you are happy with a lesson plan, output "DONE!".
"""

with llm_config:
teacher = ConversableAgent(
name="teacher_agent",
system_message=teacher_message,
# 3. Our teacher can end the conversation by saying DONE!
is_termination_msg=lambda x: "DONE!" in (x.get("content", "") or "").upper(),
)
teacher = ConversableAgent(
name="teacher_agent",
system_message=teacher_message,
# 3. Our teacher can end the conversation by saying DONE!
is_termination_msg=lambda x: "DONE!" in (x.get("content", "") or "").upper(),
llm_config=llm_config,
)

# 4. Create the GroupChat with agents and selection method
groupchat = GroupChat(
Expand Down Expand Up @@ -319,24 +330,28 @@ from typing import Annotated
from autogen import ConversableAgent, register_function, LLMConfig

# Put your key in the OPENAI_API_KEY environment variable
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")
llm_config = LLMConfig({
"api_type": "openai",
"model": "gpt-4o-mini",
})

# 1. Our tool, returns the day of the week for a given date
def get_weekday(date_string: Annotated[str, "Format: YYYY-MM-DD"]) -> str:
date = datetime.strptime(date_string, "%Y-%m-%d")
return date.strftime("%A")

# 2. Agent for determining whether to run the tool
with llm_config:
date_agent = ConversableAgent(
name="date_agent",
system_message="You get the day of the week for a given date.",
)
date_agent = ConversableAgent(
name="date_agent",
system_message="You get the day of the week for a given date.",
llm_config=llm_config,
)

# 3. And an agent for executing the tool
executor_agent = ConversableAgent(
name="executor_agent",
human_input_mode="NEVER",
llm_config=llm_config,
)

# 4. Registers the tool with the agents, the description will be used by the LLM
Expand Down
13 changes: 4 additions & 9 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,12 @@ def _validate_llm_config(
if llm_config is None:
llm_config = LLMConfig.get_current_llm_config()
if llm_config is None:
llm_config = cls.DEFAULT_CONFIG
elif isinstance(llm_config, dict):
llm_config = LLMConfig(**llm_config)
elif isinstance(llm_config, LLMConfig):
llm_config = llm_config.copy()
return cls.DEFAULT_CONFIG

elif llm_config is False:
pass
else:
raise ValueError("llm_config must be a LLMConfig, dict or False or None.")
return False

return llm_config
return LLMConfig.ensure_config(llm_config)

@classmethod
def _create_client(cls, llm_config: LLMConfig | Literal[False]) -> OpenAIWrapper | None:
Expand Down
Loading
Loading