aurelian 0.3.2__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.
- aurelian/__init__.py +9 -0
- aurelian/agents/__init__.py +0 -0
- aurelian/agents/amigo/__init__.py +3 -0
- aurelian/agents/amigo/amigo_agent.py +77 -0
- aurelian/agents/amigo/amigo_config.py +85 -0
- aurelian/agents/amigo/amigo_evals.py +73 -0
- aurelian/agents/amigo/amigo_gradio.py +52 -0
- aurelian/agents/amigo/amigo_mcp.py +152 -0
- aurelian/agents/amigo/amigo_tools.py +152 -0
- aurelian/agents/biblio/__init__.py +42 -0
- aurelian/agents/biblio/biblio_agent.py +94 -0
- aurelian/agents/biblio/biblio_config.py +40 -0
- aurelian/agents/biblio/biblio_gradio.py +67 -0
- aurelian/agents/biblio/biblio_mcp.py +115 -0
- aurelian/agents/biblio/biblio_tools.py +164 -0
- aurelian/agents/biblio_agent.py +46 -0
- aurelian/agents/checklist/__init__.py +44 -0
- aurelian/agents/checklist/checklist_agent.py +85 -0
- aurelian/agents/checklist/checklist_config.py +28 -0
- aurelian/agents/checklist/checklist_gradio.py +70 -0
- aurelian/agents/checklist/checklist_mcp.py +86 -0
- aurelian/agents/checklist/checklist_tools.py +141 -0
- aurelian/agents/checklist/content/checklists.yaml +7 -0
- aurelian/agents/checklist/content/streams.csv +136 -0
- aurelian/agents/checklist_agent.py +40 -0
- aurelian/agents/chemistry/__init__.py +3 -0
- aurelian/agents/chemistry/chemistry_agent.py +46 -0
- aurelian/agents/chemistry/chemistry_config.py +71 -0
- aurelian/agents/chemistry/chemistry_evals.py +79 -0
- aurelian/agents/chemistry/chemistry_gradio.py +50 -0
- aurelian/agents/chemistry/chemistry_mcp.py +120 -0
- aurelian/agents/chemistry/chemistry_tools.py +121 -0
- aurelian/agents/chemistry/image_agent.py +15 -0
- aurelian/agents/d4d/__init__.py +30 -0
- aurelian/agents/d4d/d4d_agent.py +72 -0
- aurelian/agents/d4d/d4d_config.py +46 -0
- aurelian/agents/d4d/d4d_gradio.py +58 -0
- aurelian/agents/d4d/d4d_mcp.py +71 -0
- aurelian/agents/d4d/d4d_tools.py +157 -0
- aurelian/agents/d4d_agent.py +64 -0
- aurelian/agents/diagnosis/__init__.py +33 -0
- aurelian/agents/diagnosis/diagnosis_agent.py +53 -0
- aurelian/agents/diagnosis/diagnosis_config.py +48 -0
- aurelian/agents/diagnosis/diagnosis_evals.py +76 -0
- aurelian/agents/diagnosis/diagnosis_gradio.py +52 -0
- aurelian/agents/diagnosis/diagnosis_mcp.py +141 -0
- aurelian/agents/diagnosis/diagnosis_tools.py +204 -0
- aurelian/agents/diagnosis_agent.py +28 -0
- aurelian/agents/draw/__init__.py +3 -0
- aurelian/agents/draw/draw_agent.py +39 -0
- aurelian/agents/draw/draw_config.py +26 -0
- aurelian/agents/draw/draw_gradio.py +50 -0
- aurelian/agents/draw/draw_mcp.py +94 -0
- aurelian/agents/draw/draw_tools.py +100 -0
- aurelian/agents/draw/judge_agent.py +18 -0
- aurelian/agents/filesystem/__init__.py +0 -0
- aurelian/agents/filesystem/filesystem_config.py +27 -0
- aurelian/agents/filesystem/filesystem_gradio.py +49 -0
- aurelian/agents/filesystem/filesystem_mcp.py +89 -0
- aurelian/agents/filesystem/filesystem_tools.py +95 -0
- aurelian/agents/filesystem/py.typed +0 -0
- aurelian/agents/github/__init__.py +0 -0
- aurelian/agents/github/github_agent.py +83 -0
- aurelian/agents/github/github_cli.py +248 -0
- aurelian/agents/github/github_config.py +22 -0
- aurelian/agents/github/github_gradio.py +152 -0
- aurelian/agents/github/github_mcp.py +252 -0
- aurelian/agents/github/github_tools.py +408 -0
- aurelian/agents/github/github_tools.py.tmp +413 -0
- aurelian/agents/goann/__init__.py +13 -0
- aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines.md +1000 -0
- aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines.pdf +0 -0
- aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines_Paper.md +693 -0
- aurelian/agents/goann/documents/Transcription_Factors_Annotation_Guidelines_Paper.pdf +0 -0
- aurelian/agents/goann/goann_agent.py +90 -0
- aurelian/agents/goann/goann_config.py +90 -0
- aurelian/agents/goann/goann_evals.py +104 -0
- aurelian/agents/goann/goann_gradio.py +62 -0
- aurelian/agents/goann/goann_mcp.py +0 -0
- aurelian/agents/goann/goann_tools.py +65 -0
- aurelian/agents/gocam/__init__.py +43 -0
- aurelian/agents/gocam/documents/DNA-binding transcription factor activity annotation guidelines.docx +0 -0
- aurelian/agents/gocam/documents/DNA-binding transcription factor activity annotation guidelines.pdf +0 -0
- aurelian/agents/gocam/documents/DNA-binding_transcription_factor_activity_annotation_guidelines.md +100 -0
- aurelian/agents/gocam/documents/E3 ubiquitin ligases.docx +0 -0
- aurelian/agents/gocam/documents/E3 ubiquitin ligases.pdf +0 -0
- aurelian/agents/gocam/documents/E3_ubiquitin_ligases.md +134 -0
- aurelian/agents/gocam/documents/GO-CAM annotation guidelines README.docx +0 -0
- aurelian/agents/gocam/documents/GO-CAM annotation guidelines README.pdf +0 -0
- aurelian/agents/gocam/documents/GO-CAM modelling guidelines TO DO.docx +0 -0
- aurelian/agents/gocam/documents/GO-CAM modelling guidelines TO DO.pdf +0 -0
- aurelian/agents/gocam/documents/GO-CAM_annotation_guidelines_README.md +1 -0
- aurelian/agents/gocam/documents/GO-CAM_modelling_guidelines_TO_DO.md +3 -0
- aurelian/agents/gocam/documents/How to annotate complexes in GO-CAM.docx +0 -0
- aurelian/agents/gocam/documents/How to annotate complexes in GO-CAM.pdf +0 -0
- aurelian/agents/gocam/documents/How to annotate molecular adaptors.docx +0 -0
- aurelian/agents/gocam/documents/How to annotate molecular adaptors.pdf +0 -0
- aurelian/agents/gocam/documents/How to annotate sequestering proteins.docx +0 -0
- aurelian/agents/gocam/documents/How to annotate sequestering proteins.pdf +0 -0
- aurelian/agents/gocam/documents/How_to_annotate_complexes_in_GO-CAM.md +29 -0
- aurelian/agents/gocam/documents/How_to_annotate_molecular_adaptors.md +31 -0
- aurelian/agents/gocam/documents/How_to_annotate_sequestering_proteins.md +42 -0
- aurelian/agents/gocam/documents/Molecular adaptor activity.docx +0 -0
- aurelian/agents/gocam/documents/Molecular adaptor activity.pdf +0 -0
- aurelian/agents/gocam/documents/Molecular carrier activity.docx +0 -0
- aurelian/agents/gocam/documents/Molecular carrier activity.pdf +0 -0
- aurelian/agents/gocam/documents/Molecular_adaptor_activity.md +51 -0
- aurelian/agents/gocam/documents/Molecular_carrier_activity.md +41 -0
- aurelian/agents/gocam/documents/Protein sequestering activity.docx +0 -0
- aurelian/agents/gocam/documents/Protein sequestering activity.pdf +0 -0
- aurelian/agents/gocam/documents/Protein_sequestering_activity.md +50 -0
- aurelian/agents/gocam/documents/Signaling receptor activity annotation guidelines.docx +0 -0
- aurelian/agents/gocam/documents/Signaling receptor activity annotation guidelines.pdf +0 -0
- aurelian/agents/gocam/documents/Signaling_receptor_activity_annotation_guidelines.md +187 -0
- aurelian/agents/gocam/documents/Transcription coregulator activity.docx +0 -0
- aurelian/agents/gocam/documents/Transcription coregulator activity.pdf +0 -0
- aurelian/agents/gocam/documents/Transcription_coregulator_activity.md +36 -0
- aurelian/agents/gocam/documents/Transporter activity annotation annotation guidelines.docx +0 -0
- aurelian/agents/gocam/documents/Transporter activity annotation annotation guidelines.pdf +0 -0
- aurelian/agents/gocam/documents/Transporter_activity_annotation_annotation_guidelines.md +43 -0
- Regulatory Processes in GO-CAM.docx +0 -0
- Regulatory Processes in GO-CAM.pdf +0 -0
- aurelian/agents/gocam/documents/WIP_-_Regulation_and_Regulatory_Processes_in_GO-CAM.md +31 -0
- aurelian/agents/gocam/documents/md/DNA-binding_transcription_factor_activity_annotation_guidelines.md +131 -0
- aurelian/agents/gocam/documents/md/E3_ubiquitin_ligases.md +166 -0
- aurelian/agents/gocam/documents/md/GO-CAM_annotation_guidelines_README.md +1 -0
- aurelian/agents/gocam/documents/md/GO-CAM_modelling_guidelines_TO_DO.md +5 -0
- aurelian/agents/gocam/documents/md/How_to_annotate_complexes_in_GO-CAM.md +28 -0
- aurelian/agents/gocam/documents/md/How_to_annotate_molecular_adaptors.md +19 -0
- aurelian/agents/gocam/documents/md/How_to_annotate_sequestering_proteins.md +38 -0
- aurelian/agents/gocam/documents/md/Molecular_adaptor_activity.md +52 -0
- aurelian/agents/gocam/documents/md/Molecular_carrier_activity.md +59 -0
- aurelian/agents/gocam/documents/md/Protein_sequestering_activity.md +52 -0
- aurelian/agents/gocam/documents/md/Signaling_receptor_activity_annotation_guidelines.md +271 -0
- aurelian/agents/gocam/documents/md/Transcription_coregulator_activity.md +54 -0
- aurelian/agents/gocam/documents/md/Transporter_activity_annotation_annotation_guidelines.md +38 -0
- aurelian/agents/gocam/documents/md/WIP_-_Regulation_and_Regulatory_Processes_in_GO-CAM.md +39 -0
- aurelian/agents/gocam/documents/pandoc_md/Signaling_receptor_activity_annotation_guidelines.md +334 -0
- aurelian/agents/gocam/gocam_agent.py +240 -0
- aurelian/agents/gocam/gocam_config.py +85 -0
- aurelian/agents/gocam/gocam_curator_agent.py +46 -0
- aurelian/agents/gocam/gocam_evals.py +67 -0
- aurelian/agents/gocam/gocam_gradio.py +89 -0
- aurelian/agents/gocam/gocam_mcp.py +224 -0
- aurelian/agents/gocam/gocam_tools.py +294 -0
- aurelian/agents/linkml/__init__.py +0 -0
- aurelian/agents/linkml/linkml_agent.py +62 -0
- aurelian/agents/linkml/linkml_config.py +48 -0
- aurelian/agents/linkml/linkml_evals.py +66 -0
- aurelian/agents/linkml/linkml_gradio.py +45 -0
- aurelian/agents/linkml/linkml_mcp.py +186 -0
- aurelian/agents/linkml/linkml_tools.py +102 -0
- aurelian/agents/literature/__init__.py +3 -0
- aurelian/agents/literature/literature_agent.py +55 -0
- aurelian/agents/literature/literature_config.py +35 -0
- aurelian/agents/literature/literature_gradio.py +52 -0
- aurelian/agents/literature/literature_mcp.py +174 -0
- aurelian/agents/literature/literature_tools.py +182 -0
- aurelian/agents/monarch/__init__.py +25 -0
- aurelian/agents/monarch/monarch_agent.py +44 -0
- aurelian/agents/monarch/monarch_config.py +45 -0
- aurelian/agents/monarch/monarch_gradio.py +51 -0
- aurelian/agents/monarch/monarch_mcp.py +65 -0
- aurelian/agents/monarch/monarch_tools.py +113 -0
- aurelian/agents/oak/__init__.py +0 -0
- aurelian/agents/oak/oak_config.py +27 -0
- aurelian/agents/oak/oak_gradio.py +57 -0
- aurelian/agents/ontology_mapper/__init__.py +31 -0
- aurelian/agents/ontology_mapper/ontology_mapper_agent.py +56 -0
- aurelian/agents/ontology_mapper/ontology_mapper_config.py +50 -0
- aurelian/agents/ontology_mapper/ontology_mapper_evals.py +108 -0
- aurelian/agents/ontology_mapper/ontology_mapper_gradio.py +58 -0
- aurelian/agents/ontology_mapper/ontology_mapper_mcp.py +81 -0
- aurelian/agents/ontology_mapper/ontology_mapper_tools.py +147 -0
- aurelian/agents/phenopackets/__init__.py +3 -0
- aurelian/agents/phenopackets/phenopackets_agent.py +58 -0
- aurelian/agents/phenopackets/phenopackets_config.py +72 -0
- aurelian/agents/phenopackets/phenopackets_evals.py +99 -0
- aurelian/agents/phenopackets/phenopackets_gradio.py +55 -0
- aurelian/agents/phenopackets/phenopackets_mcp.py +178 -0
- aurelian/agents/phenopackets/phenopackets_tools.py +127 -0
- aurelian/agents/rag/__init__.py +40 -0
- aurelian/agents/rag/rag_agent.py +83 -0
- aurelian/agents/rag/rag_config.py +80 -0
- aurelian/agents/rag/rag_gradio.py +67 -0
- aurelian/agents/rag/rag_mcp.py +107 -0
- aurelian/agents/rag/rag_tools.py +189 -0
- aurelian/agents/rag_agent.py +54 -0
- aurelian/agents/robot/__init__.py +0 -0
- aurelian/agents/robot/assets/__init__.py +3 -0
- aurelian/agents/robot/assets/template.md +384 -0
- aurelian/agents/robot/robot_config.py +25 -0
- aurelian/agents/robot/robot_gradio.py +46 -0
- aurelian/agents/robot/robot_mcp.py +100 -0
- aurelian/agents/robot/robot_ontology_agent.py +139 -0
- aurelian/agents/robot/robot_tools.py +50 -0
- aurelian/agents/talisman/__init__.py +3 -0
- aurelian/agents/talisman/talisman_agent.py +126 -0
- aurelian/agents/talisman/talisman_config.py +66 -0
- aurelian/agents/talisman/talisman_gradio.py +50 -0
- aurelian/agents/talisman/talisman_mcp.py +168 -0
- aurelian/agents/talisman/talisman_tools.py +720 -0
- aurelian/agents/ubergraph/__init__.py +40 -0
- aurelian/agents/ubergraph/ubergraph_agent.py +71 -0
- aurelian/agents/ubergraph/ubergraph_config.py +79 -0
- aurelian/agents/ubergraph/ubergraph_gradio.py +48 -0
- aurelian/agents/ubergraph/ubergraph_mcp.py +69 -0
- aurelian/agents/ubergraph/ubergraph_tools.py +118 -0
- aurelian/agents/uniprot/__init__.py +37 -0
- aurelian/agents/uniprot/uniprot_agent.py +43 -0
- aurelian/agents/uniprot/uniprot_config.py +43 -0
- aurelian/agents/uniprot/uniprot_evals.py +99 -0
- aurelian/agents/uniprot/uniprot_gradio.py +48 -0
- aurelian/agents/uniprot/uniprot_mcp.py +168 -0
- aurelian/agents/uniprot/uniprot_tools.py +136 -0
- aurelian/agents/web/__init__.py +0 -0
- aurelian/agents/web/web_config.py +27 -0
- aurelian/agents/web/web_gradio.py +48 -0
- aurelian/agents/web/web_mcp.py +50 -0
- aurelian/agents/web/web_tools.py +108 -0
- aurelian/chat.py +23 -0
- aurelian/cli.py +800 -0
- aurelian/dependencies/__init__.py +0 -0
- aurelian/dependencies/workdir.py +78 -0
- aurelian/mcp/__init__.py +0 -0
- aurelian/mcp/amigo_mcp_test.py +86 -0
- aurelian/mcp/config_generator.py +123 -0
- aurelian/mcp/example_config.json +43 -0
- aurelian/mcp/generate_sample_config.py +37 -0
- aurelian/mcp/gocam_mcp_test.py +126 -0
- aurelian/mcp/linkml_mcp_tools.py +190 -0
- aurelian/mcp/mcp_discovery.py +87 -0
- aurelian/mcp/mcp_test.py +31 -0
- aurelian/mcp/phenopackets_mcp_test.py +103 -0
- aurelian/tools/__init__.py +0 -0
- aurelian/tools/web/__init__.py +0 -0
- aurelian/tools/web/url_download.py +51 -0
- aurelian/utils/__init__.py +0 -0
- aurelian/utils/async_utils.py +15 -0
- aurelian/utils/data_utils.py +32 -0
- aurelian/utils/documentation_manager.py +59 -0
- aurelian/utils/doi_fetcher.py +238 -0
- aurelian/utils/ontology_utils.py +68 -0
- aurelian/utils/pdf_fetcher.py +23 -0
- aurelian/utils/process_logs.py +100 -0
- aurelian/utils/pubmed_utils.py +238 -0
- aurelian/utils/pytest_report_to_markdown.py +67 -0
- aurelian/utils/robot_ontology_utils.py +112 -0
- aurelian/utils/search_utils.py +95 -0
- aurelian-0.3.2.dist-info/LICENSE +22 -0
- aurelian-0.3.2.dist-info/METADATA +105 -0
- aurelian-0.3.2.dist-info/RECORD +254 -0
- aurelian-0.3.2.dist-info/WHEEL +4 -0
- aurelian-0.3.2.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
from pydantic_ai import Agent, Tool, RunContext
|
2
|
+
|
3
|
+
from aurelian.agents.gocam import GOCAMDependencies, validate_gocam_model
|
4
|
+
from aurelian.agents.gocam.gocam_agent import PREDICATES_INFO, SYSTEM_CURIES, core_tools, \
|
5
|
+
get_documents_for_prompt
|
6
|
+
from aurelian.agents.gocam.gocam_tools import lookup_gocam_local
|
7
|
+
|
8
|
+
CURATOR_SYSTEM = f"""
|
9
|
+
You are a GO-CAM curator in charge of curating GO-CAMs.
|
10
|
+
|
11
|
+
When curating a GO-CAM, you should first review all relevant information:
|
12
|
+
|
13
|
+
- read the relevant papers provided to you `literature_lookup_pmid`
|
14
|
+
- find any additional references or papers of relevance `lookup_uniprot_entry`
|
15
|
+
- check the relevant GO-CAM best practices (see `fetch_document`)
|
16
|
+
- find the right uniprot IDs, and check what information is known `lookup_uniprot_entry`
|
17
|
+
- find the relevant GO and ontology terms `lookup_go_term`
|
18
|
+
|
19
|
+
{PREDICATES_INFO}
|
20
|
+
|
21
|
+
{SYSTEM_CURIES}
|
22
|
+
"""
|
23
|
+
gocam_curator_agent = Agent(
|
24
|
+
model="anthropic:claude-3-7-sonnet-latest",
|
25
|
+
deps_type=GOCAMDependencies,
|
26
|
+
system_prompt=CURATOR_SYSTEM,
|
27
|
+
tools=[
|
28
|
+
*core_tools,
|
29
|
+
Tool(lookup_gocam_local),
|
30
|
+
Tool(validate_gocam_model),
|
31
|
+
],
|
32
|
+
)
|
33
|
+
|
34
|
+
|
35
|
+
@gocam_curator_agent.system_prompt
|
36
|
+
def add_documents(ctx: RunContext[GOCAMDependencies]) -> str:
|
37
|
+
"""
|
38
|
+
Add available GO-CAM documents to the system prompt.
|
39
|
+
|
40
|
+
Args:
|
41
|
+
ctx: The run context
|
42
|
+
|
43
|
+
Returns:
|
44
|
+
A string containing the list of available GO-CAM documents
|
45
|
+
"""
|
46
|
+
return get_documents_for_prompt()
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"""
|
2
|
+
Evaluation module for the GO-CAM agent.
|
3
|
+
|
4
|
+
This module implements evaluations for the GO-CAM agent using the pydantic-ai-evals framework.
|
5
|
+
"""
|
6
|
+
import asyncio
|
7
|
+
import sys
|
8
|
+
from typing import Optional, Any, Dict, Callable, Awaitable
|
9
|
+
|
10
|
+
from aurelian.evaluators.model import MetadataDict, metadata
|
11
|
+
from aurelian.evaluators.substring_evaluator import SubstringEvaluator
|
12
|
+
from pydantic_evals import Case, Dataset
|
13
|
+
|
14
|
+
from aurelian.agents.gocam.gocam_agent import gocam_agent
|
15
|
+
from aurelian.agents.gocam.gocam_config import GOCAMDependencies
|
16
|
+
|
17
|
+
class GOCAMMetadata(Dict[str, Any]):
|
18
|
+
"""Simple metadata dictionary for GO-CAM evaluations."""
|
19
|
+
pass
|
20
|
+
|
21
|
+
# Define individual evaluation cases
|
22
|
+
case1 = Case(
|
23
|
+
name="apoptosis_genes",
|
24
|
+
inputs="Find a model relating to apoptosis and list their genes",
|
25
|
+
expected_output="CASP",
|
26
|
+
metadata=metadata("medium", "information_retrieval")
|
27
|
+
)
|
28
|
+
|
29
|
+
case2 = Case(
|
30
|
+
name="count_gene_products",
|
31
|
+
inputs="How many distinct gene products in 62b4ffe300001804? Answer with a number, e.g. 7.",
|
32
|
+
expected_output="4",
|
33
|
+
metadata=metadata("easy", "counting")
|
34
|
+
)
|
35
|
+
|
36
|
+
case3 = Case(
|
37
|
+
name="nonexistent_model",
|
38
|
+
inputs="Find a model with ID gomodel:1234 and summarize it",
|
39
|
+
expected_output=None, # Just checking the agent doesn't error out
|
40
|
+
metadata=metadata("medium", "error_handling")
|
41
|
+
)
|
42
|
+
|
43
|
+
case4 = Case(
|
44
|
+
name="signaling_receptor_id",
|
45
|
+
inputs="When curating GO-CAMs, the activity unit for a ligand of a signaling receptor should use which GO MF ID for the activity unit?",
|
46
|
+
expected_output="0048018",
|
47
|
+
metadata=metadata("hard", "knowledge_retrieval")
|
48
|
+
)
|
49
|
+
|
50
|
+
def create_eval_dataset() -> Dataset[str, str, MetadataDict]:
|
51
|
+
"""
|
52
|
+
Create a dataset for evaluating the GO-CAM agent.
|
53
|
+
|
54
|
+
Returns:
|
55
|
+
Dataset of GO-CAM evaluation cases with appropriate evaluators
|
56
|
+
"""
|
57
|
+
# Collect all cases
|
58
|
+
cases = [case1, case2, case3, case4]
|
59
|
+
|
60
|
+
# Dataset-level evaluators
|
61
|
+
evaluators = [SubstringEvaluator()]
|
62
|
+
|
63
|
+
return Dataset(
|
64
|
+
cases=cases,
|
65
|
+
evaluators=evaluators
|
66
|
+
)
|
67
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"""
|
2
|
+
Gradio UI for the GOCAM agent.
|
3
|
+
"""
|
4
|
+
from typing import List, Optional
|
5
|
+
|
6
|
+
import gradio as gr
|
7
|
+
|
8
|
+
from aurelian.agents.gocam.gocam_agent import gocam_agent
|
9
|
+
from aurelian.agents.gocam.gocam_config import GOCAMDependencies
|
10
|
+
from aurelian.utils.async_utils import run_sync
|
11
|
+
|
12
|
+
|
13
|
+
def ui():
|
14
|
+
"""
|
15
|
+
Initialize a basic interface for the GOCAM agent (non-chat).
|
16
|
+
|
17
|
+
Returns:
|
18
|
+
A Gradio interface
|
19
|
+
"""
|
20
|
+
deps = GOCAMDependencies()
|
21
|
+
|
22
|
+
def get_info(query: str):
|
23
|
+
print(f"QUERY: {query}")
|
24
|
+
result = run_sync(lambda: gocam_agent.run_sync(query, deps=deps))
|
25
|
+
return result.data
|
26
|
+
|
27
|
+
demo = gr.Interface(
|
28
|
+
fn=get_info,
|
29
|
+
inputs=gr.Textbox(
|
30
|
+
label="Ask about any GO-CAMs", placeholder="What is the function of caspase genes in apoptosis pathways?"
|
31
|
+
),
|
32
|
+
outputs=gr.Textbox(label="GO-CAM Information"),
|
33
|
+
title="GO-CAM AI Assistant",
|
34
|
+
description="Ask me anything about GO-CAMs and I will try to provide you with the information you need.",
|
35
|
+
)
|
36
|
+
return demo
|
37
|
+
|
38
|
+
|
39
|
+
def chat(deps: Optional[GOCAMDependencies] = None, db_path: Optional[str] = None, collection_name: Optional[str] = None, **kwargs):
|
40
|
+
"""
|
41
|
+
Initialize a chat interface for the GOCAM agent.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
deps: Optional dependencies configuration
|
45
|
+
db_path: Optional database path, defaults to MongoDB localhost
|
46
|
+
collection_name: Optional collection name, defaults to "main"
|
47
|
+
**kwargs: Additional arguments to pass to the agent
|
48
|
+
|
49
|
+
Returns:
|
50
|
+
A Gradio chat interface
|
51
|
+
"""
|
52
|
+
if deps is None:
|
53
|
+
deps = GOCAMDependencies()
|
54
|
+
|
55
|
+
if db_path:
|
56
|
+
deps.db_path = db_path
|
57
|
+
if collection_name:
|
58
|
+
deps.collection_name = collection_name
|
59
|
+
|
60
|
+
def get_info(query: str, history: List[str]) -> str:
|
61
|
+
print(f"QUERY: {query}")
|
62
|
+
print(f"HISTORY: {history}")
|
63
|
+
if history:
|
64
|
+
query += "## History"
|
65
|
+
for h in history:
|
66
|
+
query += f"\n{h}"
|
67
|
+
result = run_sync(lambda: gocam_agent.run_sync(query, deps=deps, **kwargs))
|
68
|
+
return result.data
|
69
|
+
|
70
|
+
return gr.ChatInterface(
|
71
|
+
fn=get_info,
|
72
|
+
type="messages",
|
73
|
+
title="GO-CAM AI Assistant",
|
74
|
+
examples=[
|
75
|
+
["What is the function of caspase genes in apoptosis pathways?"],
|
76
|
+
["What models involve autophagy?"],
|
77
|
+
[
|
78
|
+
(
|
79
|
+
"find the wikipedia article on the integrated stress response pathway,"
|
80
|
+
" download it, and summarize the genes and what they do."
|
81
|
+
" then find similar GO-CAMs, look up their details,"
|
82
|
+
" and compare them to the reviews"
|
83
|
+
)
|
84
|
+
],
|
85
|
+
["Find models involving the NLRP3 inflammasome. Compare the GO-CAM model with information available from uniprot"],
|
86
|
+
["Examine models for antimicrobial resistance, look for commonalities in genes"],
|
87
|
+
["When curating GO-CAMs, the activity unit for a ligand of a signaling receptor should use which GO MF ID for the activity unit?"],
|
88
|
+
],
|
89
|
+
)
|
@@ -0,0 +1,224 @@
|
|
1
|
+
"""
|
2
|
+
MCP tools for working with Gene Ontology Causal Activity Models.
|
3
|
+
"""
|
4
|
+
import os
|
5
|
+
from typing import Dict, List
|
6
|
+
|
7
|
+
from mcp.server.fastmcp import FastMCP
|
8
|
+
|
9
|
+
import aurelian.agents.filesystem.filesystem_tools as fst
|
10
|
+
from aurelian.agents.gocam.gocam_agent import SYSTEM
|
11
|
+
import aurelian.agents.gocam.gocam_tools as gt
|
12
|
+
from aurelian.agents.literature.literature_tools import lookup_pmid as lit_lookup_pmid, search_literature_web, retrieve_literature_page
|
13
|
+
from aurelian.agents.gocam.gocam_config import GOCAMDependencies
|
14
|
+
from pydantic_ai import RunContext
|
15
|
+
|
16
|
+
# Initialize FastMCP server
|
17
|
+
mcp = FastMCP("gocam", instructions=SYSTEM)
|
18
|
+
|
19
|
+
|
20
|
+
from aurelian.dependencies.workdir import WorkDir
|
21
|
+
|
22
|
+
def deps() -> GOCAMDependencies:
|
23
|
+
deps = GOCAMDependencies()
|
24
|
+
# Set the location from environment variable or default
|
25
|
+
loc = os.getenv("AURELIAN_WORKDIR", "/tmp/aurelian")
|
26
|
+
deps.workdir = WorkDir(loc)
|
27
|
+
|
28
|
+
# Get database connection parameters from environment if available
|
29
|
+
db_path = os.getenv("GOCAM_DB_PATH")
|
30
|
+
db_name = os.getenv("GOCAM_DB_NAME")
|
31
|
+
collection_name = os.getenv("GOCAM_COLLECTION_NAME")
|
32
|
+
|
33
|
+
if db_path:
|
34
|
+
deps.db_path = db_path
|
35
|
+
if db_name:
|
36
|
+
deps.db_name = db_name
|
37
|
+
if collection_name:
|
38
|
+
deps.collection_name = collection_name
|
39
|
+
|
40
|
+
return deps
|
41
|
+
|
42
|
+
def ctx() -> RunContext[GOCAMDependencies]:
|
43
|
+
rc: RunContext[GOCAMDependencies] = RunContext[GOCAMDependencies](
|
44
|
+
deps=deps(),
|
45
|
+
model=None, usage=None, prompt=None,
|
46
|
+
)
|
47
|
+
return rc
|
48
|
+
|
49
|
+
|
50
|
+
@mcp.tool()
|
51
|
+
async def search_gocams(query: str) -> List[Dict]:
|
52
|
+
"""
|
53
|
+
Performs a retrieval search over the GO-CAM database.
|
54
|
+
|
55
|
+
The query can be any text, such as name of a pathway, genes, or
|
56
|
+
a complex sentence.
|
57
|
+
|
58
|
+
The objects returned are summaries of GO-CAM models; they do not contain full
|
59
|
+
details. Use `lookup_gocam` to retrieve full details of a model.
|
60
|
+
|
61
|
+
This tool uses a retrieval method that is not guaranteed to always return
|
62
|
+
complete results, and some results may be less relevant than others.
|
63
|
+
You MAY use your judgment in filtering these.
|
64
|
+
|
65
|
+
Args:
|
66
|
+
query: The search query text
|
67
|
+
|
68
|
+
Returns:
|
69
|
+
List[Dict]: List of GOCAM models matching the query
|
70
|
+
"""
|
71
|
+
return await gt.search_gocams(ctx(), query)
|
72
|
+
|
73
|
+
|
74
|
+
@mcp.tool()
|
75
|
+
async def lookup_gocam(model_id: str) -> Dict:
|
76
|
+
"""
|
77
|
+
Performs a lookup of a GO-CAM model by its ID, and returns the model.
|
78
|
+
|
79
|
+
Args:
|
80
|
+
model_id: The ID of the GO-CAM model to look up
|
81
|
+
|
82
|
+
Returns:
|
83
|
+
Dict: The GO-CAM model data
|
84
|
+
"""
|
85
|
+
return await gt.lookup_gocam(ctx(), model_id)
|
86
|
+
|
87
|
+
|
88
|
+
@mcp.tool()
|
89
|
+
async def lookup_uniprot_entry(uniprot_acc: str) -> str:
|
90
|
+
"""
|
91
|
+
Lookup the Uniprot entry for a given Uniprot accession number.
|
92
|
+
|
93
|
+
This can be used to obtain further information about a protein in
|
94
|
+
a GO-CAM.
|
95
|
+
|
96
|
+
Args:
|
97
|
+
uniprot_acc: The Uniprot accession
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
str: Detailed functional and other info about the protein
|
101
|
+
"""
|
102
|
+
return await gt.lookup_uniprot_entry(ctx(), uniprot_acc)
|
103
|
+
|
104
|
+
|
105
|
+
@mcp.tool()
|
106
|
+
async def lookup_pmid(pmid: str) -> str:
|
107
|
+
"""
|
108
|
+
Lookup the text of a PubMed article by its PMID.
|
109
|
+
|
110
|
+
Note that assertions in GO-CAMs may reference PMIDs, so this tool
|
111
|
+
is useful for validating assertions. A common task is to align
|
112
|
+
the text of a PMID with the text of an assertion, or extracting text
|
113
|
+
snippets from the publication that support the assertion.
|
114
|
+
|
115
|
+
Args:
|
116
|
+
pmid: The PubMed ID to look up
|
117
|
+
|
118
|
+
Returns:
|
119
|
+
str: Full text if available, otherwise abstract
|
120
|
+
"""
|
121
|
+
return await lit_lookup_pmid(pmid)
|
122
|
+
|
123
|
+
|
124
|
+
@mcp.tool()
|
125
|
+
async def search_web(query: str) -> str:
|
126
|
+
"""
|
127
|
+
Search the web using a text query.
|
128
|
+
|
129
|
+
Args:
|
130
|
+
query: The search query
|
131
|
+
|
132
|
+
Returns:
|
133
|
+
str: Search results with summaries
|
134
|
+
"""
|
135
|
+
return await search_literature_web(query)
|
136
|
+
|
137
|
+
|
138
|
+
@mcp.tool()
|
139
|
+
async def retrieve_web_page(url: str) -> str:
|
140
|
+
"""
|
141
|
+
Fetch the contents of a web page.
|
142
|
+
|
143
|
+
Args:
|
144
|
+
url: The URL to fetch
|
145
|
+
|
146
|
+
Returns:
|
147
|
+
str: The contents of the web page
|
148
|
+
"""
|
149
|
+
return await retrieve_literature_page(url)
|
150
|
+
|
151
|
+
|
152
|
+
@mcp.tool()
|
153
|
+
async def inspect_file(data_file: str) -> str:
|
154
|
+
"""
|
155
|
+
Inspect a file in the working directory.
|
156
|
+
|
157
|
+
Args:
|
158
|
+
data_file: name of file
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
str: Contents of the file
|
162
|
+
"""
|
163
|
+
return await fst.inspect_file(ctx(), data_file)
|
164
|
+
|
165
|
+
|
166
|
+
@mcp.tool()
|
167
|
+
async def list_files() -> str:
|
168
|
+
"""
|
169
|
+
List files in the working directory.
|
170
|
+
|
171
|
+
Returns:
|
172
|
+
str: List of files in the working directory
|
173
|
+
"""
|
174
|
+
return await fst.list_files(ctx())
|
175
|
+
|
176
|
+
|
177
|
+
@mcp.tool()
|
178
|
+
async def write_to_file(file_name: str, data: str) -> str:
|
179
|
+
"""
|
180
|
+
Write data to a file in the working directory.
|
181
|
+
|
182
|
+
Args:
|
183
|
+
file_name: Name of the file to write
|
184
|
+
data: Data to write to the file
|
185
|
+
|
186
|
+
Returns:
|
187
|
+
str: Confirmation message
|
188
|
+
"""
|
189
|
+
return await fst.write_to_file(ctx(), file_name, data)
|
190
|
+
|
191
|
+
|
192
|
+
@mcp.tool()
|
193
|
+
async def fetch_document(name: str, format: str = "md") -> str:
|
194
|
+
"""
|
195
|
+
Lookup the GO-CAM document by name.
|
196
|
+
|
197
|
+
Args:
|
198
|
+
name: The document name (e.g. "How_to_annotate_complexes_in_GO-CAM")
|
199
|
+
format: The format of the document (defaults to "md")
|
200
|
+
|
201
|
+
Returns:
|
202
|
+
The content of the document
|
203
|
+
"""
|
204
|
+
return await gt.fetch_document(ctx(), name, format)
|
205
|
+
|
206
|
+
|
207
|
+
@mcp.tool()
|
208
|
+
async def validate_gocam_model(model_data: str, format: str = "json") -> Dict:
|
209
|
+
"""
|
210
|
+
Validate a GO-CAM model against the pydantic schema.
|
211
|
+
|
212
|
+
Args:
|
213
|
+
model_data: The model data as a JSON/YAML string
|
214
|
+
format: The format of the input data (json or yaml)
|
215
|
+
|
216
|
+
Returns:
|
217
|
+
Dict with validation results, including success status and errors if any
|
218
|
+
"""
|
219
|
+
return await gt.validate_gocam_model(ctx(), model_data, format)
|
220
|
+
|
221
|
+
|
222
|
+
if __name__ == "__main__":
|
223
|
+
# Initialize and run the server
|
224
|
+
mcp.run(transport='stdio')
|