From afb227c8c2d901070a614e621c1c9cfc7bbf0e81 Mon Sep 17 00:00:00 2001 From: Lazaros Toumanidis Date: Mon, 2 Dec 2024 08:17:57 +0200 Subject: [PATCH 1/5] update: llamaindex_conversable_agent.py --- autogen/agentchat/contrib/llamaindex_conversable_agent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autogen/agentchat/contrib/llamaindex_conversable_agent.py b/autogen/agentchat/contrib/llamaindex_conversable_agent.py index e29393748f..f8dcf17aa3 100644 --- a/autogen/agentchat/contrib/llamaindex_conversable_agent.py +++ b/autogen/agentchat/contrib/llamaindex_conversable_agent.py @@ -16,14 +16,16 @@ from llama_index.core.agent.runner.base import AgentRunner from llama_index.core.base.llms.types import ChatMessage from llama_index.core.chat_engine.types import AgentChatResponse - from pydantic import BaseModel, __version__ as pydantic_version - + from pydantic import BaseModel + from pydantic import __version__ as pydantic_version + # let's Avoid: AttributeError: type object 'Config' has no attribute 'copy' if pydantic_version >= "2.0": from pydantic import ConfigDict Config = ConfigDict(arbitrary_types_allowed=True) else: + class Config: arbitrary_types_allowed = True From 4b5ab2318d1fa2aa108d84e67799cd74c10a22da Mon Sep 17 00:00:00 2001 From: Lazaros Toumanidis Date: Tue, 3 Dec 2024 10:33:49 +0200 Subject: [PATCH 2/5] Update llamaindex_conversable_agent.py --- autogen/agentchat/contrib/llamaindex_conversable_agent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autogen/agentchat/contrib/llamaindex_conversable_agent.py b/autogen/agentchat/contrib/llamaindex_conversable_agent.py index f8dcf17aa3..950b5995ec 100644 --- a/autogen/agentchat/contrib/llamaindex_conversable_agent.py +++ b/autogen/agentchat/contrib/llamaindex_conversable_agent.py @@ -16,11 +16,12 @@ from llama_index.core.agent.runner.base import AgentRunner from llama_index.core.base.llms.types import ChatMessage from llama_index.core.chat_engine.types import AgentChatResponse + from packaging import version from pydantic import BaseModel from pydantic import __version__ as pydantic_version # let's Avoid: AttributeError: type object 'Config' has no attribute 'copy' - if pydantic_version >= "2.0": + if version.parse(pydantic_version) >= version.parse("2.0.0"): from pydantic import ConfigDict Config = ConfigDict(arbitrary_types_allowed=True) From 53f186c84f6cdade2e13e9defb976d8add12bf53 Mon Sep 17 00:00:00 2001 From: Lazaros Toumanidis Date: Tue, 3 Dec 2024 10:50:41 +0200 Subject: [PATCH 3/5] Update llamaindex_conversable_agent.py --- autogen/agentchat/contrib/llamaindex_conversable_agent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autogen/agentchat/contrib/llamaindex_conversable_agent.py b/autogen/agentchat/contrib/llamaindex_conversable_agent.py index 582ff396a5..3cfafb5f7e 100644 --- a/autogen/agentchat/contrib/llamaindex_conversable_agent.py +++ b/autogen/agentchat/contrib/llamaindex_conversable_agent.py @@ -17,6 +17,9 @@ from llama_index.core.base.llms.types import ChatMessage from llama_index.core.chat_engine.types import AgentChatResponse + from packaging import version + from pydantic import BaseModel + from pydantic import __version__ as pydantic_version # let's Avoid: AttributeError: type object 'Config' has no attribute 'copy' if version.parse(pydantic_version) >= version.parse("2.0.0"): from pydantic import ConfigDict From e871878dac7c5f7fa8c1341e304065e5dc4876bf Mon Sep 17 00:00:00 2001 From: Lazaros Toumanidis Date: Tue, 3 Dec 2024 10:54:48 +0200 Subject: [PATCH 4/5] Update llamaindex_conversable_agent.py --- autogen/agentchat/contrib/llamaindex_conversable_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen/agentchat/contrib/llamaindex_conversable_agent.py b/autogen/agentchat/contrib/llamaindex_conversable_agent.py index 3cfafb5f7e..950b5995ec 100644 --- a/autogen/agentchat/contrib/llamaindex_conversable_agent.py +++ b/autogen/agentchat/contrib/llamaindex_conversable_agent.py @@ -16,10 +16,10 @@ from llama_index.core.agent.runner.base import AgentRunner from llama_index.core.base.llms.types import ChatMessage from llama_index.core.chat_engine.types import AgentChatResponse - from packaging import version from pydantic import BaseModel from pydantic import __version__ as pydantic_version + # let's Avoid: AttributeError: type object 'Config' has no attribute 'copy' if version.parse(pydantic_version) >= version.parse("2.0.0"): from pydantic import ConfigDict From 1b1343e4f00046ef7384acb2bd742e2670cb1341 Mon Sep 17 00:00:00 2001 From: Lazaros Toumanidis Date: Thu, 12 Dec 2024 23:05:25 +0200 Subject: [PATCH 5/5] Update llamaindex_conversable_agent.py --- autogen/agentchat/contrib/llamaindex_conversable_agent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autogen/agentchat/contrib/llamaindex_conversable_agent.py b/autogen/agentchat/contrib/llamaindex_conversable_agent.py index 950b5995ec..c1a51cc491 100644 --- a/autogen/agentchat/contrib/llamaindex_conversable_agent.py +++ b/autogen/agentchat/contrib/llamaindex_conversable_agent.py @@ -16,12 +16,13 @@ from llama_index.core.agent.runner.base import AgentRunner from llama_index.core.base.llms.types import ChatMessage from llama_index.core.chat_engine.types import AgentChatResponse - from packaging import version from pydantic import BaseModel from pydantic import __version__ as pydantic_version # let's Avoid: AttributeError: type object 'Config' has no attribute 'copy' - if version.parse(pydantic_version) >= version.parse("2.0.0"): + # check for v1 like in autogen/_pydantic.py + is_pydantic_v1 = pydantic_version.startswith("1.") + if not is_pydantic_v1: from pydantic import ConfigDict Config = ConfigDict(arbitrary_types_allowed=True)