Skip to content

Commit

Permalink
Merge pull request #130 from ag2ai/patch/llamaindex
Browse files Browse the repository at this point in the history
update: llamaindex_conversable_agent.py
  • Loading branch information
qingyun-wu authored Dec 15, 2024
2 parents 89b1bee + 1b1343e commit 5e7758b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions autogen/agentchat/contrib/llamaindex_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@
from llama_index.core.base.llms.types import ChatMessage
from llama_index.core.chat_engine.types import AgentChatResponse
from pydantic import BaseModel
from pydantic import __version__ as pydantic_version

# let's Avoid: AttributeError: type object 'Config' has no attribute 'copy'
# 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)
else:

class Config:
arbitrary_types_allowed = True

# Add Pydantic configuration to allow arbitrary types
# Added to mitigate PydanticSchemaGenerationError
class Config:
arbitrary_types_allowed = True

BaseModel.model_config = Config

except ImportError as e:
Expand Down

0 comments on commit 5e7758b

Please sign in to comment.