aiagents4pharma 1.16.0__tar.gz → 1.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/PKG-INFO +1 -1
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/__init__.py +1 -1
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/agents/main_agent.py +36 -15
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/agents/s2_agent.py +38 -29
- {aiagents4pharma-1.16.0/aiagents4pharma/talk2scholars/config → aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs}/__init__.py +3 -1
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/__init__.py +5 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/talk2scholars/__init__.py +6 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/default.yaml +39 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/default.yaml +68 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/app/__init__.py +5 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/app/frontend/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/app/frontend/default.yaml +33 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/config.yaml +8 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/__init__.py +7 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/default.yaml +19 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/search/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/search/default.yaml +19 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/__init__.py +3 -0
- aiagents4pharma-1.17.0/aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/default.yaml +20 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tests/test_langgraph.py +71 -54
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/s2/multi_paper_rec.py +13 -5
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/s2/search.py +9 -3
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/s2/single_paper_rec.py +13 -7
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma.egg-info/PKG-INFO +1 -1
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma.egg-info/SOURCES.txt +18 -2
- aiagents4pharma-1.17.0/pyproject.toml +86 -0
- aiagents4pharma-1.17.0/release_version.txt +1 -0
- aiagents4pharma-1.16.0/aiagents4pharma/talk2scholars/config/config.py +0 -110
- aiagents4pharma-1.16.0/pyproject.toml +0 -76
- aiagents4pharma-1.16.0/release_version.txt +0 -1
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/LICENSE +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/README.md +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/config.yaml +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/agents/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/default.yaml +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/tools/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/tools/ask_question/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/tools/ask_question/default.yaml +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/tools/get_annotation/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/configs/talk2biomodels/tools/get_annotation/default.yaml +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/agents/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/agents/t2b_agent.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/api/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/api/kegg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/api/ols.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/api/uniprot.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/models/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/models/basico_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/models/sys_bio_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/states/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_api.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_ask_question.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_basico_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_get_annotation.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_integration.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_param_scan.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_query_article.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_search_models.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_simulate_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_steady_state.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/ask_question.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/custom_plotter.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/get_annotation.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/load_arguments.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/load_biomodel.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/parameter_scan.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/query_article.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/search_models.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/simulate_model.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2biomodels/tools/steady_state.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/agents/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/agents/scp_agent.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/states/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/states/state_talk2cells.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/tools/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_sentencetransformer.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/agents/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/state/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/state/state_talk2scholars.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tests/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/s2/__init__.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/tools/s2/display_results.py +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma.egg-info/dependency_links.txt +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma.egg-info/requires.txt +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma.egg-info/top_level.txt +0 -0
- {aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: aiagents4pharma
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.17.0
|
4
4
|
Summary: AI Agents for drug discovery, drug development, and other pharmaceutical R&D
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
{aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/agents/main_agent.py
RENAMED
@@ -5,8 +5,8 @@ Main agent for the talk2scholars app.
|
|
5
5
|
"""
|
6
6
|
|
7
7
|
import logging
|
8
|
-
from typing import Literal
|
9
|
-
|
8
|
+
from typing import Literal, Any
|
9
|
+
import hydra
|
10
10
|
from langchain_core.language_models.chat_models import BaseChatModel
|
11
11
|
from langchain_core.messages import AIMessage
|
12
12
|
from langchain_openai import ChatOpenAI
|
@@ -14,27 +14,26 @@ from langgraph.checkpoint.memory import MemorySaver
|
|
14
14
|
from langgraph.graph import END, START, StateGraph
|
15
15
|
from langgraph.types import Command
|
16
16
|
from ..agents import s2_agent
|
17
|
-
from ..config.config import config
|
18
17
|
from ..state.state_talk2scholars import Talk2Scholars
|
19
18
|
|
20
19
|
logging.basicConfig(level=logging.INFO)
|
21
20
|
logger = logging.getLogger(__name__)
|
22
21
|
|
23
|
-
load_dotenv()
|
24
22
|
|
25
|
-
def make_supervisor_node(llm: BaseChatModel) -> str:
|
23
|
+
def make_supervisor_node(llm: BaseChatModel, cfg: Any) -> str:
|
26
24
|
"""
|
27
25
|
Creates a supervisor node following LangGraph patterns.
|
28
26
|
|
29
27
|
Args:
|
30
28
|
llm (BaseChatModel): The language model to use for generating responses.
|
29
|
+
cfg (Any): The configuration object.
|
31
30
|
|
32
31
|
Returns:
|
33
32
|
str: The supervisor node function.
|
34
33
|
"""
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def supervisor_node(
|
35
|
+
state: Talk2Scholars,
|
36
|
+
) -> Command[Literal["s2_agent", "__end__"]]:
|
38
37
|
"""
|
39
38
|
Supervisor node that routes to appropriate sub-agents.
|
40
39
|
|
@@ -44,9 +43,13 @@ def make_supervisor_node(llm: BaseChatModel) -> str:
|
|
44
43
|
Returns:
|
45
44
|
Command[Literal["s2_agent", "__end__"]]: The command to execute next.
|
46
45
|
"""
|
47
|
-
logger.info(
|
46
|
+
logger.info(
|
47
|
+
"Supervisor node called - Messages count: %d, Current Agent: %s",
|
48
|
+
len(state["messages"]),
|
49
|
+
state.get("current_agent", "None"),
|
50
|
+
)
|
48
51
|
|
49
|
-
messages = [{"role": "system", "content":
|
52
|
+
messages = [{"role": "system", "content": cfg.state_modifier}] + state[
|
50
53
|
"messages"
|
51
54
|
]
|
52
55
|
response = llm.invoke(messages)
|
@@ -81,7 +84,8 @@ def make_supervisor_node(llm: BaseChatModel) -> str:
|
|
81
84
|
|
82
85
|
return supervisor_node
|
83
86
|
|
84
|
-
|
87
|
+
|
88
|
+
def get_app(thread_id: str, llm_model="gpt-4o-mini") -> StateGraph:
|
85
89
|
"""
|
86
90
|
Returns the langraph app with hierarchical structure.
|
87
91
|
|
@@ -91,6 +95,16 @@ def get_app(thread_id: str, llm_model ='gpt-4o-mini') -> StateGraph:
|
|
91
95
|
Returns:
|
92
96
|
The compiled langraph app.
|
93
97
|
"""
|
98
|
+
|
99
|
+
# Load hydra configuration
|
100
|
+
logger.log(logging.INFO, "Load Hydra configuration for Talk2Scholars main agent.")
|
101
|
+
with hydra.initialize(version_base=None, config_path="../../configs"):
|
102
|
+
cfg = hydra.compose(
|
103
|
+
config_name="config", overrides=["agents/talk2scholars/main_agent=default"]
|
104
|
+
)
|
105
|
+
cfg = cfg.agents.talk2scholars.main_agent
|
106
|
+
logger.info("Hydra configuration loaded with values: %s", cfg)
|
107
|
+
|
94
108
|
def call_s2_agent(state: Talk2Scholars) -> Command[Literal["__end__"]]:
|
95
109
|
"""
|
96
110
|
Node for calling the S2 agent.
|
@@ -101,10 +115,10 @@ def get_app(thread_id: str, llm_model ='gpt-4o-mini') -> StateGraph:
|
|
101
115
|
Returns:
|
102
116
|
Command[Literal["__end__"]]: The command to execute next.
|
103
117
|
"""
|
104
|
-
logger.info("Calling S2 agent")
|
118
|
+
logger.info("Calling S2 agent with state: %s", state)
|
105
119
|
app = s2_agent.get_app(thread_id, llm_model)
|
106
120
|
response = app.invoke(state)
|
107
|
-
logger.info("S2 agent completed")
|
121
|
+
logger.info("S2 agent completed with response: %s", response)
|
108
122
|
return Command(
|
109
123
|
goto=END,
|
110
124
|
update={
|
@@ -114,10 +128,17 @@ def get_app(thread_id: str, llm_model ='gpt-4o-mini') -> StateGraph:
|
|
114
128
|
"current_agent": "s2_agent",
|
115
129
|
},
|
116
130
|
)
|
117
|
-
|
131
|
+
|
132
|
+
logger.log(
|
133
|
+
logging.INFO,
|
134
|
+
"Using OpenAI model %s with temperature %s",
|
135
|
+
llm_model,
|
136
|
+
cfg.temperature
|
137
|
+
)
|
138
|
+
llm = ChatOpenAI(model=llm_model, temperature=cfg.temperature)
|
118
139
|
workflow = StateGraph(Talk2Scholars)
|
119
140
|
|
120
|
-
supervisor = make_supervisor_node(llm)
|
141
|
+
supervisor = make_supervisor_node(llm, cfg)
|
121
142
|
workflow.add_node("supervisor", supervisor)
|
122
143
|
workflow.add_node("s2_agent", call_s2_agent)
|
123
144
|
|
{aiagents4pharma-1.16.0 → aiagents4pharma-1.17.0}/aiagents4pharma/talk2scholars/agents/s2_agent.py
RENAMED
@@ -1,56 +1,65 @@
|
|
1
|
-
|
1
|
+
# /usr/bin/env python3
|
2
2
|
|
3
|
-
|
3
|
+
"""
|
4
4
|
Agent for interacting with Semantic Scholar
|
5
|
-
|
5
|
+
"""
|
6
6
|
|
7
7
|
import logging
|
8
|
-
|
8
|
+
import hydra
|
9
9
|
from langchain_openai import ChatOpenAI
|
10
10
|
from langgraph.graph import START, StateGraph
|
11
|
-
from langgraph.prebuilt import create_react_agent
|
11
|
+
from langgraph.prebuilt import create_react_agent, ToolNode
|
12
12
|
from langgraph.checkpoint.memory import MemorySaver
|
13
|
-
from ..config.config import config
|
14
13
|
from ..state.state_talk2scholars import Talk2Scholars
|
15
|
-
|
16
|
-
from ..tools.s2.
|
17
|
-
from ..tools.s2.
|
18
|
-
|
19
|
-
|
14
|
+
from ..tools.s2.search import search_tool as s2_search
|
15
|
+
from ..tools.s2.display_results import display_results as s2_display
|
16
|
+
from ..tools.s2.single_paper_rec import (
|
17
|
+
get_single_paper_recommendations as s2_single_rec,
|
18
|
+
)
|
19
|
+
from ..tools.s2.multi_paper_rec import get_multi_paper_recommendations as s2_multi_rec
|
20
20
|
|
21
|
-
load_dotenv()
|
22
21
|
|
23
22
|
# Initialize logger
|
24
23
|
logging.basicConfig(level=logging.INFO)
|
25
24
|
logger = logging.getLogger(__name__)
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
|
27
|
+
def get_app(uniq_id, llm_model="gpt-4o-mini"):
|
28
|
+
"""
|
29
29
|
This function returns the langraph app.
|
30
|
-
|
30
|
+
"""
|
31
|
+
|
31
32
|
def agent_s2_node(state: Talk2Scholars):
|
32
|
-
|
33
|
+
"""
|
33
34
|
This function calls the model.
|
34
|
-
|
35
|
+
"""
|
35
36
|
logger.log(logging.INFO, "Creating Agent_S2 node with thread_id %s", uniq_id)
|
36
37
|
response = model.invoke(state, {"configurable": {"thread_id": uniq_id}})
|
37
38
|
return response
|
38
39
|
|
40
|
+
# Load hydra configuration
|
41
|
+
logger.log(logging.INFO, "Load Hydra configuration for Talk2Scholars S2 agent.")
|
42
|
+
with hydra.initialize(version_base=None, config_path="../../configs"):
|
43
|
+
cfg = hydra.compose(
|
44
|
+
config_name="config", overrides=["agents/talk2scholars/s2_agent=default"]
|
45
|
+
)
|
46
|
+
cfg = cfg.agents.talk2scholars.s2_agent
|
47
|
+
|
39
48
|
# Define the tools
|
40
|
-
tools = [
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
tools = ToolNode([s2_search, s2_display, s2_single_rec, s2_multi_rec])
|
50
|
+
|
51
|
+
# Define the model
|
52
|
+
logger.log(logging.INFO, "Using OpenAI model %s", llm_model)
|
53
|
+
llm = ChatOpenAI(model=llm_model, temperature=cfg.temperature)
|
44
54
|
|
45
|
-
# Create the
|
46
|
-
llm = ChatOpenAI(model=llm_model, temperature=0)
|
55
|
+
# Create the agent
|
47
56
|
model = create_react_agent(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
llm,
|
58
|
+
tools=tools,
|
59
|
+
state_schema=Talk2Scholars,
|
60
|
+
state_modifier=cfg.s2_agent,
|
61
|
+
checkpointer=MemorySaver(),
|
62
|
+
)
|
54
63
|
|
55
64
|
# Define a new graph
|
56
65
|
workflow = StateGraph(Talk2Scholars)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
_target_: agents.main_agent.get_app
|
2
|
+
openai_api_key: ${oc.env:OPENAI_API_KEY}
|
3
|
+
openai_llms:
|
4
|
+
- "gpt-4o-mini"
|
5
|
+
- "gpt-4-turbo"
|
6
|
+
- "gpt-3.5-turbo"
|
7
|
+
temperature: 0
|
8
|
+
main_agent: >
|
9
|
+
"You are a supervisory AI agent that routes user queries to specialized tools.\n"
|
10
|
+
"Your task is to select the most appropriate tool based on the user's request.\n\n"
|
11
|
+
"Available tools and their capabilities:\n\n"
|
12
|
+
"1. semantic_scholar_agent:\n"
|
13
|
+
" - Search for academic papers and research\n"
|
14
|
+
" - Get paper recommendations\n"
|
15
|
+
" - Find similar papers\n"
|
16
|
+
" USE FOR: Any queries about finding papers, academic research, "
|
17
|
+
"or getting paper recommendations\n\n"
|
18
|
+
"ROUTING GUIDELINES:\n\n"
|
19
|
+
"ALWAYS route to semantic_scholar_agent for:\n"
|
20
|
+
"- Finding academic papers\n"
|
21
|
+
"- Searching research topics\n"
|
22
|
+
"- Getting paper recommendations\n"
|
23
|
+
"- Finding similar papers\n"
|
24
|
+
"- Any query about academic literature\n\n"
|
25
|
+
"Approach:\n"
|
26
|
+
"1. Identify the core need in the user's query\n"
|
27
|
+
"2. Select the most appropriate tool based on the guidelines above\n"
|
28
|
+
"3. If unclear, ask for clarification\n"
|
29
|
+
"4. For multi-step tasks, focus on the immediate next step\n\n"
|
30
|
+
"Remember:\n"
|
31
|
+
"- Be decisive in your tool selection\n"
|
32
|
+
"- Focus on the immediate task\n"
|
33
|
+
"- Default to semantic_scholar_agent for any paper-finding tasks\n"
|
34
|
+
"- Ask for clarification if the request is ambiguous\n\n"
|
35
|
+
"When presenting paper search results, always use this exact format:\n\n"
|
36
|
+
"Remember to:\n"
|
37
|
+
"- To always add the url\n"
|
38
|
+
"- Put URLs on the title line itself as markdown\n"
|
39
|
+
"- Maintain consistent spacing and formatting"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
_target_: agents.s2_agent.get_app
|
2
|
+
openai_api_key: ${oc.env:OPENAI_API_KEY}
|
3
|
+
openai_llms:
|
4
|
+
- "gpt-4o-mini"
|
5
|
+
- "gpt-4-turbo"
|
6
|
+
- "gpt-3.5-turbo"
|
7
|
+
temperature: 0
|
8
|
+
s2_agent: >
|
9
|
+
"You are a specialized academic research assistant with access to the following tools:\n\n"
|
10
|
+
"1. search_papers:\n"
|
11
|
+
" USE FOR: General paper searches\n"
|
12
|
+
" - Enhances search terms automatically\n"
|
13
|
+
" - Adds relevant academic keywords\n"
|
14
|
+
" - Focuses on recent research when appropriate\n\n"
|
15
|
+
"2. get_single_paper_recommendations:\n"
|
16
|
+
" USE FOR: Finding papers similar to a specific paper\n"
|
17
|
+
" - Takes a single paper ID\n"
|
18
|
+
" - Returns related papers\n\n"
|
19
|
+
"3. get_multi_paper_recommendations:\n"
|
20
|
+
" USE FOR: Finding papers similar to multiple papers\n"
|
21
|
+
" - Takes multiple paper IDs\n"
|
22
|
+
" - Finds papers related to all inputs\n\n"
|
23
|
+
"GUIDELINES:\n\n"
|
24
|
+
"For paper searches:\n"
|
25
|
+
"- Enhance search terms with academic language\n"
|
26
|
+
"- Include field-specific terminology\n"
|
27
|
+
'- Add "recent" or "latest" when appropriate\n'
|
28
|
+
"- Keep queries focused and relevant\n\n"
|
29
|
+
"For paper recommendations:\n"
|
30
|
+
"- Identify paper IDs (40-character hexadecimal strings)\n"
|
31
|
+
"- Use single_paper_recommendations for one ID\n"
|
32
|
+
"- Use multi_paper_recommendations for multiple IDs\n\n"
|
33
|
+
"Best practices:\n"
|
34
|
+
"1. Start with a broad search if no paper IDs are provided\n"
|
35
|
+
"2. Look for paper IDs in user input\n"
|
36
|
+
"3. Enhance search terms for better results\n"
|
37
|
+
"4. Consider the academic context\n"
|
38
|
+
"5. Be prepared to refine searches based on feedback\n\n"
|
39
|
+
"Remember:\n"
|
40
|
+
"- Always select the most appropriate tool\n"
|
41
|
+
"- Enhance search queries naturally\n"
|
42
|
+
"- Consider academic context\n"
|
43
|
+
"- Focus on delivering relevant results\n\n"
|
44
|
+
"IMPORTANT GUIDELINES FOR PAPER RECOMMENDATIONS:\n\n"
|
45
|
+
"For Multiple Papers:\n"
|
46
|
+
"- When getting recommendations for multiple papers, always use "
|
47
|
+
"get_multi_paper_recommendations tool\n"
|
48
|
+
"- DO NOT call get_single_paper_recommendations multiple times\n"
|
49
|
+
"- Always pass all paper IDs in a single call to get_multi_paper_recommendations\n"
|
50
|
+
'- Use for queries like "find papers related to both/all papers" or '
|
51
|
+
'"find similar papers to these papers"\n\n'
|
52
|
+
"For Single Paper:\n"
|
53
|
+
"- Use get_single_paper_recommendations when focusing on one specific paper\n"
|
54
|
+
"- Pass only one paper ID at a time\n"
|
55
|
+
'- Use for queries like "find papers similar to this paper" or '
|
56
|
+
'"get recommendations for paper X"\n'
|
57
|
+
"- Do not use for multiple papers\n\n"
|
58
|
+
"Examples:\n"
|
59
|
+
'- For "find related papers for both papers":\n'
|
60
|
+
" ✓ Use get_multi_paper_recommendations with both paper IDs\n"
|
61
|
+
" × Don't make multiple calls to get_single_paper_recommendations\n\n"
|
62
|
+
'- For "find papers related to the first paper":\n'
|
63
|
+
" ✓ Use get_single_paper_recommendations with just that paper's ID\n"
|
64
|
+
" × Don't use get_multi_paper_recommendations\n\n"
|
65
|
+
"Remember:\n"
|
66
|
+
"- Be precise in identifying which paper ID to use for single recommendations\n"
|
67
|
+
"- Don't reuse previous paper IDs unless specifically requested\n"
|
68
|
+
"- For fresh paper recommendations, always use the original paper ID"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# # Page configuration
|
2
|
+
# page:
|
3
|
+
# title: "Talk2Scholars"
|
4
|
+
# icon: "🤖"
|
5
|
+
# layout: "wide"
|
6
|
+
|
7
|
+
# Available LLM models
|
8
|
+
llm_models:
|
9
|
+
- "gpt-4o-mini"
|
10
|
+
- "gpt-4-turbo"
|
11
|
+
- "gpt-3.5-turbo"
|
12
|
+
# # Chat UI configuration
|
13
|
+
# chat:
|
14
|
+
# assistant_avatar: "🤖"
|
15
|
+
# user_avatar: "👩🏻💻"
|
16
|
+
# input_placeholder: "Say something ..."
|
17
|
+
# spinner_text: "Fetching response ..."
|
18
|
+
|
19
|
+
# # Feedback configuration
|
20
|
+
# feedback:
|
21
|
+
# type: "thumbs"
|
22
|
+
# text_label: "[Optional] Please provide an explanation"
|
23
|
+
# success_message: "Your feedback is on its way to the developers. Thank you!"
|
24
|
+
# success_icon: "🚀"
|
25
|
+
|
26
|
+
# # Layout configuration
|
27
|
+
# layout:
|
28
|
+
# column_ratio: [3, 7] # Ratio for main_col1 and main_col2
|
29
|
+
# chat_container_height: 575
|
30
|
+
# sidebar_container_height: 500
|
31
|
+
#
|
32
|
+
# # Project name prefix
|
33
|
+
# project_name_prefix: "Talk2Scholars-"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
api_endpoint: "https://api.semanticscholar.org/recommendations/v1/papers"
|
2
|
+
default_limit: 2
|
3
|
+
request_timeout: 10
|
4
|
+
api_fields:
|
5
|
+
- "paperId"
|
6
|
+
- "title"
|
7
|
+
- "abstract"
|
8
|
+
- "year"
|
9
|
+
- "authors"
|
10
|
+
- "citationCount"
|
11
|
+
- "url"
|
12
|
+
|
13
|
+
# Default headers and params
|
14
|
+
headers:
|
15
|
+
Content-Type: "application/json"
|
16
|
+
|
17
|
+
recommendation_params:
|
18
|
+
limit: ${.default_limit}
|
19
|
+
fields: ${.api_fields}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
api_endpoint: "https://api.semanticscholar.org/graph/v1/paper/search"
|
2
|
+
default_limit: 2
|
3
|
+
request_timeout: 10
|
4
|
+
api_fields:
|
5
|
+
- "paperId"
|
6
|
+
- "title"
|
7
|
+
- "abstract"
|
8
|
+
- "year"
|
9
|
+
- "authors"
|
10
|
+
- "citationCount"
|
11
|
+
- "url"
|
12
|
+
# Commented fields that could be added later if needed
|
13
|
+
# - "publicationTypes"
|
14
|
+
# - "openAccessPdf"
|
15
|
+
|
16
|
+
# Default search parameters
|
17
|
+
search_params:
|
18
|
+
limit: ${.default_limit} # Reference to the default_limit above
|
19
|
+
fields: ${.api_fields} # Reference to the api_fields above
|
@@ -0,0 +1,20 @@
|
|
1
|
+
api_endpoint: "https://api.semanticscholar.org/recommendations/v1/papers/forpaper"
|
2
|
+
default_limit: 2
|
3
|
+
request_timeout: 10
|
4
|
+
api_fields:
|
5
|
+
- "paperId"
|
6
|
+
- "title"
|
7
|
+
- "abstract"
|
8
|
+
- "year"
|
9
|
+
- "authors"
|
10
|
+
- "citationCount"
|
11
|
+
- "url"
|
12
|
+
# Commented fields that could be added later if needed
|
13
|
+
# - "publicationTypes"
|
14
|
+
# - "openAccessPdf"
|
15
|
+
|
16
|
+
# Default recommendation parameters
|
17
|
+
recommendation_params:
|
18
|
+
limit: ${.default_limit} # Reference to the default_limit above
|
19
|
+
fields: ${.api_fields} # Reference to the api_fields above
|
20
|
+
from_pool: "all-cs" # Using all-cs pool as specified in docs
|