mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-24 14:15:17 +02:00
migrate from pydantic v1 to v2
This commit is contained in:
parent
0569fc5560
commit
66925dd791
29 changed files with 143 additions and 158 deletions
|
|
@ -5,7 +5,7 @@ from typing import Generator, Optional
|
|||
from urllib.parse import urljoin, urlparse
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, PrivateAttr
|
||||
|
||||
|
||||
class WebPage(BaseModel):
|
||||
|
|
@ -13,11 +13,8 @@ class WebPage(BaseModel):
|
|||
html: str
|
||||
url: str
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
|
||||
_soup: Optional[BeautifulSoup] = None
|
||||
_title: Optional[str] = None
|
||||
_soup: Optional[BeautifulSoup] = PrivateAttr(default=None)
|
||||
_title: Optional[str] = PrivateAttr(default=None)
|
||||
|
||||
@property
|
||||
def soup(self) -> BeautifulSoup:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ def serialize_message(message: "Message"):
|
|||
ic = message_cp.instruct_content
|
||||
if ic:
|
||||
# model create by pydantic create_model like `pydantic.main.prd`, can't pickle.dump directly
|
||||
schema = ic.schema()
|
||||
schema = ic.model_json_schema()
|
||||
mapping = actionoutout_schema_to_mapping(schema)
|
||||
|
||||
message_cp.instruct_content = {"class": schema["title"], "mapping": mapping, "value": ic.dict()}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue