Upload app.py
Browse files
app.py
CHANGED
@@ -462,7 +462,25 @@ MANUAL CORRECTION STEPS:
|
|
462 |
-->"""
|
463 |
|
464 |
def validate_rdf_interface(rdf_content: str, template: str, use_ai: bool = True):
|
465 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
if not rdf_content.strip():
|
467 |
return "β Error", "No RDF/XML data provided", "", ""
|
468 |
|
@@ -493,13 +511,18 @@ def get_rdf_examples(example_type: str = "valid") -> str:
|
|
493 |
Retrieve example RDF/XML snippets for testing and learning.
|
494 |
|
495 |
This tool provides sample RDF/XML content that can be used to test
|
496 |
-
the validation system or learn proper RDF structure.
|
|
|
|
|
497 |
|
498 |
Args:
|
499 |
-
example_type (str): Type of example
|
|
|
|
|
|
|
500 |
|
501 |
Returns:
|
502 |
-
str: RDF/XML example content
|
503 |
"""
|
504 |
examples = {
|
505 |
"valid": SAMPLE_VALID_RDF,
|
@@ -700,17 +723,36 @@ def create_interface():
|
|
700 |
### π§ **MCP Server Mode:**
|
701 |
This app functions as both a web interface AND an MCP server for Claude Desktop and other MCP clients.
|
702 |
|
703 |
-
**Available MCP Tools
|
704 |
- `validate_rdf_tool`: Validate RDF/XML against SHACL shapes
|
705 |
- `get_ai_suggestions`: Get AI-powered fix suggestions
|
706 |
- `get_ai_correction`: Generate corrected RDF/XML
|
707 |
- `get_rdf_examples`: Retrieve example RDF snippets
|
|
|
|
|
|
|
|
|
708 |
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
714 |
|
715 |
### π‘ **Features:**
|
716 |
- β
Real-time RDF/XML validation against SHACL schemas
|
|
|
462 |
-->"""
|
463 |
|
464 |
def validate_rdf_interface(rdf_content: str, template: str, use_ai: bool = True):
|
465 |
+
"""
|
466 |
+
Main validation function for Gradio interface and MCP server.
|
467 |
+
|
468 |
+
This function provides comprehensive RDF/XML validation with AI-powered
|
469 |
+
suggestions and corrections. It serves as the primary interface for both
|
470 |
+
the Gradio web UI and MCP client tools.
|
471 |
+
|
472 |
+
Args:
|
473 |
+
rdf_content (str): The RDF/XML content to validate
|
474 |
+
template (str): Validation template to use ('monograph' or 'custom')
|
475 |
+
use_ai (bool): Whether to enable AI-powered suggestions and corrections
|
476 |
+
|
477 |
+
Returns:
|
478 |
+
tuple: (status, results_text, suggestions, corrected_rdf) containing:
|
479 |
+
- status: Validation status message
|
480 |
+
- results_text: Detailed validation results
|
481 |
+
- suggestions: AI or manual fix suggestions
|
482 |
+
- corrected_rdf: AI-generated corrections or success message
|
483 |
+
"""
|
484 |
if not rdf_content.strip():
|
485 |
return "β Error", "No RDF/XML data provided", "", ""
|
486 |
|
|
|
511 |
Retrieve example RDF/XML snippets for testing and learning.
|
512 |
|
513 |
This tool provides sample RDF/XML content that can be used to test
|
514 |
+
the validation system or learn proper RDF structure. Examples include
|
515 |
+
valid BibFrame Work records, invalid records for testing corrections,
|
516 |
+
and BibFrame Instance records.
|
517 |
|
518 |
Args:
|
519 |
+
example_type (str): Type of example to retrieve. Options:
|
520 |
+
- 'valid': A complete, valid BibFrame Work record
|
521 |
+
- 'invalid': An incomplete BibFrame Work with validation errors
|
522 |
+
- 'bibframe': A BibFrame Instance record example
|
523 |
|
524 |
Returns:
|
525 |
+
str: Complete RDF/XML example content ready for validation testing
|
526 |
"""
|
527 |
examples = {
|
528 |
"valid": SAMPLE_VALID_RDF,
|
|
|
723 |
### π§ **MCP Server Mode:**
|
724 |
This app functions as both a web interface AND an MCP server for Claude Desktop and other MCP clients.
|
725 |
|
726 |
+
**Available MCP Tools:**
|
727 |
- `validate_rdf_tool`: Validate RDF/XML against SHACL shapes
|
728 |
- `get_ai_suggestions`: Get AI-powered fix suggestions
|
729 |
- `get_ai_correction`: Generate corrected RDF/XML
|
730 |
- `get_rdf_examples`: Retrieve example RDF snippets
|
731 |
+
- `validate_rdf_interface`: Complete validation with AI suggestions and corrections (primary tool)
|
732 |
+
|
733 |
+
**MCP Configuration (Streamable HTTP):**
|
734 |
+
Add this configuration to your MCP client (Claude Desktop, etc.):
|
735 |
|
736 |
+
```json
|
737 |
+
{
|
738 |
+
"mcpServers": {
|
739 |
+
"rdf-validator": {
|
740 |
+
"url": "https://jimfhahn-mcp4rdf.hf.space/gradio_api/mcp/"
|
741 |
+
}
|
742 |
+
}
|
743 |
+
}
|
744 |
+
```
|
745 |
+
|
746 |
+
**Alternative SSE Configuration:**
|
747 |
+
```json
|
748 |
+
{
|
749 |
+
"mcpServers": {
|
750 |
+
"rdf-validator": {
|
751 |
+
"url": "https://jimfhahn-mcp4rdf.hf.space/gradio_api/mcp/sse"
|
752 |
+
}
|
753 |
+
}
|
754 |
+
}
|
755 |
+
```
|
756 |
|
757 |
### π‘ **Features:**
|
758 |
- β
Real-time RDF/XML validation against SHACL schemas
|