Skip to content

Commit 085c973

Browse files
authored
Merge pull request #169 from HolobiomicsLab/dev_madina
Dev madina
2 parents 10e9a55 + 5384796 commit 085c973

18 files changed

Lines changed: 682 additions & 604 deletions

app/core/agents/enpkg/tool_chemicals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from langchain_openai import OpenAIEmbeddings
1717

1818

19-
from langchain.pydantic_v1 import BaseModel, Field
19+
from pydantic import BaseModel, Field
2020
from langchain.tools import BaseTool
2121
from typing import Optional
2222

@@ -47,7 +47,7 @@ class ChemicalResolver(BaseTool):
4747
Dict[str, str]: a dictionary that contains the output chemical name and corresponding NPC Class URI.
4848
"""
4949

50-
args_schema = ChemicalInput
50+
args_schema: type[BaseModel] = ChemicalInput
5151
csv_data: List[Document] = None
5252
retriever: Any = None
5353
openai_key: str = None

app/core/agents/enpkg/tool_smiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import requests
22

33
from langchain.tools import BaseTool
4-
from langchain.pydantic_v1 import BaseModel, Field
4+
from pydantic import BaseModel, Field
55

66
from typing import Optional
77

@@ -36,7 +36,7 @@ class SMILESResolver(BaseTool):
3636
smiles_string = "CCC12CCCN3C1C4(CC3)C(CC2)NC5=CC=CC=C45"
3737
inchikey = _run(smiles_string)
3838
"""
39-
args_schema = SMILESInput
39+
args_schema: type[BaseModel] = SMILESInput
4040
openai_key: str = None
4141

4242
def __init__(self, openai_key: str = None):

app/core/agents/enpkg/tool_target.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77

8-
from langchain.pydantic_v1 import BaseModel, Field
8+
from pydantic import BaseModel, Field
99

1010
from typing import Optional
1111

@@ -38,7 +38,7 @@ class TargetResolver(BaseTool):
3838
str: A string containing the ChEMBLTarget notation.
3939
"""
4040

41-
args_schema = TargetInput
41+
args_schema: type[BaseModel] = TargetInput
4242
openai_key: str = None
4343

4444
def __init__(self, openai_key: str = None):

app/core/agents/enpkg/tool_taxon.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Optional
1+
from typing import ClassVar, Optional
22

33
from SPARQLWrapper import JSON, SPARQLWrapper
44

55

6-
from langchain.pydantic_v1 import BaseModel, Field
6+
from pydantic import BaseModel, Field
77

88
from typing import Optional
99

@@ -34,10 +34,10 @@ class TaxonResolver(BaseTool):
3434
Returns:
3535
str: A string that contains the Wikidata IRI if found, otherwise `None`.
3636
"""
37-
args_schema = TaxonInput
37+
args_schema: type[BaseModel] = TaxonInput
3838

39-
ENDPOINT_URL = "https://query.wikidata.org/sparql"
40-
PREFIXES = """
39+
ENDPOINT_URL: ClassVar[str] = "https://query.wikidata.org/sparql"
40+
PREFIXES: ClassVar[str] = """
4141
PREFIX prov: <http://www.w3.org/ns/prov#>
4242
PREFIX pr: <http://www.wikidata.org/prop/reference/>
4343
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

app/core/agents/entry/tool_filesparser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
import pandas as pd
33
from datetime import datetime
44
from langchain.tools import BaseTool
5-
from langchain.pydantic_v1 import BaseModel, Field
5+
from pydantic import BaseModel, Field
66
from pathlib import Path
77
from app.core.session import setup_logger, create_user_session
88

99
logger = setup_logger(__name__)
1010

11+
class FileAnalyzerInput(BaseModel):
12+
"""Input schema for FileAnalyzer - no input fields required."""
13+
pass
14+
1115
class FileAnalyzer(BaseTool):
1216
name: str = "FILE_ANALYZER"
1317
description: str = """
1418
Analyzes files in a specified directory and provides a summary of their content.
1519
"""
16-
args_schema = BaseModel # Using BaseModel directly since no specific input fields are necessary
20+
args_schema: type[BaseModel] = FileAnalyzerInput
1721
folder_path: Path = None
1822
openai_key: str = None
1923
session_id: str = None

app/core/agents/interpreter/tool_interpreter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
from codeinterpreterapi import CodeInterpreterSession, File, settings
5-
from langchain.pydantic_v1 import BaseModel, Field
5+
from pydantic import BaseModel, Field
66
from langchain.tools import BaseTool
77

88
from typing import Optional
@@ -37,7 +37,7 @@ class Interpreter(BaseTool):
3737
Returns:
3838
None: Outputs the response after interpreting files.
3939
"""
40-
args_schema = InterpreterInput
40+
args_schema: type[BaseModel] = InterpreterInput
4141
openai_key: str = None
4242
session_id: str = None
4343

app/core/agents/interpreter/tool_spectrum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22
from pathlib import Path
33
from typing import Any, Dict, Optional, Union
4-
from langchain.pydantic_v1 import BaseModel, Field
4+
from pydantic import BaseModel, Field
55
from langchain.tools import BaseTool
66
from langchain.callbacks.manager import CallbackManagerForToolRun
77
from app.core.memory.database_manager import tools_database
@@ -29,7 +29,7 @@ class SpectrumPlotter(BaseTool):
2929
Returns:
3030
An url with spectrum plot.
3131
"""
32-
args_schema = SpectrumPlotInput
32+
args_schema: type[BaseModel] = SpectrumPlotInput
3333
session_id: str = None
3434
openai_key: str = None
3535
def __init__(self, openai_key: str, session_id: str):

app/core/agents/sparql/tool_merge_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from langchain.pydantic_v1 import BaseModel, Field
1+
from pydantic import BaseModel, Field
22
from langchain.tools import BaseTool
33

44
from typing import Optional
@@ -40,7 +40,7 @@ class OutputMerger(BaseTool):
4040
output_file_path (str): The path to the temporary CSV file where the output with common Wikidata IDs will be saved.
4141
4242
"""
43-
args_schema = MergerInput
43+
args_schema: type[BaseModel] = MergerInput
4444
session_id: str = None
4545

4646
def __init__(self, session_id: str):

app/core/agents/sparql/tool_sparql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from langchain.chains.llm import LLMChain
1212
from langchain_core.prompts.prompt import PromptTemplate
13-
from langchain.pydantic_v1 import BaseModel, Field
13+
from pydantic import BaseModel, Field
1414
from langchain.tools import BaseTool
1515
from langchain_community.vectorstores import FAISS
1616
from langchain_openai import OpenAIEmbeddings
@@ -207,8 +207,8 @@ class SparqlInput(BaseModel):
207207

208208
##Question-answering against an RDF or OWL graph by generating SPARQL statements.
209209
class GraphSparqlQAChain(BaseTool):
210-
name = "SPARQL_QUERY_RUNNER"
211-
description = """
210+
name: str = "SPARQL_QUERY_RUNNER"
211+
description: str = """
212212
The agent resolve the user's question by querying the knowledge graph database.
213213
The two inputs should be a string containing the user's question and a string containing the resolved entities in the question.
214214
@@ -226,10 +226,10 @@ class GraphSparqlQAChain(BaseTool):
226226
227227
"""
228228
verbose: bool = True
229-
args_schema = SparqlInput
229+
args_schema: type[BaseModel] = SparqlInput
230230
sparql_generation_select_chain: LLMChain = None
231231
sparql_improvement_chain: LLMChain = None
232-
requires_params = True
232+
requires_params: bool = True
233233
graph: RdfGraph = None
234234
session_id: str = None
235235

app/core/agents/sparql/tool_wikidata_query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import csv
44
import tempfile
55
from pathlib import Path
6-
from typing import List, Optional
6+
from typing import ClassVar, List, Optional
77

88
from langchain_core.tools import tool
99
from SPARQLWrapper import JSON, SPARQLWrapper
1010

1111
from app.core.session import setup_logger, create_user_session
12-
from langchain.pydantic_v1 import BaseModel, Field
12+
from pydantic import BaseModel, Field
1313
from langchain.tools import BaseTool
1414
from langchain.callbacks.manager import (
1515
CallbackManagerForToolRun,
@@ -33,10 +33,10 @@ class WikidataStructureSearch(BaseTool):
3333
Returns:
3434
str: A string that contains the path to the file with Wikidata IRIs if found, otherwise `None`.
3535
"""
36-
args_schema = WikidataInput
36+
args_schema: type[BaseModel] = WikidataInput
3737

38-
ENDPOINT_URL = "https://query.wikidata.org/sparql"
39-
PREFIXES = """
38+
ENDPOINT_URL: ClassVar[str] = "https://query.wikidata.org/sparql"
39+
PREFIXES: ClassVar[str] = """
4040
PREFIX wd: <http://www.wikidata.org/entity/>
4141
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
4242
"""

0 commit comments

Comments
 (0)