aurelian 0.1.0__py3-none-any.whl

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.
Files changed (266) hide show
  1. aurelian/__init__.py +9 -0
  2. aurelian/agents/__init__.py +0 -0
  3. aurelian/agents/amigo/__init__.py +3 -0
  4. aurelian/agents/amigo/amigo_agent.py +77 -0
  5. aurelian/agents/amigo/amigo_config.py +85 -0
  6. aurelian/agents/amigo/amigo_evals.py +73 -0
  7. aurelian/agents/amigo/amigo_gradio.py +52 -0
  8. aurelian/agents/amigo/amigo_mcp.py +152 -0
  9. aurelian/agents/amigo/amigo_tools.py +152 -0
  10. aurelian/agents/biblio/__init__.py +42 -0
  11. aurelian/agents/biblio/biblio_agent.py +95 -0
  12. aurelian/agents/biblio/biblio_config.py +40 -0
  13. aurelian/agents/biblio/biblio_gradio.py +67 -0
  14. aurelian/agents/biblio/biblio_mcp.py +115 -0
  15. aurelian/agents/biblio/biblio_tools.py +164 -0
  16. aurelian/agents/biblio_agent.py +46 -0
  17. aurelian/agents/checklist/__init__.py +44 -0
  18. aurelian/agents/checklist/checklist_agent.py +86 -0
  19. aurelian/agents/checklist/checklist_config.py +28 -0
  20. aurelian/agents/checklist/checklist_gradio.py +70 -0
  21. aurelian/agents/checklist/checklist_mcp.py +86 -0
  22. aurelian/agents/checklist/checklist_tools.py +141 -0
  23. aurelian/agents/checklist/content/checklists.yaml +7 -0
  24. aurelian/agents/checklist/content/streams.csv +136 -0
  25. aurelian/agents/checklist_agent.py +40 -0
  26. aurelian/agents/chemistry/__init__.py +3 -0
  27. aurelian/agents/chemistry/chemistry_agent.py +47 -0
  28. aurelian/agents/chemistry/chemistry_config.py +71 -0
  29. aurelian/agents/chemistry/chemistry_evals.py +79 -0
  30. aurelian/agents/chemistry/chemistry_gradio.py +50 -0
  31. aurelian/agents/chemistry/chemistry_mcp.py +120 -0
  32. aurelian/agents/chemistry/chemistry_tools.py +121 -0
  33. aurelian/agents/chemistry/image_agent.py +15 -0
  34. aurelian/agents/d4d/__init__.py +30 -0
  35. aurelian/agents/d4d/d4d_agent.py +73 -0
  36. aurelian/agents/d4d/d4d_config.py +46 -0
  37. aurelian/agents/d4d/d4d_gradio.py +58 -0
  38. aurelian/agents/d4d/d4d_mcp.py +71 -0
  39. aurelian/agents/d4d/d4d_tools.py +157 -0
  40. aurelian/agents/d4d_agent.py +64 -0
  41. aurelian/agents/diagnosis/__init__.py +33 -0
  42. aurelian/agents/diagnosis/diagnosis_agent.py +54 -0
  43. aurelian/agents/diagnosis/diagnosis_config.py +48 -0
  44. aurelian/agents/diagnosis/diagnosis_evals.py +76 -0
  45. aurelian/agents/diagnosis/diagnosis_gradio.py +52 -0
  46. aurelian/agents/diagnosis/diagnosis_mcp.py +141 -0
  47. aurelian/agents/diagnosis/diagnosis_tools.py +204 -0
  48. aurelian/agents/diagnosis_agent.py +28 -0
  49. aurelian/agents/draw/__init__.py +3 -0
  50. aurelian/agents/draw/draw_agent.py +39 -0
  51. aurelian/agents/draw/draw_config.py +26 -0
  52. aurelian/agents/draw/draw_gradio.py +50 -0
  53. aurelian/agents/draw/draw_mcp.py +94 -0
  54. aurelian/agents/draw/draw_tools.py +100 -0
  55. aurelian/agents/draw/judge_agent.py +18 -0
  56. aurelian/agents/filesystem/__init__.py +0 -0
  57. aurelian/agents/filesystem/filesystem_config.py +27 -0
  58. aurelian/agents/filesystem/filesystem_gradio.py +49 -0
  59. aurelian/agents/filesystem/filesystem_mcp.py +89 -0
  60. aurelian/agents/filesystem/filesystem_tools.py +95 -0
  61. aurelian/agents/filesystem/py.typed +0 -0
  62. aurelian/agents/github/__init__.py +0 -0
  63. aurelian/agents/github/github_agent.py +83 -0
  64. aurelian/agents/github/github_cli.py +248 -0
  65. aurelian/agents/github/github_config.py +22 -0
  66. aurelian/agents/github/github_gradio.py +152 -0
  67. aurelian/agents/github/github_mcp.py +252 -0
  68. aurelian/agents/github/github_tools.py +408 -0
  69. aurelian/agents/github/github_tools.py.tmp +413 -0
  70. aurelian/agents/goann/__init__.py +13 -0
  71. aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines.md +1000 -0
  72. aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines.pdf +0 -0
  73. aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines_Paper.md +693 -0
  74. aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines_Paper.pdf +0 -0
  75. aurelian/agents/goann/goann_agent.py +90 -0
  76. aurelian/agents/goann/goann_config.py +90 -0
  77. aurelian/agents/goann/goann_evals.py +104 -0
  78. aurelian/agents/goann/goann_gradio.py +62 -0
  79. aurelian/agents/goann/goann_mcp.py +0 -0
  80. aurelian/agents/goann/goann_tools.py +65 -0
  81. aurelian/agents/gocam/__init__.py +52 -0
  82. aurelian/agents/gocam/documents/DNA-binding transcription factor activity annotation guidelines.docx +0 -0
  83. aurelian/agents/gocam/documents/DNA-binding transcription factor activity annotation guidelines.pdf +0 -0
  84. aurelian/agents/gocam/documents/DNA-binding_transcription_factor_activity_annotation_guidelines.md +100 -0
  85. aurelian/agents/gocam/documents/E3 ubiquitin ligases.docx +0 -0
  86. aurelian/agents/gocam/documents/E3 ubiquitin ligases.pdf +0 -0
  87. aurelian/agents/gocam/documents/E3_ubiquitin_ligases.md +134 -0
  88. aurelian/agents/gocam/documents/GO-CAM annotation guidelines README.docx +0 -0
  89. aurelian/agents/gocam/documents/GO-CAM annotation guidelines README.pdf +0 -0
  90. aurelian/agents/gocam/documents/GO-CAM modelling guidelines TO DO.docx +0 -0
  91. aurelian/agents/gocam/documents/GO-CAM modelling guidelines TO DO.pdf +0 -0
  92. aurelian/agents/gocam/documents/GO-CAM_annotation_guidelines_README.md +1 -0
  93. aurelian/agents/gocam/documents/GO-CAM_modelling_guidelines_TO_DO.md +3 -0
  94. aurelian/agents/gocam/documents/How to annotate complexes in GO-CAM.docx +0 -0
  95. aurelian/agents/gocam/documents/How to annotate complexes in GO-CAM.pdf +0 -0
  96. aurelian/agents/gocam/documents/How to annotate molecular adaptors.docx +0 -0
  97. aurelian/agents/gocam/documents/How to annotate molecular adaptors.pdf +0 -0
  98. aurelian/agents/gocam/documents/How to annotate sequestering proteins.docx +0 -0
  99. aurelian/agents/gocam/documents/How to annotate sequestering proteins.pdf +0 -0
  100. aurelian/agents/gocam/documents/How_to_annotate_complexes_in_GO-CAM.md +29 -0
  101. aurelian/agents/gocam/documents/How_to_annotate_molecular_adaptors.md +31 -0
  102. aurelian/agents/gocam/documents/How_to_annotate_sequestering_proteins.md +42 -0
  103. aurelian/agents/gocam/documents/Molecular adaptor activity.docx +0 -0
  104. aurelian/agents/gocam/documents/Molecular adaptor activity.pdf +0 -0
  105. aurelian/agents/gocam/documents/Molecular carrier activity.docx +0 -0
  106. aurelian/agents/gocam/documents/Molecular carrier activity.pdf +0 -0
  107. aurelian/agents/gocam/documents/Molecular_adaptor_activity.md +51 -0
  108. aurelian/agents/gocam/documents/Molecular_carrier_activity.md +41 -0
  109. aurelian/agents/gocam/documents/Protein sequestering activity.docx +0 -0
  110. aurelian/agents/gocam/documents/Protein sequestering activity.pdf +0 -0
  111. aurelian/agents/gocam/documents/Protein_sequestering_activity.md +50 -0
  112. aurelian/agents/gocam/documents/Signaling receptor activity annotation guidelines.docx +0 -0
  113. aurelian/agents/gocam/documents/Signaling receptor activity annotation guidelines.pdf +0 -0
  114. aurelian/agents/gocam/documents/Signaling_receptor_activity_annotation_guidelines.md +187 -0
  115. aurelian/agents/gocam/documents/Transcription coregulator activity.docx +0 -0
  116. aurelian/agents/gocam/documents/Transcription coregulator activity.pdf +0 -0
  117. aurelian/agents/gocam/documents/Transcription_coregulator_activity.md +36 -0
  118. aurelian/agents/gocam/documents/Transporter activity annotation annotation guidelines.docx +0 -0
  119. aurelian/agents/gocam/documents/Transporter activity annotation annotation guidelines.pdf +0 -0
  120. aurelian/agents/gocam/documents/Transporter_activity_annotation_annotation_guidelines.md +43 -0
  121. Regulatory Processes in GO-CAM.docx +0 -0
  122. Regulatory Processes in GO-CAM.pdf +0 -0
  123. aurelian/agents/gocam/documents/WIP_-_Regulation_and_Regulatory_Processes_in_GO-CAM.md +31 -0
  124. aurelian/agents/gocam/documents/md/DNA-binding_transcription_factor_activity_annotation_guidelines.md +131 -0
  125. aurelian/agents/gocam/documents/md/E3_ubiquitin_ligases.md +166 -0
  126. aurelian/agents/gocam/documents/md/GO-CAM_annotation_guidelines_README.md +1 -0
  127. aurelian/agents/gocam/documents/md/GO-CAM_modelling_guidelines_TO_DO.md +5 -0
  128. aurelian/agents/gocam/documents/md/How_to_annotate_complexes_in_GO-CAM.md +28 -0
  129. aurelian/agents/gocam/documents/md/How_to_annotate_molecular_adaptors.md +19 -0
  130. aurelian/agents/gocam/documents/md/How_to_annotate_sequestering_proteins.md +38 -0
  131. aurelian/agents/gocam/documents/md/Molecular_adaptor_activity.md +52 -0
  132. aurelian/agents/gocam/documents/md/Molecular_carrier_activity.md +59 -0
  133. aurelian/agents/gocam/documents/md/Protein_sequestering_activity.md +52 -0
  134. aurelian/agents/gocam/documents/md/Signaling_receptor_activity_annotation_guidelines.md +271 -0
  135. aurelian/agents/gocam/documents/md/Transcription_coregulator_activity.md +54 -0
  136. aurelian/agents/gocam/documents/md/Transporter_activity_annotation_annotation_guidelines.md +38 -0
  137. aurelian/agents/gocam/documents/md/WIP_-_Regulation_and_Regulatory_Processes_in_GO-CAM.md +39 -0
  138. aurelian/agents/gocam/documents/pandoc_md/Signaling_receptor_activity_annotation_guidelines.md +334 -0
  139. aurelian/agents/gocam/gocam_agent.py +243 -0
  140. aurelian/agents/gocam/gocam_config.py +85 -0
  141. aurelian/agents/gocam/gocam_curator_agent.py +46 -0
  142. aurelian/agents/gocam/gocam_evals.py +64 -0
  143. aurelian/agents/gocam/gocam_gradio.py +89 -0
  144. aurelian/agents/gocam/gocam_mcp.py +224 -0
  145. aurelian/agents/gocam/gocam_tools.py +294 -0
  146. aurelian/agents/linkml/__init__.py +0 -0
  147. aurelian/agents/linkml/linkml_agent.py +62 -0
  148. aurelian/agents/linkml/linkml_config.py +48 -0
  149. aurelian/agents/linkml/linkml_evals.py +66 -0
  150. aurelian/agents/linkml/linkml_gradio.py +45 -0
  151. aurelian/agents/linkml/linkml_mcp.py +181 -0
  152. aurelian/agents/linkml/linkml_tools.py +102 -0
  153. aurelian/agents/literature/__init__.py +3 -0
  154. aurelian/agents/literature/literature_agent.py +75 -0
  155. aurelian/agents/literature/literature_config.py +35 -0
  156. aurelian/agents/literature/literature_gradio.py +52 -0
  157. aurelian/agents/literature/literature_mcp.py +174 -0
  158. aurelian/agents/literature/literature_tools.py +182 -0
  159. aurelian/agents/monarch/__init__.py +0 -0
  160. aurelian/agents/monarch/monarch_agent.py +45 -0
  161. aurelian/agents/monarch/monarch_config.py +45 -0
  162. aurelian/agents/monarch/monarch_gradio.py +51 -0
  163. aurelian/agents/monarch/monarch_mcp.py +65 -0
  164. aurelian/agents/monarch/monarch_tools.py +112 -0
  165. aurelian/agents/oak/__init__.py +0 -0
  166. aurelian/agents/oak/oak_config.py +27 -0
  167. aurelian/agents/oak/oak_gradio.py +57 -0
  168. aurelian/agents/ontology_mapper/__init__.py +31 -0
  169. aurelian/agents/ontology_mapper/ontology_mapper_agent.py +57 -0
  170. aurelian/agents/ontology_mapper/ontology_mapper_config.py +50 -0
  171. aurelian/agents/ontology_mapper/ontology_mapper_evals.py +108 -0
  172. aurelian/agents/ontology_mapper/ontology_mapper_gradio.py +58 -0
  173. aurelian/agents/ontology_mapper/ontology_mapper_mcp.py +81 -0
  174. aurelian/agents/ontology_mapper/ontology_mapper_tools.py +147 -0
  175. aurelian/agents/paperqa/__init__.py +27 -0
  176. aurelian/agents/paperqa/paperqa_agent.py +66 -0
  177. aurelian/agents/paperqa/paperqa_cli.py +305 -0
  178. aurelian/agents/paperqa/paperqa_config.py +142 -0
  179. aurelian/agents/paperqa/paperqa_gradio.py +90 -0
  180. aurelian/agents/paperqa/paperqa_mcp.py +155 -0
  181. aurelian/agents/paperqa/paperqa_tools.py +566 -0
  182. aurelian/agents/phenopackets/__init__.py +3 -0
  183. aurelian/agents/phenopackets/phenopackets_agent.py +58 -0
  184. aurelian/agents/phenopackets/phenopackets_config.py +72 -0
  185. aurelian/agents/phenopackets/phenopackets_evals.py +99 -0
  186. aurelian/agents/phenopackets/phenopackets_gradio.py +55 -0
  187. aurelian/agents/phenopackets/phenopackets_mcp.py +178 -0
  188. aurelian/agents/phenopackets/phenopackets_tools.py +127 -0
  189. aurelian/agents/rag/__init__.py +40 -0
  190. aurelian/agents/rag/rag_agent.py +84 -0
  191. aurelian/agents/rag/rag_config.py +80 -0
  192. aurelian/agents/rag/rag_gradio.py +67 -0
  193. aurelian/agents/rag/rag_mcp.py +107 -0
  194. aurelian/agents/rag/rag_tools.py +189 -0
  195. aurelian/agents/rag_agent.py +54 -0
  196. aurelian/agents/robot/__init__.py +0 -0
  197. aurelian/agents/robot/assets/__init__.py +3 -0
  198. aurelian/agents/robot/assets/template.md +384 -0
  199. aurelian/agents/robot/robot_config.py +25 -0
  200. aurelian/agents/robot/robot_gradio.py +46 -0
  201. aurelian/agents/robot/robot_mcp.py +100 -0
  202. aurelian/agents/robot/robot_ontology_agent.py +139 -0
  203. aurelian/agents/robot/robot_tools.py +50 -0
  204. aurelian/agents/talisman/__init__.py +3 -0
  205. aurelian/agents/talisman/__main__.py +17 -0
  206. aurelian/agents/talisman/cli.py +70 -0
  207. aurelian/agents/talisman/run_talisman.py +18 -0
  208. aurelian/agents/talisman/talisman_agent.py +143 -0
  209. aurelian/agents/talisman/talisman_config.py +66 -0
  210. aurelian/agents/talisman/talisman_gradio.py +50 -0
  211. aurelian/agents/talisman/talisman_mcp.py +75 -0
  212. aurelian/agents/talisman/talisman_tools.py +962 -0
  213. aurelian/agents/ubergraph/__init__.py +40 -0
  214. aurelian/agents/ubergraph/ubergraph_agent.py +72 -0
  215. aurelian/agents/ubergraph/ubergraph_config.py +79 -0
  216. aurelian/agents/ubergraph/ubergraph_gradio.py +48 -0
  217. aurelian/agents/ubergraph/ubergraph_mcp.py +69 -0
  218. aurelian/agents/ubergraph/ubergraph_tools.py +118 -0
  219. aurelian/agents/uniprot/__init__.py +0 -0
  220. aurelian/agents/uniprot/uniprot_agent.py +43 -0
  221. aurelian/agents/uniprot/uniprot_config.py +43 -0
  222. aurelian/agents/uniprot/uniprot_evals.py +99 -0
  223. aurelian/agents/uniprot/uniprot_gradio.py +48 -0
  224. aurelian/agents/uniprot/uniprot_mcp.py +168 -0
  225. aurelian/agents/uniprot/uniprot_tools.py +136 -0
  226. aurelian/agents/web/__init__.py +0 -0
  227. aurelian/agents/web/web_config.py +27 -0
  228. aurelian/agents/web/web_gradio.py +48 -0
  229. aurelian/agents/web/web_mcp.py +50 -0
  230. aurelian/agents/web/web_tools.py +121 -0
  231. aurelian/chat.py +23 -0
  232. aurelian/cli.py +1004 -0
  233. aurelian/dependencies/__init__.py +0 -0
  234. aurelian/dependencies/workdir.py +78 -0
  235. aurelian/evaluators/model.py +9 -0
  236. aurelian/evaluators/substring_evaluator.py +30 -0
  237. aurelian/mcp/__init__.py +0 -0
  238. aurelian/mcp/amigo_mcp_test.py +86 -0
  239. aurelian/mcp/config_generator.py +123 -0
  240. aurelian/mcp/example_config.json +43 -0
  241. aurelian/mcp/generate_sample_config.py +37 -0
  242. aurelian/mcp/gocam_mcp_test.py +126 -0
  243. aurelian/mcp/linkml_mcp_tools.py +190 -0
  244. aurelian/mcp/mcp_discovery.py +87 -0
  245. aurelian/mcp/mcp_test.py +31 -0
  246. aurelian/mcp/phenopackets_mcp_test.py +103 -0
  247. aurelian/tools/__init__.py +0 -0
  248. aurelian/tools/web/__init__.py +0 -0
  249. aurelian/tools/web/url_download.py +51 -0
  250. aurelian/utils/__init__.py +0 -0
  251. aurelian/utils/async_utils.py +18 -0
  252. aurelian/utils/data_utils.py +32 -0
  253. aurelian/utils/documentation_manager.py +59 -0
  254. aurelian/utils/doi_fetcher.py +238 -0
  255. aurelian/utils/ontology_utils.py +68 -0
  256. aurelian/utils/pdf_fetcher.py +23 -0
  257. aurelian/utils/process_logs.py +100 -0
  258. aurelian/utils/pubmed_utils.py +238 -0
  259. aurelian/utils/pytest_report_to_markdown.py +67 -0
  260. aurelian/utils/robot_ontology_utils.py +112 -0
  261. aurelian/utils/search_utils.py +95 -0
  262. aurelian-0.1.0.dist-info/LICENSE +22 -0
  263. aurelian-0.1.0.dist-info/METADATA +109 -0
  264. aurelian-0.1.0.dist-info/RECORD +266 -0
  265. aurelian-0.1.0.dist-info/WHEEL +4 -0
  266. aurelian-0.1.0.dist-info/entry_points.txt +4 -0
@@ -0,0 +1,142 @@
1
+ """
2
+ Configuration for the PaperQA agent.
3
+ """
4
+ from dataclasses import dataclass, field
5
+ import os
6
+ from typing import Optional, List
7
+
8
+ from paperqa import Settings as PQASettings
9
+ from paperqa.settings import (
10
+ AnswerSettings,
11
+ ParsingSettings,
12
+ PromptSettings,
13
+ AgentSettings,
14
+ IndexSettings, Settings,
15
+ )
16
+
17
+ from aurelian.dependencies.workdir import HasWorkdir, WorkDir
18
+
19
+
20
+ @dataclass
21
+ class PaperQADependencies(HasWorkdir):
22
+ """Configuration for the PaperQA agent."""
23
+
24
+ paper_directory: str = field(
25
+ default_factory=lambda: os.getcwd(),
26
+ metadata={"description": "Directory containing papers to be searched"}
27
+ )
28
+ index_name: Optional[str] = field(
29
+ default=None,
30
+ metadata={"description": "Optional name for the search index. If None, it will be generated based on settings."}
31
+ )
32
+
33
+ llm: str = field(
34
+ default="gpt-4.1-2025-04-14",
35
+ metadata={"description": "LLM to use for queries and answer generation. Default is gpt-4.1-2025-04-14."}
36
+ )
37
+ summary_llm: str = field(
38
+ default="gpt-4.1-2025-04-14",
39
+ metadata={"description": "LLM to use for summarization. Default is gpt-4.1-2025-04-14."}
40
+ )
41
+ embedding: str = field(
42
+ default="text-embedding-3-small",
43
+ metadata={"description": "Embedding model to use. Default is text-embedding-3-small."}
44
+ )
45
+ temperature: float = field(
46
+ default=0.1,
47
+ metadata={"description": "Temperature for LLM generation. Default is 0.1."}
48
+ )
49
+
50
+ search_count: int = field(
51
+ default=8,
52
+ metadata={"description": "Number of papers to retrieve in searches. Default is 8."}
53
+ )
54
+
55
+ evidence_k: int = field(
56
+ default=10,
57
+ metadata={"description": "Number of evidence pieces to retrieve. Default is 10."}
58
+ )
59
+ answer_max_sources: int = field(
60
+ default=5,
61
+ metadata={"description": "Maximum number of sources to use in answers. Default is 5."}
62
+ )
63
+ max_concurrent_requests: int = field(
64
+ default=4,
65
+ metadata={"description": "Maximum number of concurrent requests to LLMs. Default is 4."}
66
+ )
67
+
68
+ chunk_size: int = field(
69
+ default=5000,
70
+ metadata={"description": "Size of document chunks for embedding. Default is 5000."}
71
+ )
72
+ overlap: int = field(
73
+ default=250,
74
+ metadata={"description": "Overlap between chunks. Default is 250."}
75
+ )
76
+
77
+ workdir: Optional[WorkDir] = None
78
+
79
+ def __post_init__(self):
80
+ """Initialize the config with default values."""
81
+ if self.workdir is None:
82
+ self.workdir = WorkDir()
83
+
84
+ def set_paperqa_settings(self) -> PQASettings:
85
+ """
86
+ Convert to PaperQA Settings object.
87
+
88
+ This allows users to customize all PaperQA settings through the dependencies object.
89
+ Any changes to the dependencies will be reflected in the returned Settings object.
90
+ """
91
+ return PQASettings(
92
+ llm=self.llm,
93
+ summary_llm=self.summary_llm,
94
+ embedding=self.embedding,
95
+ temperature=self.temperature,
96
+
97
+ answer=AnswerSettings(
98
+ evidence_k=self.evidence_k,
99
+ answer_max_sources=self.answer_max_sources,
100
+ max_concurrent_requests=self.max_concurrent_requests,
101
+ ),
102
+
103
+ parsing=ParsingSettings(
104
+ chunk_size=self.chunk_size,
105
+ overlap=self.overlap,
106
+ ),
107
+
108
+ agent=AgentSettings(
109
+ agent_llm=self.llm,
110
+ search_count=self.search_count,
111
+ index=IndexSettings(
112
+ name=self.index_name,
113
+ paper_directory=self.paper_directory,
114
+ recurse_subdirectories=False,
115
+ ),
116
+ ),
117
+ )
118
+
119
+
120
+ def get_config() -> PaperQADependencies:
121
+ """
122
+ Get the PaperQA configuration from environment variables or defaults.
123
+
124
+ Returns:
125
+ A PaperQADependencies instance with default settings.
126
+
127
+ Note:
128
+ Users can modify the returned object to customize settings.
129
+ Example:
130
+ ```python
131
+ deps = get_config()
132
+ deps.llm = "claude-3-sonnet-20240229" # Use Claude instead of default GPT-4
133
+ deps.temperature = 0.5 # Increase temperature
134
+ deps.evidence_k = 15 # Retrieve more evidence
135
+ ```
136
+ """
137
+ workdir_path = os.environ.get("AURELIAN_WORKDIR", None)
138
+ workdir = WorkDir(location=workdir_path) if workdir_path else None
139
+
140
+ return PaperQADependencies(
141
+ workdir=workdir,
142
+ )
@@ -0,0 +1,90 @@
1
+ """
2
+ Gradio interface for the PaperQA agent.
3
+ """
4
+ import os
5
+ import logging
6
+ from typing import List, Optional, Any
7
+
8
+ import gradio as gr
9
+
10
+ from aurelian.utils.async_utils import run_sync
11
+ from .paperqa_agent import paperqa_agent
12
+ from .paperqa_config import PaperQADependencies, get_config
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ async def get_info(query: str, history: List[str], deps: PaperQADependencies, **kwargs) -> str:
18
+ """
19
+ Process a query using the PaperQA agent.
20
+
21
+ Args:
22
+ query: The user query
23
+ history: The conversation history
24
+ deps: The dependencies for the agent
25
+ model: Optional model override
26
+
27
+ Returns:
28
+ The agent's response
29
+ """
30
+ logger.info(f"QUERY: {query}")
31
+ logger.debug(f"HISTORY: {history}")
32
+
33
+ if history:
34
+ query += "\n\n## Previous Conversation:\n"
35
+ for h in history:
36
+ query += f"\n{h}"
37
+
38
+ result = await paperqa_agent.run(query, deps=deps, **kwargs)
39
+ return result.data
40
+
41
+
42
+ def chat(deps: Optional[PaperQADependencies] = None, model=None, **kwargs):
43
+ """
44
+ Create a Gradio chat interface for the PaperQA agent.
45
+
46
+ Args:
47
+ deps: Optional dependencies configuration
48
+ model: Optional model override
49
+ kwargs: Additional keyword arguments for dependencies
50
+
51
+ Returns:
52
+ A Gradio ChatInterface
53
+ """
54
+ if deps is None:
55
+ deps = get_config()
56
+
57
+ for key, value in kwargs.items():
58
+ if hasattr(deps, key):
59
+ setattr(deps, key, value)
60
+
61
+ paper_dir = os.path.join(os.getcwd(), "pqa_source")
62
+ os.makedirs(paper_dir, exist_ok=True)
63
+ deps.paper_directory = paper_dir
64
+ os.environ["PQA_HOME"] = paper_dir
65
+ print(f"Using dedicated papers directory at: {paper_dir}")
66
+
67
+ def get_info_wrapper(query: str, history: List[str]) -> str:
68
+ """Wrapper for the async get_info function."""
69
+ import asyncio
70
+ return asyncio.run(get_info(query, history, deps, **kwargs))
71
+
72
+ return gr.ChatInterface(
73
+ fn=get_info_wrapper,
74
+ type="messages",
75
+ title="PaperQA AI Assistant",
76
+ description="""This assistant helps you search and analyze scientific papers. You can:
77
+ - Search for papers on a topic
78
+ - Ask questions about the papers in the repository
79
+ - Add specific papers by path or URL: (if paths, use absolute paths!)"
80
+ - Add multiple papers from a directory: (use absolute paths!)"
81
+ - List all papers in the collection
82
+
83
+ Supported document types: PDF, TXT, HTML, and Markdown files""",
84
+ examples=[
85
+ ["Search for papers on CRISPR gene editing"],
86
+ ["What are the main challenges in CRISPR gene editing?"],
87
+ ["What is the relationship between CRISPR and Cas9?"],
88
+ ["List all the indexed papers"],
89
+ ],
90
+ )
@@ -0,0 +1,155 @@
1
+ """
2
+ MCP tools for working with PaperQA for scientific literature search and analysis.
3
+ """
4
+ import os
5
+ from typing import Dict, List, Any, Optional
6
+
7
+ from mcp.server.fastmcp import FastMCP
8
+
9
+ import aurelian.agents.paperqa.paperqa_tools as pt
10
+ from aurelian.agents.paperqa.paperqa_agent import paperqa_agent, PAPERQA_SYSTEM_PROMPT
11
+ from aurelian.agents.paperqa.paperqa_config import PaperQADependencies
12
+ from pydantic_ai import RunContext
13
+
14
+ mcp = FastMCP("paperqa", instructions=PAPERQA_SYSTEM_PROMPT.strip())
15
+
16
+
17
+ from aurelian.dependencies.workdir import WorkDir
18
+
19
+ def deps() -> PaperQADependencies:
20
+ deps = PaperQADependencies()
21
+ loc = os.getenv("AURELIAN_WORKDIR", "/tmp/paperqa")
22
+ deps.workdir = WorkDir(loc)
23
+
24
+ paper_dir = os.getenv("PAPERQA_PAPER_DIRECTORY", os.path.join(loc, "papers"))
25
+ deps.paper_directory = paper_dir
26
+
27
+ if os.getenv("PAPERQA_LLM"):
28
+ deps.llm = os.getenv("PAPERQA_LLM")
29
+
30
+ if os.getenv("PAPERQA_EMBEDDING"):
31
+ deps.embedding = os.getenv("PAPERQA_EMBEDDING")
32
+
33
+ return deps
34
+
35
+ def ctx() -> RunContext[PaperQADependencies]:
36
+ rc: RunContext[PaperQADependencies] = RunContext[PaperQADependencies](
37
+ deps=deps(),
38
+ model=None, usage=None, prompt=None,
39
+ )
40
+ return rc
41
+
42
+
43
+ @mcp.tool()
44
+ async def search_papers(query: str, max_papers: Optional[int] = None) -> Any:
45
+ """
46
+ Search for papers relevant to the query using PaperQA.
47
+
48
+ Args:
49
+ query: The search query for scientific papers
50
+ max_papers: Maximum number of papers to return (overrides config)
51
+
52
+ Returns:
53
+ The search results with paper information
54
+
55
+ This searches for scientific papers based on your query. It returns papers
56
+ that are most relevant to the topic you're searching for. You can optionally
57
+ specify a maximum number of papers to return.
58
+ """
59
+ return await pt.search_papers(ctx(), query, max_papers)
60
+
61
+
62
+ @mcp.tool()
63
+ async def query_papers(query: str) -> Any:
64
+ """
65
+ Query the papers to answer a specific question using PaperQA.
66
+
67
+ Args:
68
+ query: The question to answer based on the papers
69
+
70
+ Returns:
71
+ Detailed answer with citations from the papers
72
+
73
+ This tool analyzes the papers in your collection to provide an evidence-based
74
+ answer to your question. It extracts relevant information from across papers
75
+ and synthesizes a response with citations to the source papers.
76
+ """
77
+ return await pt.query_papers(ctx(), query)
78
+
79
+
80
+ @mcp.tool()
81
+ async def add_paper(path: str, citation: Optional[str] = None) -> Any:
82
+ """
83
+ Add a specific paper to the collection.
84
+
85
+ Args:
86
+ path: Path to the paper file or URL
87
+ citation: Optional citation for the paper
88
+
89
+ Returns:
90
+ Information about the added paper
91
+
92
+ You can add a paper by providing its file path (PDF) or a URL to the paper
93
+ (must be accessible). The paper will be added to your collection for searching
94
+ and querying. You can optionally provide a citation string.
95
+ """
96
+ return await pt.add_paper(ctx(), path, citation)
97
+
98
+ @mcp.tool()
99
+ async def add_papers(path: str,) -> Any:
100
+ """
101
+ Add multiple papers to the collection.
102
+ Args:
103
+ path: Path to the paper file or URL
104
+ citation: Optional citation for the paper
105
+
106
+ Returns:
107
+ Informations about the added papers
108
+
109
+ You can add multiple papers by providing its file path (PDF) or a URL to the
110
+ paper (must be accessible). The paper will be added to your collection for
111
+ searching and querying.
112
+ """
113
+ return await pt.add_papers(ctx(), path)
114
+
115
+
116
+ @mcp.tool()
117
+ async def list_papers() -> Any:
118
+ """
119
+ List all papers in the current paper directory.
120
+
121
+ Args:
122
+ None
123
+
124
+ Returns:
125
+ Information about all papers in the paper directory
126
+
127
+ This lists all papers currently in your collection, showing their file paths and
128
+ any other available metadata. Use this to see what papers you have available
129
+ for searching and querying.
130
+ """
131
+ return await pt.list_papers(ctx())
132
+
133
+
134
+ @mcp.tool()
135
+ async def build_index() -> Any:
136
+ """
137
+ Rebuild the search index for papers.
138
+
139
+ Args:
140
+ None
141
+
142
+ Returns:
143
+ Information about the indexing process
144
+
145
+ This rebuilds the search index for all papers in your paper directory.
146
+ The index is required for searching and querying papers. You should run this
147
+ after adding new papers to make them searchable.
148
+ """
149
+ return await pt.build_index(ctx())
150
+
151
+
152
+ if __name__ == "__main__":
153
+ print("Running the PaperQA MCP server")
154
+ print("Use Ctrl-C to exit")
155
+ mcp.run(transport='stdio')