Upload 4 files
Browse files- src/agentcore/constants.py +157 -151
- src/agentcore/intents_library.py +30 -9
- src/agentcore/intents_search.py +3 -3
- src/agentcore/rendering.py +41 -43
src/agentcore/constants.py
CHANGED
|
@@ -9,7 +9,7 @@ import time
|
|
| 9 |
import uuid
|
| 10 |
from datetime import datetime
|
| 11 |
from typing import Any, Dict, List, Literal, Optional, Tuple
|
| 12 |
-
from urllib.parse import quote
|
| 13 |
|
| 14 |
import httpx
|
| 15 |
from pydantic import BaseModel, ConfigDict, Field
|
|
@@ -161,28 +161,33 @@ _GUARDRAIL = (
|
|
| 161 |
)
|
| 162 |
|
| 163 |
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
"IMPORTANT — URLS AND LINKS: "
|
| 166 |
"You must ONLY include URLs that are explicitly present in the context or "
|
| 167 |
"knowledge base provided to you, OR that appear in this fixed verified list of "
|
| 168 |
-
"KU Library URLs: "
|
| 169 |
-
"https://library.ku.ac.ae | "
|
| 170 |
-
"https://library.ku.ac.ae/hours | "
|
| 171 |
-
"https://library.ku.ac.ae/AskUs | "
|
| 172 |
-
"https://library.ku.ac.ae/ill/ | "
|
| 173 |
-
"https://library.ku.ac.ae/rooms/ | "
|
| 174 |
-
"https://library.ku.ac.ae/eresources | "
|
| 175 |
-
"https://library.ku.ac.ae/orcid | "
|
| 176 |
-
"https://library.ku.ac.ae/oa/ | "
|
| 177 |
-
"https://library.ku.ac.ae/alumni/ | "
|
| 178 |
-
"https://library.ku.ac.ae/med/ | "
|
| 179 |
-
"https://library.ku.ac.ae/requesttitle/ | "
|
| 180 |
-
"https://library.ku.ac.ae/google | "
|
| 181 |
-
"https://khazna.ku.ac.ae | "
|
| 182 |
-
"https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU | "
|
| 183 |
-
"https://khalifa.primo.exlibrisgroup.com/discovery/account?vid=971KUOSTAR_INST:KU§ion=overview | "
|
| 184 |
-
"https://kustar.libcal.com/calendar/events | "
|
| 185 |
-
"https://ku-library.github.io/researchbee/. "
|
| 186 |
"NEVER invent, guess, or construct URLs that are not in the above list or "
|
| 187 |
"explicitly present in the provided context. "
|
| 188 |
"When a relevant verified URL exists for your answer, ALWAYS include it as a "
|
|
@@ -638,184 +643,185 @@ Return ONLY valid JSON:
|
|
| 638 |
{{"corrected":"...","natural":"...","boolean":"(\"A\" OR \"B\") AND (\"C\" OR \"D\")","year_from":"","year_to":"","peer_reviewed":false,"open_access":false}}"""
|
| 639 |
|
| 640 |
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
|
|
|
| 650 |
"physics": [
|
| 651 |
-
("APS Journals",
|
| 652 |
-
("AIP Publishing",
|
| 653 |
-
("IOPScience",
|
| 654 |
("arXiv", "https://arxiv.org", "Open-access preprints in physics and maths."),
|
| 655 |
-
("ScienceDirect",
|
| 656 |
-
("Scopus",
|
| 657 |
],
|
| 658 |
"chemistry": [
|
| 659 |
-
("ACS Publications",
|
| 660 |
-
("SciFinder-n",
|
| 661 |
-
("Reaxys",
|
| 662 |
-
("RSC Journals",
|
| 663 |
-
("ScienceDirect",
|
| 664 |
-
("Scopus",
|
| 665 |
],
|
| 666 |
"chemical_engineering": [
|
| 667 |
-
("ScienceDirect",
|
| 668 |
-
("ACS Publications",
|
| 669 |
-
("SciFinder-n",
|
| 670 |
-
("Reaxys",
|
| 671 |
-
("Knovel",
|
| 672 |
-
("Scopus",
|
| 673 |
],
|
| 674 |
"computer_science": [
|
| 675 |
-
("ACM Digital Library",
|
| 676 |
-
("IEEE Xplore",
|
| 677 |
("arXiv", "https://arxiv.org", "Important preprint source for CS, AI, and ML."),
|
| 678 |
-
("INSPEC",
|
| 679 |
-
("ScienceDirect",
|
| 680 |
-
("Scopus",
|
| 681 |
],
|
| 682 |
"robotics": [
|
| 683 |
-
("IEEE Xplore",
|
| 684 |
-
("ACM Digital Library",
|
| 685 |
("arXiv", "https://arxiv.org", "Essential for current AI, robotics, and ML preprints."),
|
| 686 |
-
("INSPEC",
|
| 687 |
-
("ScienceDirect",
|
| 688 |
],
|
| 689 |
"electrical_engineering": [
|
| 690 |
-
("IEEE Xplore",
|
| 691 |
-
("INSPEC",
|
| 692 |
-
("ScienceDirect",
|
| 693 |
-
("ASTM Compass",
|
| 694 |
-
("Scopus",
|
| 695 |
],
|
| 696 |
"mechanical_engineering": [
|
| 697 |
-
("ASME Digital Library",
|
| 698 |
-
("ScienceDirect",
|
| 699 |
-
("Knovel",
|
| 700 |
-
("ASTM Compass",
|
| 701 |
-
("Scopus",
|
| 702 |
],
|
| 703 |
"civil_engineering": [
|
| 704 |
-
("ASCE Library",
|
| 705 |
-
("ICE Virtual Library",
|
| 706 |
-
("ASTM Compass",
|
| 707 |
-
("ScienceDirect",
|
| 708 |
-
("Knovel",
|
| 709 |
],
|
| 710 |
"aerospace": [
|
| 711 |
-
("AIAA",
|
| 712 |
-
("ASME Digital Library",
|
| 713 |
-
("ScienceDirect",
|
| 714 |
-
("IEEE Xplore",
|
| 715 |
-
("Scopus",
|
| 716 |
],
|
| 717 |
"petroleum": [
|
| 718 |
-
("OnePetro",
|
| 719 |
-
("EarthDoc",
|
| 720 |
-
("ScienceDirect",
|
| 721 |
-
("Knovel",
|
| 722 |
-
("Scopus",
|
| 723 |
],
|
| 724 |
"energy": [
|
| 725 |
-
("ScienceDirect",
|
| 726 |
-
("OnePetro",
|
| 727 |
-
("IEEE Xplore",
|
| 728 |
-
("Knovel",
|
| 729 |
-
("Scopus",
|
| 730 |
],
|
| 731 |
"mathematics": [
|
| 732 |
("MathSciNet", "https://mathscinet.ams.org", "Core mathematics review and discovery database."),
|
| 733 |
-
("SpringerLink",
|
| 734 |
-
("ScienceDirect",
|
| 735 |
-
("JSTOR",
|
| 736 |
("arXiv", "https://arxiv.org", "Preprints in mathematics, statistics, and data science."),
|
| 737 |
-
("Scopus",
|
| 738 |
],
|
| 739 |
"materials": [
|
| 740 |
-
("ScienceDirect",
|
| 741 |
-
("SpringerLink",
|
| 742 |
-
("AIP Publishing",
|
| 743 |
-
("IOPScience",
|
| 744 |
-
("Knovel",
|
| 745 |
-
("Scopus",
|
| 746 |
],
|
| 747 |
"nuclear": [
|
| 748 |
-
("ScienceDirect",
|
| 749 |
-
("AIP Publishing",
|
| 750 |
-
("Knovel",
|
| 751 |
-
("Scopus",
|
| 752 |
-
("Web of Science",
|
| 753 |
],
|
| 754 |
"quantum_computing": [
|
| 755 |
-
("IEEE Xplore",
|
| 756 |
-
("ACM Digital Library",
|
| 757 |
-
("APS Journals",
|
| 758 |
("arXiv", "https://arxiv.org", "Essential for current quantum computing preprints."),
|
| 759 |
-
("Scopus",
|
| 760 |
],
|
| 761 |
"biomedical": [
|
| 762 |
-
("PubMed",
|
| 763 |
-
("IEEE Xplore",
|
| 764 |
-
("Embase",
|
| 765 |
-
("ScienceDirect",
|
| 766 |
-
("Scopus",
|
| 767 |
],
|
| 768 |
"biology": [
|
| 769 |
-
("PubMed",
|
| 770 |
-
("ScienceDirect",
|
| 771 |
-
("Embase",
|
| 772 |
("PubMed Central", "https://www.ncbi.nlm.nih.gov/pmc", "Open full-text biomedical articles — no login required."),
|
| 773 |
-
("Scopus",
|
| 774 |
],
|
| 775 |
"medical": [
|
| 776 |
-
("PubMed
|
| 777 |
-
("Embase",
|
| 778 |
-
("CINAHL Ultimate",
|
| 779 |
-
("Cochrane Library",
|
| 780 |
-
("UpToDate",
|
| 781 |
-
("ClinicalKey Student",
|
| 782 |
],
|
| 783 |
"business": [
|
| 784 |
-
("Business Source Complete",
|
| 785 |
-
("Emerald Insight",
|
| 786 |
-
("ProQuest Databases",
|
| 787 |
-
("JSTOR",
|
| 788 |
-
("Scopus",
|
| 789 |
],
|
| 790 |
"earth_science": [
|
| 791 |
-
("GeoscienceWorld",
|
| 792 |
-
("EarthDoc",
|
| 793 |
-
("ScienceDirect",
|
| 794 |
-
("Scopus",
|
| 795 |
-
("Web of Science",
|
| 796 |
],
|
| 797 |
"environment": [
|
| 798 |
-
("ScienceDirect",
|
| 799 |
-
("ProQuest Databases",
|
| 800 |
-
("Web of Science",
|
| 801 |
-
("Scopus",
|
| 802 |
-
("Business Source Complete",
|
| 803 |
],
|
| 804 |
"engineering_management": [
|
| 805 |
-
("Scopus",
|
| 806 |
-
("Emerald Insight",
|
| 807 |
-
("ScienceDirect",
|
| 808 |
-
("Business Source Complete",
|
| 809 |
-
("ProQuest Databases",
|
| 810 |
],
|
| 811 |
"metrics": [
|
| 812 |
-
("Journal Citation Reports",
|
| 813 |
-
("Scopus / CiteScore",
|
| 814 |
-
("SciVal",
|
| 815 |
-
("Web of Science",
|
| 816 |
],
|
| 817 |
"theses": [
|
| 818 |
-
("ProQuest Dissertations & Theses Global",
|
| 819 |
("Khazna", "https://khazna.ku.ac.ae/", "KU institutional repository and research outputs."),
|
| 820 |
("PRIMO", "https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU", "Discovery for dissertations, theses, and KU holdings."),
|
| 821 |
],
|
|
@@ -824,13 +830,13 @@ _DB_SUBJECTS: Dict[str, List[Tuple[str, str, str]]] = {
|
|
| 824 |
|
| 825 |
_DB_GENERAL: List[Tuple[str, str, str]] = [
|
| 826 |
("PRIMO (KU Library Discovery)", "https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU", "Best starting point — search all KU books, articles, and journals."),
|
| 827 |
-
("Scopus",
|
| 828 |
-
("Web of Science",
|
| 829 |
-
("ScienceDirect",
|
| 830 |
-
("SpringerLink",
|
| 831 |
-
("ProQuest Databases",
|
| 832 |
-
("Emerald Insight",
|
| 833 |
-
("JSTOR",
|
| 834 |
]
|
| 835 |
|
| 836 |
|
|
|
|
| 9 |
import uuid
|
| 10 |
from datetime import datetime
|
| 11 |
from typing import Any, Dict, List, Literal, Optional, Tuple
|
| 12 |
+
from urllib.parse import quote
|
| 13 |
|
| 14 |
import httpx
|
| 15 |
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
| 161 |
)
|
| 162 |
|
| 163 |
|
| 164 |
+
FIXED_VERIFIED_URLS = (
|
| 165 |
+
"https://library.ku.ac.ae",
|
| 166 |
+
"https://library.ku.ac.ae/hours",
|
| 167 |
+
"https://library.ku.ac.ae/AskUs",
|
| 168 |
+
"https://library.ku.ac.ae/ill/",
|
| 169 |
+
"https://library.ku.ac.ae/rooms/",
|
| 170 |
+
"https://library.ku.ac.ae/eresources",
|
| 171 |
+
"https://library.ku.ac.ae/orcid",
|
| 172 |
+
"https://library.ku.ac.ae/oa/",
|
| 173 |
+
"https://library.ku.ac.ae/alumni/",
|
| 174 |
+
"https://library.ku.ac.ae/med/",
|
| 175 |
+
"https://library.ku.ac.ae/requesttitle/",
|
| 176 |
+
"https://library.ku.ac.ae/google",
|
| 177 |
+
"https://khazna.ku.ac.ae",
|
| 178 |
+
"https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU",
|
| 179 |
+
"https://khalifa.primo.exlibrisgroup.com/discovery/account?vid=971KUOSTAR_INST:KU§ion=overview",
|
| 180 |
+
"https://kustar.libcal.com/calendar/events",
|
| 181 |
+
"https://ku-library.github.io/researchbee/",
|
| 182 |
+
"mailto:libse@ku.ac.ae",
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
_URL_INSTRUCTION = (
|
| 187 |
"IMPORTANT — URLS AND LINKS: "
|
| 188 |
"You must ONLY include URLs that are explicitly present in the context or "
|
| 189 |
"knowledge base provided to you, OR that appear in this fixed verified list of "
|
| 190 |
+
"KU Library URLs: " + " | ".join(FIXED_VERIFIED_URLS) + ". "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
"NEVER invent, guess, or construct URLs that are not in the above list or "
|
| 192 |
"explicitly present in the provided context. "
|
| 193 |
"When a relevant verified URL exists for your answer, ALWAYS include it as a "
|
|
|
|
| 643 |
{{"corrected":"...","natural":"...","boolean":"(\"A\" OR \"B\") AND (\"C\" OR \"D\")","year_from":"","year_to":"","peer_reviewed":false,"open_access":false}}"""
|
| 644 |
|
| 645 |
|
| 646 |
+
OPENATHENS_REDIRECT_BASE = "https://go.openathens.net/redirector/ku.ac.ae?url="
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
def _openathens_url(target: str) -> str:
|
| 650 |
+
"""Build a KU OpenAthens redirect without double-encoding its target."""
|
| 651 |
+
from urllib.parse import quote as _quote
|
| 652 |
+
return OPENATHENS_REDIRECT_BASE + _quote(target, safe="")
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
_DB_SUBJECTS: Dict[str, List[Tuple[str, str, str]]] = {
|
| 656 |
"physics": [
|
| 657 |
+
("APS Journals", _openathens_url("https://journals.aps.org"), "American Physical Society — core physics journals."),
|
| 658 |
+
("AIP Publishing", _openathens_url("https://pubs.aip.org"), "Core physics and applied physics literature."),
|
| 659 |
+
("IOPScience", _openathens_url("https://iopscience.iop.org"), "Core physics journal platform."),
|
| 660 |
("arXiv", "https://arxiv.org", "Open-access preprints in physics and maths."),
|
| 661 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text across applied and interdisciplinary physics."),
|
| 662 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 663 |
],
|
| 664 |
"chemistry": [
|
| 665 |
+
("ACS Publications", _openathens_url("https://pubs.acs.org"), "Core chemistry journals from the American Chemical Society."),
|
| 666 |
+
("SciFinder-n", _openathens_url("https://scifinder-n.cas.org"), "Substance, reaction, reference, and patent searching."),
|
| 667 |
+
("Reaxys", _openathens_url("https://www.reaxys.com"), "Reaction and property searching."),
|
| 668 |
+
("RSC Journals", _openathens_url("https://pubs.rsc.org"), "Royal Society of Chemistry journals."),
|
| 669 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text chemistry journals and books."),
|
| 670 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 671 |
],
|
| 672 |
"chemical_engineering": [
|
| 673 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong full text for chemical engineering journals and books."),
|
| 674 |
+
("ACS Publications", _openathens_url("https://pubs.acs.org"), "Core chemistry and chemical engineering coverage."),
|
| 675 |
+
("SciFinder-n", _openathens_url("https://scifinder-n.cas.org"), "Chemical substances, reactions, references, and patents."),
|
| 676 |
+
("Reaxys", _openathens_url("https://www.reaxys.com"), "Reaction and property searching."),
|
| 677 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Engineering handbooks and technical reference data."),
|
| 678 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 679 |
],
|
| 680 |
"computer_science": [
|
| 681 |
+
("ACM Digital Library", _openathens_url("https://dl.acm.org"), "Core computer science literature."),
|
| 682 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Strong for CS, AI, networks, and systems."),
|
| 683 |
("arXiv", "https://arxiv.org", "Important preprint source for CS, AI, and ML."),
|
| 684 |
+
("INSPEC", _openathens_url("https://www.theiet.org/publishing/inspec"), "Indexing for computing and engineering topics."),
|
| 685 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text across CS and applied computing."),
|
| 686 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 687 |
],
|
| 688 |
"robotics": [
|
| 689 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Core source for robotics, AI, automation, and intelligent systems."),
|
| 690 |
+
("ACM Digital Library", _openathens_url("https://dl.acm.org"), "AI, ML, and computing research."),
|
| 691 |
("arXiv", "https://arxiv.org", "Essential for current AI, robotics, and ML preprints."),
|
| 692 |
+
("INSPEC", _openathens_url("https://www.theiet.org/publishing/inspec"), "Indexing for robotics, computing, electronics, and control."),
|
| 693 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for AI, robotics, and applied engineering."),
|
| 694 |
],
|
| 695 |
"electrical_engineering": [
|
| 696 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Core electrical engineering database."),
|
| 697 |
+
("INSPEC", _openathens_url("https://www.theiet.org/publishing/inspec"), "Strong indexing for EE, electronics, and physics."),
|
| 698 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for electrical engineering and control."),
|
| 699 |
+
("ASTM Compass", _openathens_url("https://compass.astm.org"), "Standards and testing methods."),
|
| 700 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 701 |
],
|
| 702 |
"mechanical_engineering": [
|
| 703 |
+
("ASME Digital Library", _openathens_url("https://asmedigitalcollection.asme.org"), "Core mechanical engineering literature."),
|
| 704 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text across mechanics, thermal, and manufacturing topics."),
|
| 705 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Engineering reference data and handbooks."),
|
| 706 |
+
("ASTM Compass", _openathens_url("https://compass.astm.org"), "Standards and materials testing information."),
|
| 707 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 708 |
],
|
| 709 |
"civil_engineering": [
|
| 710 |
+
("ASCE Library", _openathens_url("https://ascelibrary.org"), "Core civil and structural engineering journals and conference papers."),
|
| 711 |
+
("ICE Virtual Library", _openathens_url("https://www.icevirtuallibrary.com"), "Civil engineering literature and proceedings."),
|
| 712 |
+
("ASTM Compass", _openathens_url("https://compass.astm.org"), "Standards and testing methods for materials and engineering."),
|
| 713 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text across civil engineering areas."),
|
| 714 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Handbooks and design reference data."),
|
| 715 |
],
|
| 716 |
"aerospace": [
|
| 717 |
+
("AIAA", _openathens_url("https://arc.aiaa.org/"), "Core aerospace journals, conference papers, and standards."),
|
| 718 |
+
("ASME Digital Library", _openathens_url("https://asmedigitalcollection.asme.org"), "Thermal, mechanical, and fluid systems relevant to aerospace."),
|
| 719 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong full text for aerospace, mechanics, and materials."),
|
| 720 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Avionics, control systems, and guidance."),
|
| 721 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 722 |
],
|
| 723 |
"petroleum": [
|
| 724 |
+
("OnePetro", _openathens_url("https://onepetro.org"), "Core petroleum engineering and oil and gas literature."),
|
| 725 |
+
("EarthDoc", _openathens_url("https://www.earthdoc.org"), "Geoscience and petroleum-related literature."),
|
| 726 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for petroleum, energy, and engineering topics."),
|
| 727 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Engineering handbooks and oil/gas reference material."),
|
| 728 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 729 |
],
|
| 730 |
"energy": [
|
| 731 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong energy engineering and sustainability full text."),
|
| 732 |
+
("OnePetro", _openathens_url("https://onepetro.org"), "Energy sector and petroleum crossover topics."),
|
| 733 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Power systems, electrical energy, and smart grids."),
|
| 734 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Engineering handbooks and energy reference content."),
|
| 735 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 736 |
],
|
| 737 |
"mathematics": [
|
| 738 |
("MathSciNet", "https://mathscinet.ams.org", "Core mathematics review and discovery database."),
|
| 739 |
+
("SpringerLink", _openathens_url("https://link.springer.com"), "Strong mathematics and statistics book and journal coverage."),
|
| 740 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for mathematics, statistics, and data science."),
|
| 741 |
+
("JSTOR", _openathens_url("https://www.jstor.org"), "Foundational mathematics and statistics literature."),
|
| 742 |
("arXiv", "https://arxiv.org", "Preprints in mathematics, statistics, and data science."),
|
| 743 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 744 |
],
|
| 745 |
"materials": [
|
| 746 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong materials science full text."),
|
| 747 |
+
("SpringerLink", _openathens_url("https://link.springer.com"), "Strong materials and nanoscience coverage."),
|
| 748 |
+
("AIP Publishing", _openathens_url("https://pubs.aip.org"), "Applied materials and physics crossover."),
|
| 749 |
+
("IOPScience", _openathens_url("https://iopscience.iop.org"), "Materials and physics crossover."),
|
| 750 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Reference data and engineering materials handbooks."),
|
| 751 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 752 |
],
|
| 753 |
"nuclear": [
|
| 754 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong nuclear engineering and energy full text."),
|
| 755 |
+
("AIP Publishing", _openathens_url("https://pubs.aip.org"), "Nuclear and applied physics crossover."),
|
| 756 |
+
("Knovel", _openathens_url("https://app.knovel.com"), "Engineering reference and handbooks."),
|
| 757 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 758 |
+
("Web of Science", _openathens_url("https://www.webofscience.com"), "Broad citation discovery."),
|
| 759 |
],
|
| 760 |
"quantum_computing": [
|
| 761 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Quantum computing engineering implementations."),
|
| 762 |
+
("ACM Digital Library", _openathens_url("https://dl.acm.org"), "Algorithms, theory, and computing literature."),
|
| 763 |
+
("APS Journals", _openathens_url("https://journals.aps.org"), "Quantum information and foundational physics."),
|
| 764 |
("arXiv", "https://arxiv.org", "Essential for current quantum computing preprints."),
|
| 765 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 766 |
],
|
| 767 |
"biomedical": [
|
| 768 |
+
("PubMed", _openathens_url("https://pubmed.ncbi.nlm.nih.gov"), "Core biomedical and life sciences literature."),
|
| 769 |
+
("IEEE Xplore", _openathens_url("https://ieeexplore.ieee.org"), "Biomedical engineering and medical devices."),
|
| 770 |
+
("Embase", _openathens_url("https://www.embase.com"), "Biomedical and pharmacological literature."),
|
| 771 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for biomedical engineering and applied sciences."),
|
| 772 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 773 |
],
|
| 774 |
"biology": [
|
| 775 |
+
("PubMed", _openathens_url("https://pubmed.ncbi.nlm.nih.gov"), "Core life sciences and biomedical literature."),
|
| 776 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text biology and molecular sciences content."),
|
| 777 |
+
("Embase", _openathens_url("https://www.embase.com"), "Biomedical crossover topics."),
|
| 778 |
("PubMed Central", "https://www.ncbi.nlm.nih.gov/pmc", "Open full-text biomedical articles — no login required."),
|
| 779 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 780 |
],
|
| 781 |
"medical": [
|
| 782 |
+
("PubMed", "https://pubmed.ncbi.nlm.nih.gov/", "Core biomedical and life-sciences literature."),
|
| 783 |
+
("Embase", _openathens_url("https://www.embase.com"), "Biomedical and pharmacological literature."),
|
| 784 |
+
("CINAHL Ultimate", _openathens_url("https://search.ebscohost.com/login.aspx?authtype=ip,uid&profile=ehost&defaultdb=cul"), "Nursing and allied health literature."),
|
| 785 |
+
("Cochrane Library", _openathens_url("https://www.cochranelibrary.com"), "Evidence synthesis and systematic reviews — gold standard."),
|
| 786 |
+
("UpToDate", _openathens_url("https://www.uptodate.com"), "Point-of-care clinical decision support."),
|
| 787 |
+
("ClinicalKey Student", _openathens_url("https://www.clinicalkey.com/student/login"), "Clinical reference and learning resource."),
|
| 788 |
],
|
| 789 |
"business": [
|
| 790 |
+
("Business Source Complete", _openathens_url("https://search.ebscohost.com"), "Core business and management literature."),
|
| 791 |
+
("Emerald Insight", _openathens_url("https://www.emerald.com/insight"), "Management, strategy, and leadership journals."),
|
| 792 |
+
("ProQuest Databases", _openathens_url("https://search.proquest.com"), "Broad business and interdisciplinary discovery."),
|
| 793 |
+
("JSTOR", _openathens_url("https://www.jstor.org"), "Business, economics, and policy literature."),
|
| 794 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 795 |
],
|
| 796 |
"earth_science": [
|
| 797 |
+
("GeoscienceWorld", _openathens_url("https://pubs.geoscienceworld.org"), "Core earth science journals and conference content."),
|
| 798 |
+
("EarthDoc", _openathens_url("https://www.earthdoc.org"), "Geoscience and subsurface literature."),
|
| 799 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Full text for geoscience and planetary topics."),
|
| 800 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Discovery and citation tracking."),
|
| 801 |
+
("Web of Science", _openathens_url("https://www.webofscience.com"), "Broad citation discovery."),
|
| 802 |
],
|
| 803 |
"environment": [
|
| 804 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Strong sustainability and environmental full text."),
|
| 805 |
+
("ProQuest Databases", _openathens_url("https://search.proquest.com"), "Environmental policy and interdisciplinary discovery."),
|
| 806 |
+
("Web of Science", _openathens_url("https://www.webofscience.com"), "Broad citation discovery."),
|
| 807 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery and citation tracking."),
|
| 808 |
+
("Business Source Complete", _openathens_url("https://search.ebscohost.com"), "Sustainability, policy, and corporate responsibility."),
|
| 809 |
],
|
| 810 |
"engineering_management": [
|
| 811 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Broad discovery across engineering and management research."),
|
| 812 |
+
("Emerald Insight", _openathens_url("https://www.emerald.com/insight"), "Management, operations, and leadership literature."),
|
| 813 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Engineering and management full text."),
|
| 814 |
+
("Business Source Complete", _openathens_url("https://search.ebscohost.com"), "Business, management, and strategy literature."),
|
| 815 |
+
("ProQuest Databases", _openathens_url("https://search.proquest.com"), "Broad business and interdisciplinary discovery."),
|
| 816 |
],
|
| 817 |
"metrics": [
|
| 818 |
+
("Journal Citation Reports", _openathens_url("https://jcr.clarivate.com"), "Impact factors and journal rankings (Web of Science)."),
|
| 819 |
+
("Scopus / CiteScore", _openathens_url("https://www.scopus.com"), "CiteScore and source-level metrics."),
|
| 820 |
+
("SciVal", _openathens_url("https://www.scival.com"), "Research performance analytics."),
|
| 821 |
+
("Web of Science", _openathens_url("https://www.webofscience.com"), "Citation discovery and journal evaluation context."),
|
| 822 |
],
|
| 823 |
"theses": [
|
| 824 |
+
("ProQuest Dissertations & Theses Global", _openathens_url("https://www.proquest.com/pqdtglobal"), "International dissertations and theses."),
|
| 825 |
("Khazna", "https://khazna.ku.ac.ae/", "KU institutional repository and research outputs."),
|
| 826 |
("PRIMO", "https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU", "Discovery for dissertations, theses, and KU holdings."),
|
| 827 |
],
|
|
|
|
| 830 |
|
| 831 |
_DB_GENERAL: List[Tuple[str, str, str]] = [
|
| 832 |
("PRIMO (KU Library Discovery)", "https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU", "Best starting point — search all KU books, articles, and journals."),
|
| 833 |
+
("Scopus", _openathens_url("https://www.scopus.com"), "Largest abstract and citation database — all disciplines."),
|
| 834 |
+
("Web of Science", _openathens_url("https://www.webofscience.com"), "Premier citation index — all disciplines."),
|
| 835 |
+
("ScienceDirect", _openathens_url("https://www.sciencedirect.com"), "Large full-text platform across science, engineering, and medicine."),
|
| 836 |
+
("SpringerLink", _openathens_url("https://link.springer.com"), "Springer journals and books across all disciplines."),
|
| 837 |
+
("ProQuest Databases", _openathens_url("https://search.proquest.com"), "Broad multidisciplinary discovery."),
|
| 838 |
+
("Emerald Insight", _openathens_url("https://www.emerald.com/insight"), "Social sciences, management, and interdisciplinary research."),
|
| 839 |
+
("JSTOR", _openathens_url("https://www.jstor.org"), "Foundational and archival literature across many fields."),
|
| 840 |
]
|
| 841 |
|
| 842 |
|
src/agentcore/intents_library.py
CHANGED
|
@@ -25,14 +25,16 @@ from src.services.staff_service import (
|
|
| 25 |
)
|
| 26 |
|
| 27 |
from src.agentcore.models import ChatMessage
|
| 28 |
-
from src.agentcore.constants import (
|
| 29 |
-
ASK_LIBRARIAN_URL,
|
| 30 |
-
DATABASE_RECOMMEND_RE,
|
|
|
|
| 31 |
_DB_GENERAL,
|
| 32 |
_DB_SUBJECTS,
|
| 33 |
_GUARDRAIL,
|
| 34 |
_URL_INSTRUCTION,
|
| 35 |
-
)
|
|
|
|
| 36 |
from src.agentcore.utils import (
|
| 37 |
_build_history_messages,
|
| 38 |
_escape,
|
|
@@ -43,7 +45,25 @@ from src.agentcore.utils import (
|
|
| 43 |
)
|
| 44 |
from src.agentcore.classify import _looks_library_hours_question
|
| 45 |
|
| 46 |
-
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
def _campus_answer() -> str:
|
| 49 |
return (
|
|
@@ -82,8 +102,9 @@ async def _rag_answer(question: str, rag_results: List[dict], history: List[Chat
|
|
| 82 |
system = (
|
| 83 |
"You are LibBee, the Khalifa University Library AI Assistant. "
|
| 84 |
"Answer the user's question using ONLY the context provided below. "
|
| 85 |
-
"Be concise, friendly, and use HTML <br> for line breaks where needed. "
|
| 86 |
-
"
|
|
|
|
| 87 |
"include it as a clickable HTML link using <a href=\"URL\" target=\"_blank\">link text</a>. "
|
| 88 |
"For example, if context mentions 'library.ku.ac.ae/ill/' include it as a link. "
|
| 89 |
"NEVER invent or guess URLs that do not appear in the context. "
|
|
@@ -104,7 +125,7 @@ async def _rag_answer(question: str, rag_results: List[dict], history: List[Chat
|
|
| 104 |
msgs.extend(_build_history_messages(history))
|
| 105 |
msgs.append({"role": "user", "content": question})
|
| 106 |
response = await llm.ainvoke(msgs)
|
| 107 |
-
return response.content.strip()
|
| 108 |
except Exception as e:
|
| 109 |
logger.error(f"_rag_answer error: {e}")
|
| 110 |
return (
|
|
@@ -231,7 +252,7 @@ def _theses_answer() -> str:
|
|
| 231 |
"<strong>ProQuest Dissertations & Theses Global</strong><br>"
|
| 232 |
"KU subscribes to ProQuest D&T Global — the world's largest database of "
|
| 233 |
"theses and dissertations from universities worldwide.<br>"
|
| 234 |
-
'🔗 <a href="https://
|
| 235 |
"Access via KU Library</a><br><br>"
|
| 236 |
"<strong>Other sources</strong><br>"
|
| 237 |
'• <a href="https://ethos.bl.uk" target="_blank">EThOS</a> — UK theses (British Library)<br>'
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
from src.agentcore.models import ChatMessage
|
| 28 |
+
from src.agentcore.constants import (
|
| 29 |
+
ASK_LIBRARIAN_URL,
|
| 30 |
+
DATABASE_RECOMMEND_RE,
|
| 31 |
+
FIXED_VERIFIED_URLS,
|
| 32 |
_DB_GENERAL,
|
| 33 |
_DB_SUBJECTS,
|
| 34 |
_GUARDRAIL,
|
| 35 |
_URL_INSTRUCTION,
|
| 36 |
+
)
|
| 37 |
+
from src.services.html_sanitizer import markdown_to_safe_html, sanitize_answer_html
|
| 38 |
from src.agentcore.utils import (
|
| 39 |
_build_history_messages,
|
| 40 |
_escape,
|
|
|
|
| 45 |
)
|
| 46 |
from src.agentcore.classify import _looks_library_hours_question
|
| 47 |
|
| 48 |
+
logger = logging.getLogger(__name__)
|
| 49 |
+
|
| 50 |
+
_CONTEXT_URL_RE = re.compile(r"(?:https?://|mailto:|tel:)[^\s<>\"']+")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def _verified_rag_urls(context: str) -> set[str]:
|
| 54 |
+
"""Return the exact URLs a knowledge-base answer is allowed to emit."""
|
| 55 |
+
urls = set(FIXED_VERIFIED_URLS)
|
| 56 |
+
for match in _CONTEXT_URL_RE.findall(context or ""):
|
| 57 |
+
candidate = html.unescape(match).rstrip(".,;:!?)]}")
|
| 58 |
+
if candidate:
|
| 59 |
+
urls.add(candidate)
|
| 60 |
+
return urls
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _prepare_rag_answer(answer: str, context: str) -> str:
|
| 64 |
+
"""Normalize LLM formatting and enforce the KB URL allow-list in code."""
|
| 65 |
+
normalized = markdown_to_safe_html(answer)
|
| 66 |
+
return sanitize_answer_html(normalized, allowed_urls=_verified_rag_urls(context))
|
| 67 |
|
| 68 |
def _campus_answer() -> str:
|
| 69 |
return (
|
|
|
|
| 102 |
system = (
|
| 103 |
"You are LibBee, the Khalifa University Library AI Assistant. "
|
| 104 |
"Answer the user's question using ONLY the context provided below. "
|
| 105 |
+
"Be concise, friendly, and use HTML <br> for line breaks where needed. "
|
| 106 |
+
"Return sanitized HTML, not Markdown. Never use **bold**, # headings, or [text](URL). "
|
| 107 |
+
"IMPORTANT — LINKS: When the context contains a URL starting with https://, "
|
| 108 |
"include it as a clickable HTML link using <a href=\"URL\" target=\"_blank\">link text</a>. "
|
| 109 |
"For example, if context mentions 'library.ku.ac.ae/ill/' include it as a link. "
|
| 110 |
"NEVER invent or guess URLs that do not appear in the context. "
|
|
|
|
| 125 |
msgs.extend(_build_history_messages(history))
|
| 126 |
msgs.append({"role": "user", "content": question})
|
| 127 |
response = await llm.ainvoke(msgs)
|
| 128 |
+
return _prepare_rag_answer(response.content.strip(), context)
|
| 129 |
except Exception as e:
|
| 130 |
logger.error(f"_rag_answer error: {e}")
|
| 131 |
return (
|
|
|
|
| 252 |
"<strong>ProQuest Dissertations & Theses Global</strong><br>"
|
| 253 |
"KU subscribes to ProQuest D&T Global — the world's largest database of "
|
| 254 |
"theses and dissertations from universities worldwide.<br>"
|
| 255 |
+
'🔗 <a href="https://go.openathens.net/redirector/ku.ac.ae?url=https%3A%2F%2Fwww.proquest.com%2Fpqdtglobal" target="_blank">'
|
| 256 |
"Access via KU Library</a><br><br>"
|
| 257 |
"<strong>Other sources</strong><br>"
|
| 258 |
'• <a href="https://ethos.bl.uk" target="_blank">EThOS</a> — UK theses (British Library)<br>'
|
src/agentcore/intents_search.py
CHANGED
|
@@ -498,7 +498,7 @@ def _citation_chain_answer() -> str:
|
|
| 498 |
"This gives you foundational and seminal works on the topic.<br><br>"
|
| 499 |
"<strong>Forward citation (who has cited this paper since publication?)</strong><br>"
|
| 500 |
"Use these tools — paste in the DOI or title:<br>"
|
| 501 |
-
'• <a href="https://
|
| 502 |
'— search the article, then click "Cited by N documents"<br>'
|
| 503 |
'• <a href="https://www.webofscience.com" target="_blank"><strong>Web of Science</strong></a> '
|
| 504 |
'— search the article, click "Times Cited"<br>'
|
|
@@ -521,7 +521,7 @@ def _predatory_eval_answer() -> str:
|
|
| 521 |
"• Check the journal's website for a peer-review statement or editorial process description<br>"
|
| 522 |
"• In PRIMO, tick the <em>Peer-reviewed</em> filter in the left sidebar<br>"
|
| 523 |
"• Check if the journal is indexed in "
|
| 524 |
-
'<a href="https://
|
| 525 |
'<a href="https://www.webofscience.com" target="_blank">Web of Science</a> — '
|
| 526 |
"indexed = generally peer-reviewed<br><br>"
|
| 527 |
"<strong>Is it a legitimate journal?</strong><br>"
|
|
@@ -546,7 +546,7 @@ def _highly_cited_note(topic_escaped: str) -> str:
|
|
| 546 |
return (
|
| 547 |
f"<br><br><strong>📊 Finding highly cited papers on {topic_escaped}</strong><br>"
|
| 548 |
"PRIMO doesn't sort by citation count, but these tools do:<br>"
|
| 549 |
-
'• <a href="https://
|
| 550 |
'— search your topic → Sort by <em>Cited by (highest)</em><br>'
|
| 551 |
'• <a href="https://www.webofscience.com" target="_blank"><strong>Web of Science</strong></a> '
|
| 552 |
'— search → Sort by <em>Times Cited</em><br>'
|
|
|
|
| 498 |
"This gives you foundational and seminal works on the topic.<br><br>"
|
| 499 |
"<strong>Forward citation (who has cited this paper since publication?)</strong><br>"
|
| 500 |
"Use these tools — paste in the DOI or title:<br>"
|
| 501 |
+
'• <a href="https://go.openathens.net/redirector/ku.ac.ae?url=https%3A%2F%2Fwww.scopus.com%2Fpages%2Fai" target="_blank"><strong>Scopus</strong></a> '
|
| 502 |
'— search the article, then click "Cited by N documents"<br>'
|
| 503 |
'• <a href="https://www.webofscience.com" target="_blank"><strong>Web of Science</strong></a> '
|
| 504 |
'— search the article, click "Times Cited"<br>'
|
|
|
|
| 521 |
"• Check the journal's website for a peer-review statement or editorial process description<br>"
|
| 522 |
"• In PRIMO, tick the <em>Peer-reviewed</em> filter in the left sidebar<br>"
|
| 523 |
"• Check if the journal is indexed in "
|
| 524 |
+
'<a href="https://go.openathens.net/redirector/ku.ac.ae?url=https%3A%2F%2Fwww.scopus.com" target="_blank">Scopus</a> or '
|
| 525 |
'<a href="https://www.webofscience.com" target="_blank">Web of Science</a> — '
|
| 526 |
"indexed = generally peer-reviewed<br><br>"
|
| 527 |
"<strong>Is it a legitimate journal?</strong><br>"
|
|
|
|
| 546 |
return (
|
| 547 |
f"<br><br><strong>📊 Finding highly cited papers on {topic_escaped}</strong><br>"
|
| 548 |
"PRIMO doesn't sort by citation count, but these tools do:<br>"
|
| 549 |
+
'• <a href="https://go.openathens.net/redirector/ku.ac.ae?url=https%3A%2F%2Fwww.scopus.com" target="_blank"><strong>Scopus</strong></a> '
|
| 550 |
'— search your topic → Sort by <em>Cited by (highest)</em><br>'
|
| 551 |
'• <a href="https://www.webofscience.com" target="_blank"><strong>Web of Science</strong></a> '
|
| 552 |
'— search → Sort by <em>Times Cited</em><br>'
|
src/agentcore/rendering.py
CHANGED
|
@@ -25,7 +25,7 @@ from src.services.staff_service import (
|
|
| 25 |
)
|
| 26 |
|
| 27 |
from src.agentcore.models import SearchContextPayload
|
| 28 |
-
from src.agentcore.constants import ASK_LIBRARIAN_URL, PRIMO_AI_URL
|
| 29 |
from src.agentcore.utils import (
|
| 30 |
_escape,
|
| 31 |
_find_staff_by_token,
|
|
@@ -65,9 +65,9 @@ def _tool_urls(context: SearchContextPayload) -> Dict[str, str]:
|
|
| 65 |
primo_ai_query = quote(context.ai_tool_query or context.display_topic or context.topic)
|
| 66 |
urls: Dict[str, str] = {
|
| 67 |
"leapspace": f"https://www.sciencedirect.com/leapspace?query={ai_query}",
|
| 68 |
-
"scopus_ai": f"https://www
|
| 69 |
"ebsco_ai": (
|
| 70 |
-
f"https://research
|
| 71 |
f"?q={ai_query}"
|
| 72 |
f"&autocorrect=y"
|
| 73 |
f"&expanders=concept"
|
|
@@ -245,14 +245,12 @@ def _ai_tools_footer(context):
|
|
| 245 |
context.topic, context.year_from, context.year_to, context.peer_reviewed
|
| 246 |
) if is_med else ""
|
| 247 |
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
platforms = [
|
| 251 |
("PRIMO AI Assistant", primo_ai, "primo"),
|
| 252 |
("LeapSpace", "https://www.sciencedirect.com/leapspace?query=" + ai_q, "leapspace"),
|
| 253 |
-
("Scopus AI", "https://www
|
| 254 |
("EBSCO Research AI",
|
| 255 |
-
"https://research
|
| 256 |
+ "&autocorrect=y&expanders=concept&limiters=None&searchMode=enhanced&searchSegment=all-results", "ebsco"),
|
| 257 |
("Consensus", "https://consensus.app/results/?q=" + ai_q, "consensus"),
|
| 258 |
("Semantic Scholar", "https://www.semanticscholar.org/search?q=" + ai_q + "&sort=relevance", "semanticscholar"),
|
|
@@ -507,65 +505,65 @@ def _ai_tools_footer(context):
|
|
| 507 |
if any(k in all_lower for k in ["medicine","medical","clinical","nursing","pharmacy","health","pubmed","embase","cinahl","cochrane","uptodate"]):
|
| 508 |
db_subject = "Medicine & Health Sciences"
|
| 509 |
dbs = [
|
| 510 |
-
("PubMed
|
| 511 |
-
("Embase",
|
| 512 |
-
("CINAHL Ultimate",
|
| 513 |
-
("Cochrane Library",
|
| 514 |
-
("UpToDate",
|
| 515 |
]
|
| 516 |
elif any(k in all_lower for k in ["machine learning","deep learning","artificial intelligence","neural network","computer science","software","algorithm","cybersecurity","robotics","nlp"]):
|
| 517 |
db_subject = "Computer Science & AI"
|
| 518 |
dbs = [
|
| 519 |
-
("IEEE Xplore",
|
| 520 |
-
("ACM Digital Library",
|
| 521 |
-
("ScienceDirect",
|
| 522 |
-
("Scopus",
|
| 523 |
-
("Web of Science",
|
| 524 |
]
|
| 525 |
elif any(k in all_lower for k in ["climate","global warming","environment","sustainability","ecology","carbon","emission","renewable","sea level","maldives","island"]):
|
| 526 |
db_subject = "Environment & Climate"
|
| 527 |
dbs = [
|
| 528 |
-
("ScienceDirect",
|
| 529 |
-
("Scopus",
|
| 530 |
-
("Web of Science",
|
| 531 |
-
("SpringerLink",
|
| 532 |
]
|
| 533 |
elif any(k in all_lower for k in ["engineering","mechanical","civil","electrical","aerospace","structural","petroleum","chemical","materials"]):
|
| 534 |
db_subject = "Engineering"
|
| 535 |
dbs = [
|
| 536 |
-
("IEEE Xplore",
|
| 537 |
-
("ScienceDirect",
|
| 538 |
-
("Knovel",
|
| 539 |
-
("Scopus",
|
| 540 |
-
("Web of Science",
|
| 541 |
]
|
| 542 |
elif any(k in all_lower for k in ["business","management","finance","economics","leadership","marketing","strategy","entrepreneurship"]):
|
| 543 |
db_subject = "Business & Management"
|
| 544 |
dbs = [
|
| 545 |
-
("Business Source Complete",
|
| 546 |
-
("Emerald Insight",
|
| 547 |
-
("Scopus",
|
| 548 |
-
("ScienceDirect",
|
| 549 |
]
|
| 550 |
elif any(k in all_lower for k in ["physics","chemistry","quantum","nuclear","materials science","nanotechnology","optics"]):
|
| 551 |
db_subject = "Physics, Chemistry & Materials"
|
| 552 |
dbs = [
|
| 553 |
-
("ScienceDirect",
|
| 554 |
-
("ACS Publications",
|
| 555 |
-
("APS Journals",
|
| 556 |
-
("Scopus",
|
| 557 |
-
("Web of Science",
|
| 558 |
]
|
| 559 |
else:
|
| 560 |
db_subject = "General"
|
| 561 |
dbs = [
|
| 562 |
-
("EBSCO",
|
| 563 |
-
("ScienceDirect",
|
| 564 |
-
("SpringerLink",
|
| 565 |
-
("Taylor & Francis",
|
| 566 |
-
("Emerald Insight",
|
| 567 |
-
("Scopus",
|
| 568 |
-
("Web of Science",
|
| 569 |
]
|
| 570 |
|
| 571 |
dbs_html_rows = ""
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
from src.agentcore.models import SearchContextPayload
|
| 28 |
+
from src.agentcore.constants import ASK_LIBRARIAN_URL, PRIMO_AI_URL, _openathens_url
|
| 29 |
from src.agentcore.utils import (
|
| 30 |
_escape,
|
| 31 |
_find_staff_by_token,
|
|
|
|
| 65 |
primo_ai_query = quote(context.ai_tool_query or context.display_topic or context.topic)
|
| 66 |
urls: Dict[str, str] = {
|
| 67 |
"leapspace": f"https://www.sciencedirect.com/leapspace?query={ai_query}",
|
| 68 |
+
"scopus_ai": _openathens_url(f"https://www.scopus.com/pages/ai?query={ai_query}"),
|
| 69 |
"ebsco_ai": (
|
| 70 |
+
f"https://research.ebsco.com/c/yst6t2/search/results"
|
| 71 |
f"?q={ai_query}"
|
| 72 |
f"&autocorrect=y"
|
| 73 |
f"&expanders=concept"
|
|
|
|
| 245 |
context.topic, context.year_from, context.year_to, context.peer_reviewed
|
| 246 |
) if is_med else ""
|
| 247 |
|
| 248 |
+
platforms = [
|
|
|
|
|
|
|
| 249 |
("PRIMO AI Assistant", primo_ai, "primo"),
|
| 250 |
("LeapSpace", "https://www.sciencedirect.com/leapspace?query=" + ai_q, "leapspace"),
|
| 251 |
+
("Scopus AI", _openathens_url("https://www.scopus.com/pages/ai?query=" + ai_q), "scopus"),
|
| 252 |
("EBSCO Research AI",
|
| 253 |
+
"https://research.ebsco.com/c/yst6t2/search/results?q=" + ai_q
|
| 254 |
+ "&autocorrect=y&expanders=concept&limiters=None&searchMode=enhanced&searchSegment=all-results", "ebsco"),
|
| 255 |
("Consensus", "https://consensus.app/results/?q=" + ai_q, "consensus"),
|
| 256 |
("Semantic Scholar", "https://www.semanticscholar.org/search?q=" + ai_q + "&sort=relevance", "semanticscholar"),
|
|
|
|
| 505 |
if any(k in all_lower for k in ["medicine","medical","clinical","nursing","pharmacy","health","pubmed","embase","cinahl","cochrane","uptodate"]):
|
| 506 |
db_subject = "Medicine & Health Sciences"
|
| 507 |
dbs = [
|
| 508 |
+
("PubMed","https://pubmed.ncbi.nlm.nih.gov/","Core biomedical literature"),
|
| 509 |
+
("Embase",_openathens_url("https://www.embase.com"),"Biomedical, drugs, devices, clinical medicine"),
|
| 510 |
+
("CINAHL Ultimate",_openathens_url("https://search.ebscohost.com/login.aspx?authtype=ip,uid&profile=ehost&defaultdb=cul"),"Nursing and allied health"),
|
| 511 |
+
("Cochrane Library",_openathens_url("https://www.cochranelibrary.com"),"Systematic reviews and evidence-based medicine"),
|
| 512 |
+
("UpToDate",_openathens_url("https://www.uptodate.com"),"Point-of-care clinical decision support"),
|
| 513 |
]
|
| 514 |
elif any(k in all_lower for k in ["machine learning","deep learning","artificial intelligence","neural network","computer science","software","algorithm","cybersecurity","robotics","nlp"]):
|
| 515 |
db_subject = "Computer Science & AI"
|
| 516 |
dbs = [
|
| 517 |
+
("IEEE Xplore",_openathens_url("https://ieeexplore.ieee.org"),"Core CS, AI, electronics and systems"),
|
| 518 |
+
("ACM Digital Library",_openathens_url("https://dl.acm.org"),"Computer science journals, proceedings and books"),
|
| 519 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Full text across CS and applied computing"),
|
| 520 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Discovery and citation tracking"),
|
| 521 |
+
("Web of Science",_openathens_url("https://www.webofscience.com"),"Citation index"),
|
| 522 |
]
|
| 523 |
elif any(k in all_lower for k in ["climate","global warming","environment","sustainability","ecology","carbon","emission","renewable","sea level","maldives","island"]):
|
| 524 |
db_subject = "Environment & Climate"
|
| 525 |
dbs = [
|
| 526 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Full text across science, environment and engineering"),
|
| 527 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Broad discovery and citation tracking"),
|
| 528 |
+
("Web of Science",_openathens_url("https://www.webofscience.com"),"High-impact journal coverage and citation index"),
|
| 529 |
+
("SpringerLink",_openathens_url("https://link.springer.com"),"Springer journals and books"),
|
| 530 |
]
|
| 531 |
elif any(k in all_lower for k in ["engineering","mechanical","civil","electrical","aerospace","structural","petroleum","chemical","materials"]):
|
| 532 |
db_subject = "Engineering"
|
| 533 |
dbs = [
|
| 534 |
+
("IEEE Xplore",_openathens_url("https://ieeexplore.ieee.org"),"Electrical, electronics and systems engineering"),
|
| 535 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Full text across engineering disciplines"),
|
| 536 |
+
("Knovel",_openathens_url("https://app.knovel.com"),"Engineering handbooks and reference data"),
|
| 537 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Discovery and citation tracking"),
|
| 538 |
+
("Web of Science",_openathens_url("https://www.webofscience.com"),"Citation index"),
|
| 539 |
]
|
| 540 |
elif any(k in all_lower for k in ["business","management","finance","economics","leadership","marketing","strategy","entrepreneurship"]):
|
| 541 |
db_subject = "Business & Management"
|
| 542 |
dbs = [
|
| 543 |
+
("Business Source Complete",_openathens_url("https://search.ebscohost.com"),"Core business and management literature"),
|
| 544 |
+
("Emerald Insight",_openathens_url("https://www.emerald.com/insight"),"Management, strategy and leadership"),
|
| 545 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Broad discovery and citation tracking"),
|
| 546 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Business and social sciences full text"),
|
| 547 |
]
|
| 548 |
elif any(k in all_lower for k in ["physics","chemistry","quantum","nuclear","materials science","nanotechnology","optics"]):
|
| 549 |
db_subject = "Physics, Chemistry & Materials"
|
| 550 |
dbs = [
|
| 551 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Full text across physical sciences"),
|
| 552 |
+
("ACS Publications",_openathens_url("https://pubs.acs.org"),"Core chemistry and chemical engineering"),
|
| 553 |
+
("APS Journals",_openathens_url("https://journals.aps.org"),"American Physical Society core physics journals"),
|
| 554 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Discovery and citation tracking"),
|
| 555 |
+
("Web of Science",_openathens_url("https://www.webofscience.com"),"Citation index"),
|
| 556 |
]
|
| 557 |
else:
|
| 558 |
db_subject = "General"
|
| 559 |
dbs = [
|
| 560 |
+
("EBSCO",_openathens_url("https://search.ebscohost.com"),"Multidisciplinary full text"),
|
| 561 |
+
("ScienceDirect",_openathens_url("https://www.sciencedirect.com"),"Science, engineering and medicine"),
|
| 562 |
+
("SpringerLink",_openathens_url("https://link.springer.com"),"Journals and books across all disciplines"),
|
| 563 |
+
("Taylor & Francis",_openathens_url("https://www.tandfonline.com"),"Humanities, social sciences and STEM"),
|
| 564 |
+
("Emerald Insight",_openathens_url("https://www.emerald.com/insight"),"Management and social sciences"),
|
| 565 |
+
("Scopus",_openathens_url("https://www.scopus.com"),"Citation discovery, all disciplines"),
|
| 566 |
+
("Web of Science",_openathens_url("https://www.webofscience.com"),"Citation index, all disciplines"),
|
| 567 |
]
|
| 568 |
|
| 569 |
dbs_html_rows = ""
|