Skip to content

Commit d4ea413

Browse files
Merge pull request #413 from Aggregate-Intellect/fix/pydantic-warning
upgrade pydantic from v1 to v2
2 parents 95e57f8 + 0eb938c commit d4ea413

14 files changed

Lines changed: 28 additions & 29 deletions

src/poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sherpa_ai/actions/arxiv_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
class ArxivSearch(BaseRetrievalAction):
2020
role_description: str
2121
task: str
22-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
22+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
2323
description: str = SEARCH_SUMMARY_DESCRIPTION
24-
_search_tool: Any
24+
_search_tool: Any = None
2525

2626
# Override the name and args from BaseAction
2727
name: str = "ArxivSearch"

src/sherpa_ai/actions/belief_actions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
from sherpa_ai.actions.base import BaseAction
88
from sherpa_ai.memory.belief import Belief
9+
from pydantic import ConfigDict
910

1011

1112
class UpdateBelief(BaseAction):
12-
class Config:
13-
arbitrary_types_allowed = True
13+
model_config = ConfigDict(arbitrary_types_allowed=True)
1414

1515
name: str = "update_belief"
1616
args: dict = {
@@ -39,8 +39,7 @@ def execute(self, key: str, value: str) -> str:
3939

4040

4141
class RetrieveBelief(BaseAction):
42-
class Config:
43-
arbitrary_types_allowed = True
42+
model_config = ConfigDict(arbitrary_types_allowed=True)
4443

4544
name: str = "retrieve_belief"
4645
args: dict = {

src/sherpa_ai/actions/context_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
class ContextSearch(BaseRetrievalAction):
2323
role_description: str
2424
task: str
25-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
25+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
2626
description: str = SEARCH_SUMMARY_DESCRIPTION
27-
_context: Any
27+
_context: Any = None
2828

2929
# Override the name and args from BaseAction
3030
name: str = "Context Search"

src/sherpa_ai/actions/deliberation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class Deliberation(BaseAction):
2121
# TODO: Make a version of Deliberation action that considers the context
2222
role_description: str
23-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
23+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
2424
description: str = DELIBERATION_DESCRIPTION
2525

2626
# Override the name and args from BaseAction

src/sherpa_ai/actions/google_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
class GoogleSearch(BaseRetrievalAction):
3535
role_description: str
3636
task: str
37-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
37+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
3838
description: str = SEARCH_SUMMARY_DESCRIPTION
3939
config: AgentConfig = AgentConfig()
40-
_search_tool: Any
40+
_search_tool: Any = None
4141

4242
# Override the name and args from BaseAction
4343
name: str = "Google Search"

src/sherpa_ai/actions/planning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def from_dict(cls, data):
107107

108108

109109
class TaskPlanning(BaseAction):
110-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
110+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
111111
num_steps: int = 5
112112
prompt: str = PLANNING_PROMPT
113113
revision_prompt: str = REVISION_PROMPT

src/sherpa_ai/actions/synthesize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
class SynthesizeOutput(BaseAction):
3535
role_description: str
36-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
36+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
3737
description: str = SYNTHESIZE_DESCRIPTION
3838
add_citation: bool = False
3939

src/sherpa_ai/actions/utils/refinement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def refinement(self, documents: list[str], **kwargs) -> str:
3535

3636

3737
class RefinementByQuery(BaseRefinement):
38-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
38+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
3939
description: str = SEARCH_SUMMARY_DESCRIPTION
4040
k: int = 3
4141

@@ -51,7 +51,7 @@ def refinement(self, documents: list[str], query: str) -> list[str]:
5151

5252

5353
class RefinementBySentence(BaseRefinement):
54-
llm: Any # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
54+
llm: Any = None # The BaseLanguageModel from LangChain is not compatible with Pydantic 2 yet
5555
description: str = SEARCH_SUMMARY_DESCRIPTION_SENT
5656

5757
def refinement(self, documents: list[str], query: str) -> list[str]:

src/sherpa_ai/actions/utils/reranking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def rerank(self, documents: list[str], **kwargs) -> str:
2121

2222

2323
class RerankingByQuery(BaseReranking):
24-
embeddings: Any # takes an Embedding Object from LangChain, use Any since it is not compatible with Pydantic 2 yet
24+
embeddings: Any = None # takes an Embedding Object from LangChain, use Any since it is not compatible with Pydantic 2 yet
2525
distance_metric: Callable[[ArrayLike, ArrayLike], float] = cosine_similarity
2626

2727
def rerank(self, documents: list[str], query: str) -> str:

0 commit comments

Comments
 (0)