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,54 @@
|
|
1
|
+
"""
|
2
|
+
Agent for retrieval-augmented generation against document collections.
|
3
|
+
|
4
|
+
This module re-exports components from the rag/ package for backward compatibility.
|
5
|
+
"""
|
6
|
+
from typing import Dict, List
|
7
|
+
|
8
|
+
# Re-export from rag package
|
9
|
+
from aurelian.agents.rag import (
|
10
|
+
rag_agent,
|
11
|
+
RagDependencies,
|
12
|
+
get_config,
|
13
|
+
search_documents,
|
14
|
+
inspect_document,
|
15
|
+
lookup_pmid,
|
16
|
+
search_web,
|
17
|
+
retrieve_web_page,
|
18
|
+
chat,
|
19
|
+
)
|
20
|
+
|
21
|
+
# Re-export the older synchronous versions of functions for compatibility
|
22
|
+
@rag_agent.tool
|
23
|
+
def search_documents_sync(ctx, query: str) -> List[Dict]:
|
24
|
+
"""Legacy synchronous version of search_documents"""
|
25
|
+
import asyncio
|
26
|
+
return asyncio.run(search_documents(ctx, query))
|
27
|
+
|
28
|
+
|
29
|
+
@rag_agent.tool
|
30
|
+
def inspect_document_sync(ctx, query: str) -> str:
|
31
|
+
"""Legacy synchronous version of inspect_document"""
|
32
|
+
import asyncio
|
33
|
+
return asyncio.run(inspect_document(ctx, query))
|
34
|
+
|
35
|
+
|
36
|
+
@rag_agent.tool
|
37
|
+
def lookup_pmid_sync(ctx, pmid: str) -> str:
|
38
|
+
"""Legacy synchronous version of lookup_pmid"""
|
39
|
+
import asyncio
|
40
|
+
return asyncio.run(lookup_pmid(ctx, pmid))
|
41
|
+
|
42
|
+
|
43
|
+
@rag_agent.tool
|
44
|
+
def search_web_sync(ctx, query: str) -> str:
|
45
|
+
"""Legacy synchronous version of search_web"""
|
46
|
+
import asyncio
|
47
|
+
return asyncio.run(search_web(ctx, query))
|
48
|
+
|
49
|
+
|
50
|
+
@rag_agent.tool
|
51
|
+
def retrieve_web_page_sync(ctx, url: str) -> str:
|
52
|
+
"""Legacy synchronous version of retrieve_web_page"""
|
53
|
+
import asyncio
|
54
|
+
return asyncio.run(retrieve_web_page(ctx, url))
|
File without changes
|
@@ -0,0 +1,384 @@
|
|
1
|
+
# Template
|
2
|
+
|
3
|
+
## Contents
|
4
|
+
|
5
|
+
1. [Overview](#overview)
|
6
|
+
2. [Template Strings](#template-strings)
|
7
|
+
1. [Generic Template Strings](#generic-template-strings)
|
8
|
+
2. [Class Template Strings](#class-template-strings)
|
9
|
+
3. [Property Template Strings](#property-template-strings)
|
10
|
+
4. [Individual Template Strings](#individual-template-strings)
|
11
|
+
3. [Merging (`--merge-before`, `--merge-after`)](#merging)
|
12
|
+
4. [Examples](#examples)
|
13
|
+
|
14
|
+
## Overview
|
15
|
+
|
16
|
+
ROBOT can convert tables to OWL format using templates. See [`template.csv`](/examples/template.csv) for an example. The approach extends the QTT method described in [Overcoming the ontology enrichment bottleneck with Quick Term Templates](http://dx.doi.org/10.3233/AO-2011-0086).
|
17
|
+
|
18
|
+
ROBOT can read comma-separated values (`.csv`) or tab-separated values (`.tsv` or `.tab`):
|
19
|
+
|
20
|
+
robot template --template template.csv \
|
21
|
+
--prefix "ex: http://example.com/" \
|
22
|
+
--ontology-iri "https://github.com/ontodev/robot/examples/template.owl" \
|
23
|
+
--output results/template.owl
|
24
|
+
|
25
|
+
Each template file must be set up in the following format:
|
26
|
+
|
27
|
+
1. **Headers**: ROBOT expects the first row to contain column names for every column used in the data. These are used to make error messages more helpful.
|
28
|
+
2. **Templates**: ROBOT expects the second row to contain template strings for each column that will be used in the OWL conversion. See below for details on template strings.
|
29
|
+
3. **Data**: ROBOT expects each of the remaining rows to correspond to a term (a class, property, or individual).
|
30
|
+
|
31
|
+
### Template Options
|
32
|
+
|
33
|
+
The `template` command accepts an optional input ontology, either using the `--input` option or from the previous command in a chain. If an input ontology is given, its `rdfs:label`s will be used when parsing the template. The `--template` or `-t` option specifies the CSV or TSV template file. Multiple templates are allowed, and the order of templates is significant. You can also specify the normal `--prefix` options, the `--output-iri` and `--version-iri`, and the usual `--output` options. See [Merging](#merging) for the three different merge options, and details on how they control the output of the command.
|
34
|
+
|
35
|
+
A template may have multiple errors in different rows and columns. By default, `template` will fail on the first error encountered. If you wish to proceed with errors, use `--force true`. This will log all row parse errors to STDERR and attempt to create an ontology anyway. Be aware that the output ontology may be missing axioms and ROBOT will complete with a `0` exit code (success).
|
36
|
+
|
37
|
+
You can also choose to write errors to a separate table using `--errors <path>`. If the path ends with `csv`, the output will be comma-separated. Otherwise, the output will be tab-separated. The errors table contains the following fields:
|
38
|
+
* **table**: table name (the `--template`)
|
39
|
+
* **cell**: A1 notation of cell location (e.g., C3)
|
40
|
+
* **rule ID**: the CURIE of the rule (`ROBOT-template:[rule-name]`, which expands to `http://robot.obolibrary.org/template#[rule-name]`)
|
41
|
+
* **message**: text description of the violated rule
|
42
|
+
|
43
|
+
If `--force true` is not included with `--errors <path>`, ROBOT will exit with a non-zero exit code (failure) and the output file will not be created.
|
44
|
+
|
45
|
+
## Template Strings
|
46
|
+
|
47
|
+
### Generic Template Strings
|
48
|
+
|
49
|
+
- `ID`: Every term must have an IRI to identify it. This can be specified with an `ID` column. Usually this will be a prefixed ID like `GO:12345`. See the `--prefix` options for details.
|
50
|
+
- If an entity already exists in the `--input` ontology, you can refer to it by `LABEL` instead (see below).
|
51
|
+
- Rows with no `ID` or `LABEL` will be skipped.
|
52
|
+
- `LABEL`: a special keyword to specify an `rdfs:label` that uniquely identifies the target term. This can be easier than the numeric IDs for human readers. Keep in mind:
|
53
|
+
- The `LABEL` column will create `rdfs:label` string annotation for the entity
|
54
|
+
- If you are creating new entities using `LABEL`, be sure to include an `ID` column as well
|
55
|
+
- `TYPE`: this is the `rdf:type` for the row. Because ROBOT is focused on ontology development, the default value is `owl:Class` and this column is optional. When creating an OWLIndividual, specify the class to which it belongs in this column.
|
56
|
+
- `class` or `owl:Class`
|
57
|
+
- `object property` or `owl:ObjectProperty`
|
58
|
+
- `data property` or `owl:DataProperty`
|
59
|
+
- `annotation property` or `owl:AnnotationProperty`
|
60
|
+
- `datatype` or `owl:Datatype`
|
61
|
+
- `individual`, `named individual`, `owl:Individual`, `owl:NamedIndividual`, or a defined class ID or label
|
62
|
+
- **annotations**: ROBOT can attach annotations to your term. There are four options:
|
63
|
+
- `A` string annotation: If the template string starts with an `A` and a space then it will be interpreted as a string annotation. The rest of the template string should be the label or compact IRI of an annotation property, e.g. `label` or `rdfs:label`. The cell value will be the literal value of the annotation with type `xsd:string`. Annotation property labels do not need to be wrapped in single quotes.
|
64
|
+
- `AT` typed annotation: If the template string starts with an `AT` and a space then it will be interpreted as a typed annotation. The `^^` characters must be used to separate the annotation property from the datatype, e.g. `rdfs:comment^^xsd:integer`. The cell value will be the typed literal value of the annotation.
|
65
|
+
- `AL` language annotation: If the template string starts with an `AL` and a space then it will be interpreted as a language annotation. The `@` character must be used to separate the annotation property from the language code, e.g. `rdfs:comment@en`.
|
66
|
+
- `AI` annotation IRI: If the template string starts with an `AI` and a space, then the annotation will be made as with a string annotation, except that the cell value will be interpreted as an IRI.
|
67
|
+
- `>A` (**axiom annotations**): ROBOT can also annotate logical and annotation axioms. The axiom annotation will be on the axiom created on the cell to the left of the `>A*` template string. The `>` symbol can be used in front of any valid annotation character (`>A`, `>AT`, `>AL`, `>AI`)
|
68
|
+
|
69
|
+
Sometimes you want to include zero or more values in a single spreadsheet cell, for example when you want to allow for multiple annotations or have separate logical axioms. If a template string also contains `SPLIT=|`, then ROBOT will use the `|` character to split the contents of a cell in that column and add an annotation for each result (if there are any). Instead of `|` you can specify a string of characters of your choice -- other than pure whitespace -- to split on (e.g. `SPLIT=, `).
|
70
|
+
|
71
|
+
### Class Template Strings
|
72
|
+
|
73
|
+
- **class expression**: If the template string starts with `C`, `SC`, `EC`, or `DC` followed by a space and the template string (e.g. `SC %`) then it will be interpreted as a class expression. The value of the current cell will be substituted into the template, replacing all occurrences of the percent `%` character. Then, the result will be parsed into an OWL class expression.
|
74
|
+
- ROBOT uses the same syntax for class expressions as Protégé: [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax). This means that an entity can be referred to by its `rdfs:label` (enclosing in single quotes if it has a space in it).
|
75
|
+
- If it does not recognize a label, ROBOT will assume that you're trying to refer to a class by its IRI (or compact IRI). This can lead to unexpected behaviour, but it allows you to refer to classes (by IRI) without loading them into the input ontology. This is particularly useful when the input ontology would be too large, such as the NCBI Taxonomy.
|
76
|
+
- Properties in class expressions **must** be referred to by label in order to be parsed.
|
77
|
+
- `SC %`: the class will be asserted to be a subclass of the class expression in this column (same as class type `subclass`)
|
78
|
+
- `EC %`: the class will be asserted to be an equivalent class of the intersection of the `EC` class expressions in a row (same as class type `equivalent`)
|
79
|
+
- `DC %`: the class will be asserted to be disjoint with the class expression in this column (same as class type `disjoint`)
|
80
|
+
- `C %`: the class will be asserted as specified in the `CLASS_TYPE` column
|
81
|
+
- `CLASS_TYPE`: an optional column that specifies the type for all `C` columns. This allows different rows to have different types of logical definitions. Valid values are:
|
82
|
+
- `subclass`: the values of all `C` columns will be asserted as subclasses (this is the default)
|
83
|
+
- `equivalent`: values of all `C` columns will be taken as an intersection and asserted to be an equivalent class
|
84
|
+
- `disjoint`: the values of all `C` columns will be asserted as disjoint classes
|
85
|
+
|
86
|
+
(A `CI` template string tells ROBOT to read the cell value as an IRI and assert it as the `CLASS_TYPE`. This is included for legacy support, and the other class template strings are preferred.)
|
87
|
+
|
88
|
+
#### Example of Class Template Strings
|
89
|
+
|
90
|
+
| Label | Entity Type | Superclass | Disjoint Classes | Equivalent axioms |
|
91
|
+
| ------- | ----------- | ---------- | ---------------- | ----------------- |
|
92
|
+
| LABEL | TYPE | SC % | DC % | EC part_of some % |
|
93
|
+
| Class 2 | class | Class 1 | | |
|
94
|
+
| Class 3 | class | | | Class 2 |
|
95
|
+
| Class 4 | class | equivalent | Class 3 | |
|
96
|
+
|
97
|
+
Class 2 will be a subclass of Class 1. Class 3 will be equivalent to `part_of some 'Class 2'` and Class 4 will be disjoint with Class 3.
|
98
|
+
|
99
|
+
Manchester expressions can also be used within the cells. To avoid ambiguity, it's best to enclose expressions in parentheses:
|
100
|
+
|
101
|
+
| Label | Parent |
|
102
|
+
| ------- | ------------------------ |
|
103
|
+
| LABEL | SC % |
|
104
|
+
| Class 4 | |
|
105
|
+
| Class 5 | (part_of some 'Class 4') |
|
106
|
+
|
107
|
+
In this template, Class 5 would be a subclass of `part_of some 'Class 4'`.
|
108
|
+
|
109
|
+
### Property Template Strings
|
110
|
+
|
111
|
+
- `DOMAIN`: The domain to a property is a class expression in [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax) (for object and data properties). For annotation properties, the domain must be a single class specified by label, CURIE, or IRI.
|
112
|
+
- `RANGE`: The range to a property is either a class expression in [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax) (for object properties) or the name, CURIE, or IRI of a datatype (for annotation and data properties).
|
113
|
+
- `CHARACTERISTIC`: for each row of data that has a `TYPE` of object property or data property (*not* an annotation property), you can optionally specify a logical `CHARACTERISTIC` column. The column can be split, e.g. `CHARACTERISTIC SPLIT=|`, to specify multiple characteristics. Object properties can have any of the following characteristics, but only `functional` applies to data properties:
|
114
|
+
- `functional`: the created property will be functional, meaning each entity (subject) can have at most one value
|
115
|
+
- `inverse functional`: the created object property will be inverse functional, meaning each value can have at most one subject
|
116
|
+
- `reflexive`: the created object property will be reflexive, meaning each subject can also be a value
|
117
|
+
- `irreflexive`: the created object property will be irreflexive, meaning the subject cannot also be the value
|
118
|
+
- `symmetric`: the created object property will be symmetric, meaning the subject and value can be reversed
|
119
|
+
- `asymmetric`: the created object property will be asymmetric, meaning the subject and value cannot be reversed
|
120
|
+
- `transitive`: the created object property will be transitive, meaning the property can be chained
|
121
|
+
- **property expression**: If the template string starts with `P`, `SP`, `EP`, `DP`, or `IP` followed by a space and the template string (e.g. `SP %`), then it will be interpreted as a property expression. The value of the current cell will be substituted into the template, replacing all occurrences of the `%` character. Then the result will be parsed into an OWL property expression. ROBOT uses the same syntax for property expressions as Protégé: [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax). If it does not recognize a name, ROBOT will assume that you're trying to refer to an entity by its IRI or CURIE. This can lead to unexpected behavior, but it allows you to refer to entities without loading them into the input ontology.
|
122
|
+
- `SP %`: the property will be asserted to be a subproperty of the property expression in the column
|
123
|
+
- `EP %`: the property will be asserted to be equivalent with the property expression in the column
|
124
|
+
- `DP %`: the property will be asserted to be disjoint with the property expression in the column
|
125
|
+
- `IP %`: the property will be asserted to be the inverse of the property expression in the column (this can only be used with object properties)
|
126
|
+
- `P %`: the property will be asserted as specified in the `PROPERTY_TYPE` column
|
127
|
+
- `PROPERTY_TYPE`: an optional column that specifies the type for all `P` columns. This allows different rows to have different types of logical definitions. Valid values are:
|
128
|
+
- `subproperty`: the values of all `P` columns will be asserted as subproperties (this is the default, annotation properties can only be subproperties)
|
129
|
+
- `equivalent`: values of all `C` columns will be asserted as equivalent properties
|
130
|
+
- `disjoint`: the values of all `P` columns will be asserted as disjoint properties
|
131
|
+
- `inverse`: the values of all `P` columns will be asserted as inverse properties (only applies to object properties)
|
132
|
+
|
133
|
+
#### Example of Property Template Strings
|
134
|
+
|
135
|
+
| ID | Entity Type | Characteristic | Super Property | Domain | Range |
|
136
|
+
| ---- | ------------------ | -------------- | -------------- | ------- | ---------- |
|
137
|
+
| ID | TYPE | CHARACTERISTIC | SP % | DOMAIN | RANGE |
|
138
|
+
| OP:1 | owl:ObjectProperty | | Property 1 | Class 1 | Class 2 |
|
139
|
+
| DP:1 | owl:DataProperty | functional | Property 2 | Class 2 | xsd:string |
|
140
|
+
|
141
|
+
### Individual Template Strings
|
142
|
+
|
143
|
+
If the `TYPE` is a defined class, `owl:Individual`, or `owl:NamedIndividual`, an instance will be created. If the `TYPE` does not include a defined class, that instance will have no class assertions (unless you use the `TI` template string to add an anonymous type). You may include a `SPLIT=` in `TYPE` if you wish to provide more than one class assertion for an individual.
|
144
|
+
|
145
|
+
- **class assertion**:
|
146
|
+
- `TI %`: the individual will be asserted to be a type of the *class expression* in the column
|
147
|
+
- **individual assertion**:
|
148
|
+
- `I <property>`: when creating an individual, replace property with an object property or data property to add assertions (either by label or CURIE). The value of each axiom will be the value of the cell in this column. For object property assertions, this is another individual. For data property assertions, this is a literal value. If using a property label here, **do not** wrap the label in single quotes.
|
149
|
+
- `SI %`: the individual in the column will be asserted to be the same individual
|
150
|
+
- `DI %`: the individual in the column will be asserted to be a different individual
|
151
|
+
|
152
|
+
#### Example of Individual Template Strings
|
153
|
+
|
154
|
+
| Label | Entity Type | Individual Role | Property Assertions | Different Individuals |
|
155
|
+
| ------------ | ----------- | -------------------- | ------------------- | --------------------- |
|
156
|
+
| LABEL | TYPE | TI 'has role' some % | I part_of | DI % |
|
157
|
+
| Individual 1 | Class 1 | Role Class 1 | Individual 2 | |
|
158
|
+
| Individual 2 | Class 1 | Role Class 2 | | Individual 1 |
|
159
|
+
|
160
|
+
<!-- ### Datatype Template Strings -->
|
161
|
+
|
162
|
+
## Merging
|
163
|
+
|
164
|
+
The `template` command has three options for merging, which are especially useful when chaining commands. First some terminology:
|
165
|
+
|
166
|
+
- "input ontology": the ontology from the previous command or specified by the `--input` option, used to resolve terms in the template
|
167
|
+
- "result ontology": the new ontology created from the template, distinct from the input ontology
|
168
|
+
- "merged ontology": the result ontology merged into the input ontology
|
169
|
+
|
170
|
+
The three options can differ in which ontology is saved for the `--output` option and which is sent to the next command in the chain:
|
171
|
+
|
172
|
+
option | `--output` | output
|
173
|
+
-------------|------------|-------
|
174
|
+
no merge | result | result
|
175
|
+
merge before | merged | merged
|
176
|
+
merge after | result | merged
|
177
|
+
|
178
|
+
- no merge (default behaviour): only the result ontology will be output
|
179
|
+
- `merge-before`: the result ontology is merged into the input ontology immediately, so only the merged ontology will be output
|
180
|
+
- `merge-after`: any `--output` options apply to the result ontology, then result ontology is merged into the input ontology, and the output of the command is the merged ontology
|
181
|
+
|
182
|
+
These three options are particularly useful when chaining commands. For instance, the `merge-after` option lets you save the result ontology separately, then send the merged ontology to the next command. See [merge](/merge) for more information on merge options, including `--collapse-import-closure` and `--include-annotations`.
|
183
|
+
|
184
|
+
If the command includes `--ancestors`, the result ontology will include the ancestors (from the input ontology) of the result ontology terms. Only the labels of the ancestors will be included.
|
185
|
+
|
186
|
+
## Examples
|
187
|
+
|
188
|
+
Create an output ontology that includes the input ontology and the terms defined in the template:
|
189
|
+
|
190
|
+
robot template --merge-before \
|
191
|
+
--input edit.owl \
|
192
|
+
--template part_of_template.csv \
|
193
|
+
--output results/part_of_uberon.owl
|
194
|
+
|
195
|
+
|
196
|
+
Create two outputs -- the templated terms ([`uberon_template.owl`](/examples/uberon_template.owl)) and the input ontology merged with the output ontology with an annotation ([`uberon_v2.owl`](/examples/uberon_v2)):
|
197
|
+
<!-- DO NOT TEST -->
|
198
|
+
```
|
199
|
+
robot template --merge-after \
|
200
|
+
--input edit.owl \
|
201
|
+
--template uberon_template.csv \
|
202
|
+
--output results/uberon_template.owl \
|
203
|
+
annotate --annotation rdfs:comment "UBERON with new terms" \
|
204
|
+
--output results/uberon_v2.owl
|
205
|
+
```
|
206
|
+
|
207
|
+
Create an output ontology that consists of the template terms plus their dependencies ([`uberon_template_2.owl`](/examples/uberon_template_2.owl)):
|
208
|
+
<!-- DO NOT TEST -->
|
209
|
+
```
|
210
|
+
robot template --ancestors --input edit.owl \
|
211
|
+
--template uberon_template.csv \
|
212
|
+
--ontology-iri "https://github.com/ontodev/robot/examples/uberon_template_2.owl" \
|
213
|
+
--output results/uberon_template_2.owl
|
214
|
+
```
|
215
|
+
|
216
|
+
Create an output ontology that includes the input ontology and the terms defined in the template, but keep the import statements* ([`test_template.owl`](/examples/test_template.owl)):
|
217
|
+
<!-- DO NOT TEST -->
|
218
|
+
```
|
219
|
+
robot template --merge-before \
|
220
|
+
--input test.owl \
|
221
|
+
--collapse-import-closure false \
|
222
|
+
--template uberon_template.csv \
|
223
|
+
--output results/test_template.owl
|
224
|
+
```
|
225
|
+
|
226
|
+
ROBOT template data read from separate external file
|
227
|
+
|
228
|
+
robot template --template animals_template.tsv \
|
229
|
+
--external-template animals_ext_template.tsv \
|
230
|
+
--output results/animals_ext_template.owl
|
231
|
+
|
232
|
+
Adjusted line numbers for error reporting for template data read from separate external file
|
233
|
+
<!-- DO NOT TEST -->
|
234
|
+
```
|
235
|
+
robot template --template animals_template_error.tsv \
|
236
|
+
--ext-template animals_ext_template.tsv \
|
237
|
+
--output results/animals_ext_template.owl
|
238
|
+
```
|
239
|
+
|
240
|
+
|
241
|
+
\* NOTE: the imports would be merged into the output if `--collapse-import-closure true` is included instead.
|
242
|
+
|
243
|
+
Further examples can be found [in the OBI repository](https://github.com/obi-ontology/obi/tree/master/src/ontology/templates)
|
244
|
+
|
245
|
+
---
|
246
|
+
|
247
|
+
## Error Messages
|
248
|
+
|
249
|
+
### Annotation Property Characteristic Error
|
250
|
+
|
251
|
+
Annotation properties should not have any value in the `CHARACTERISTIC` column, if it exists. This type of logic for annotation properties is not supported in OWL.
|
252
|
+
|
253
|
+
### Annotation Property Error
|
254
|
+
|
255
|
+
The annotation property provided could not be resolved. Check your template to ensure the provided annotation property is in a correct IRI or CURIE format. For legibility, using CURIEs is recommended, but you must ensure that the prefix is defined.
|
256
|
+
|
257
|
+
If you are using a label, make sure that the label is defined either in the template or input ontology.
|
258
|
+
|
259
|
+
```
|
260
|
+
A rdfs:label
|
261
|
+
A http://www.w3.org/2000/01/rdf-schema#label
|
262
|
+
```
|
263
|
+
|
264
|
+
### Annotation Property Type Error
|
265
|
+
|
266
|
+
The only valid `PROPERTY_TYPE` for an annotation property is `subproperty`. Other types of logic for annotation properties are not supported in OWL. If this column is left blank, it will default to `subproperty`.
|
267
|
+
|
268
|
+
### Axiom Annotation Error
|
269
|
+
|
270
|
+
An axiom annotation is an annotation on an axiom, either a class axiom or another annotation. Because of this, any time `>A` is used, an annotation must be in the previous column. Any time `>C` is used, a class expression must be in the previous column.
|
271
|
+
```
|
272
|
+
A rdfs:label,>A rdfs:comment
|
273
|
+
C %,>C rdfs:comment
|
274
|
+
```
|
275
|
+
|
276
|
+
### Class Type Error
|
277
|
+
|
278
|
+
The valid `CLASS_TYPE` values are: `subclass`, `equivalent`, and `disjoint`.
|
279
|
+
|
280
|
+
### Class Type Split Error
|
281
|
+
|
282
|
+
A class row may only use one of: `subclass`, `equivalent`, and `disjoint`. To add other types of axioms on an OWL class, use a separate row.
|
283
|
+
|
284
|
+
### Column Mismatch Error
|
285
|
+
|
286
|
+
Each column that has a template string in row two must have a header string in row one. It is OK to have a header string with no template string.
|
287
|
+
|
288
|
+
### Data Property Characteristic Error
|
289
|
+
|
290
|
+
The only valid `CHARACTERISTIC` value for a data property is `functional`. Other types of property characteristics for data properties are not supported in OWL.
|
291
|
+
|
292
|
+
### Datatype Error
|
293
|
+
|
294
|
+
The datatype provided in an `AT` template string could not be resolved. Check your template to ensure the provided datatype is in a correct IRI or CURIE format. For legibility, using CURIEs is recommended, but you must ensure that the prefix is defined.
|
295
|
+
```
|
296
|
+
AT rdfs:label^^xsd:string
|
297
|
+
AT rdfs:label^^http://www.w3.org/2001/XMLSchema#string
|
298
|
+
```
|
299
|
+
|
300
|
+
### File Type Error
|
301
|
+
|
302
|
+
The `--template` option accepts the following file types: CSV, TSV, or TAB.
|
303
|
+
|
304
|
+
### ID Error
|
305
|
+
|
306
|
+
Each template must have an ID column. Keep in mind that if the template has an ID column, but it is not filled in for a row, that row will be skipped.
|
307
|
+
|
308
|
+
### Individual Type Error
|
309
|
+
|
310
|
+
The valid `INDIVIDUAL_TYPE` values are: `named`, `same`, and `different`.
|
311
|
+
|
312
|
+
### Individual Type Split Error
|
313
|
+
|
314
|
+
An individual row may only use one of: `named`, `same`, and `different`. To add other types of axioms on an OWL individual, use a separate row.
|
315
|
+
|
316
|
+
### IRI Error
|
317
|
+
|
318
|
+
The IRI provided as the value (in a row) to an `AI` template string could not be resolved as an IRI. Check your template to ensure the provided value is in a correct IRI or CURIE format. If using CURIEs, remember to ensure the prefix is defined.
|
319
|
+
|
320
|
+
### Language Format Error
|
321
|
+
|
322
|
+
The template string for an `AL` annotation must always include `@`.
|
323
|
+
```
|
324
|
+
AL rdfs:label@en
|
325
|
+
```
|
326
|
+
|
327
|
+
### Manchester Parse Error
|
328
|
+
|
329
|
+
The provided value cannot be parsed and may not be in proper Manchester syntax. See [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax) for more details. If you are using labels, make sure the labels are defined in the `--input` ontology or using the `LABEL` column. Also ensure that all properties use a label instead of a CURIE or IRI.
|
330
|
+
|
331
|
+
When using a restriction (`some`, `only`, `min`, `max`, `exactly`, or `value`) the term that preceeds the restriction must be a property.
|
332
|
+
|
333
|
+
Terms joined using `and` or `or` must be of the same entity type, e.g., you cannot join an object property and a class in an expression.
|
334
|
+
|
335
|
+
### Merge Error
|
336
|
+
|
337
|
+
`--merge-before` and `--merge-after` cannot be used simultaneously.
|
338
|
+
|
339
|
+
### Missing Template Error
|
340
|
+
|
341
|
+
You must specify at least one template with `--template` to proceed.
|
342
|
+
|
343
|
+
### Missing Type Error
|
344
|
+
|
345
|
+
If no `CLASS_TYPE` column is included, ROBOT will default to using `subclass`. If a `CLASS_TYPE` column is included, though, each row must include a specified class type. If the `CLASS_TYPE` is left empty, this error message will be returned.
|
346
|
+
|
347
|
+
### Multiple Property Type Error
|
348
|
+
|
349
|
+
While the `PROPERTY_TYPE` column may include multiple types, only one of the logical types is allowed in each column: `subproperty`, `equivalent`, `disjoint`, or (for object properties only) `inverse`. To add other types of axioms on an OWL property, use a separate row.
|
350
|
+
|
351
|
+
### Null ID Error
|
352
|
+
|
353
|
+
An IRI cannot be created from the provided ID. This is most likely because the ID is not formatted properly, as an IRI or a CURIE.
|
354
|
+
|
355
|
+
### Property Type Error
|
356
|
+
|
357
|
+
The valid `PROPERTY_TYPE` values are: `subproperty`, `equivalent`, `disjoint`, and (for object properties only) `inverse`.
|
358
|
+
|
359
|
+
### Template File Error
|
360
|
+
|
361
|
+
The template cannot be found in the current directory. Make sure the file exists and your path is correct.
|
362
|
+
|
363
|
+
### Typed Format Error
|
364
|
+
|
365
|
+
The template string for an `AT` annotation must always include `^^`.
|
366
|
+
```
|
367
|
+
AT rdfs:label^^xsd:string
|
368
|
+
```
|
369
|
+
|
370
|
+
### Unknown Characteristic Error
|
371
|
+
|
372
|
+
An invalid `CHARACTERISTIC` value was passed. If you are providing multiple characteristics, make sure to include `SPLIT=` in your template string. Valid characteristics are:
|
373
|
+
- `functional`
|
374
|
+
- `inverse functional`
|
375
|
+
- `reflexive`
|
376
|
+
- `irreflexive`
|
377
|
+
- `symmetric`
|
378
|
+
- `asymmetric`
|
379
|
+
- `transitive`
|
380
|
+
|
381
|
+
### Unknown Template Error
|
382
|
+
|
383
|
+
Valid template strings are limited to the [described above](#template-strings). If a different template string is provided, this error message will be returned.
|
384
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from dataclasses import field, dataclass
|
2
|
+
import os
|
3
|
+
from typing import Dict, Optional
|
4
|
+
|
5
|
+
from aurelian.dependencies.workdir import WorkDir, HasWorkdir
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass
|
9
|
+
class RobotDependencies(HasWorkdir):
|
10
|
+
"""Configuration for the ROBOT ontology agent."""
|
11
|
+
workdir: WorkDir = field(default_factory=lambda: WorkDir())
|
12
|
+
prefix_map: Dict[str, str] = field(default_factory=lambda: {"ex": "http://example.org/"})
|
13
|
+
|
14
|
+
|
15
|
+
def get_config() -> RobotDependencies:
|
16
|
+
"""
|
17
|
+
Get the ROBOT configuration from environment variables or defaults.
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
RobotDependencies: The ROBOT dependencies
|
21
|
+
"""
|
22
|
+
workdir_path = os.environ.get("ROBOT_WORKDIR", None)
|
23
|
+
workdir = WorkDir(location=workdir_path) if workdir_path else None
|
24
|
+
|
25
|
+
return RobotDependencies(workdir=workdir)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"""
|
2
|
+
Gradio UI for the ROBOT Ontology agent.
|
3
|
+
"""
|
4
|
+
from typing import List, Optional
|
5
|
+
|
6
|
+
import gradio as gr
|
7
|
+
|
8
|
+
from aurelian.agents.robot.robot_ontology_agent import robot_ontology_agent
|
9
|
+
from aurelian.agents.robot.robot_config import RobotOntologyDependencies
|
10
|
+
from aurelian.utils.async_utils import run_sync
|
11
|
+
|
12
|
+
|
13
|
+
def chat(deps: Optional[RobotOntologyDependencies] = None, **kwargs):
|
14
|
+
"""
|
15
|
+
Initialize a chat interface for the ROBOT ontology agent.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
deps: Optional dependencies configuration
|
19
|
+
**kwargs: Additional arguments to pass to the agent
|
20
|
+
|
21
|
+
Returns:
|
22
|
+
A Gradio chat interface
|
23
|
+
"""
|
24
|
+
if deps is None:
|
25
|
+
deps = RobotOntologyDependencies()
|
26
|
+
|
27
|
+
def get_info(query: str, history: List[str]) -> str:
|
28
|
+
print(f"QUERY: {query}")
|
29
|
+
print(f"HISTORY: {history}")
|
30
|
+
if history:
|
31
|
+
query += "## History"
|
32
|
+
for h in history:
|
33
|
+
query += f"\n{h}"
|
34
|
+
result = run_sync(lambda: robot_ontology_agent.chat(query, deps=deps, **kwargs))
|
35
|
+
return result.data
|
36
|
+
|
37
|
+
return gr.ChatInterface(
|
38
|
+
fn=get_info,
|
39
|
+
type="messages",
|
40
|
+
title="ROBOT Ontology AI Assistant",
|
41
|
+
examples=[
|
42
|
+
["Create an ontology for snack foods with properties like name, ingredients, and calories"],
|
43
|
+
["Convert the CSV file snacks.csv to OWL"],
|
44
|
+
["Merge my snacks.owl with another ontology"]
|
45
|
+
]
|
46
|
+
)
|
@@ -0,0 +1,100 @@
|
|
1
|
+
"""
|
2
|
+
MCP tools for creating robot schemas and example datasets
|
3
|
+
"""
|
4
|
+
import os
|
5
|
+
from typing import Optional, List
|
6
|
+
|
7
|
+
from mcp.server.fastmcp import FastMCP
|
8
|
+
|
9
|
+
import aurelian.agents.filesystem.filesystem_tools as fst
|
10
|
+
from aurelian.agents.robot.robot_ontology_agent import SYSTEM
|
11
|
+
import aurelian.agents.robot.robot_tools as rt
|
12
|
+
from aurelian.agents.robot.robot_config import RobotDependencies
|
13
|
+
from pydantic_ai import RunContext, ModelRetry
|
14
|
+
|
15
|
+
# Initialize FastMCP server
|
16
|
+
mcp = FastMCP("robot", instructions=SYSTEM)
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
from aurelian.dependencies.workdir import WorkDir
|
21
|
+
|
22
|
+
def deps() -> RobotDependencies:
|
23
|
+
deps = RobotDependencies()
|
24
|
+
loc = os.getenv("AURELIAN_WORKDIR", "/tmp/aurelian")
|
25
|
+
deps.workdir = WorkDir(loc)
|
26
|
+
return deps
|
27
|
+
|
28
|
+
def ctx() -> RunContext[RobotDependencies]:
|
29
|
+
rc: RunContext[RobotDependencies] = RunContext[RobotDependencies](
|
30
|
+
deps=deps(),
|
31
|
+
model=None, usage=None, prompt=None,
|
32
|
+
)
|
33
|
+
return rc
|
34
|
+
|
35
|
+
|
36
|
+
@mcp.tool()
|
37
|
+
async def write_and_compile_template(template: str, save_to_file: str= "core.csv", import_ontologies: Optional[List[str]] = None) -> str:
|
38
|
+
"""
|
39
|
+
Adds a template to the file system and compile it to OWL
|
40
|
+
|
41
|
+
Args:
|
42
|
+
ctx: context
|
43
|
+
template: robot template as string. Do not truncate, always pass the whole template, including header.
|
44
|
+
save_to_file: file name to save the templates to. Defaults to core.csv. Only written if file compiles to OWL
|
45
|
+
import_ontologies: list of ontologies to import. These should be files in the working directory.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
report
|
49
|
+
"""
|
50
|
+
return await rt.write_and_compile_template(ctx(), template, save_to_file, import_ontologies)
|
51
|
+
|
52
|
+
|
53
|
+
@mcp.tool()
|
54
|
+
async def inspect_file(data_file: str) -> str:
|
55
|
+
"""
|
56
|
+
Inspect a file in the working directory.
|
57
|
+
|
58
|
+
Args:
|
59
|
+
ctx:
|
60
|
+
data_file: name of file
|
61
|
+
|
62
|
+
Returns:
|
63
|
+
|
64
|
+
"""
|
65
|
+
return await fst.inspect_file(ctx(), data_file)
|
66
|
+
|
67
|
+
|
68
|
+
@mcp.tool()
|
69
|
+
async def list_files() -> str:
|
70
|
+
"""
|
71
|
+
List files in the working directory.
|
72
|
+
|
73
|
+
Args:
|
74
|
+
ctx:
|
75
|
+
|
76
|
+
Returns:
|
77
|
+
|
78
|
+
"""
|
79
|
+
return await fst.list_files(ctx())
|
80
|
+
|
81
|
+
|
82
|
+
@mcp.tool()
|
83
|
+
async def write_to_file(data: str, file_name: str) -> str:
|
84
|
+
"""
|
85
|
+
Write data to a file in the working directory.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
ctx:
|
89
|
+
data:
|
90
|
+
file_name:
|
91
|
+
|
92
|
+
Returns:
|
93
|
+
|
94
|
+
"""
|
95
|
+
return await fst.write_to_file(ctx(), file_name, data)
|
96
|
+
|
97
|
+
|
98
|
+
if __name__ == "__main__":
|
99
|
+
# Initialize and run the server
|
100
|
+
mcp.run(transport='stdio')
|