Spaces:
Paused
Paused
Add Hugging Face Spaces deployment configuration
Browse files- Add Dockerfile for containerized deployment
- Add setup_env.py to auto-generate databases on first run
- Update README with HF Spaces metadata
- Dockerfile +19 -0
- README.md +10 -0
- setup_env.py +38 -0
Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
# Install dependencies
|
| 6 |
+
COPY requirements.txt .
|
| 7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
+
|
| 9 |
+
# Copy application code
|
| 10 |
+
COPY . .
|
| 11 |
+
|
| 12 |
+
# Setup environment (generate databases & knowledge graph)
|
| 13 |
+
RUN python setup_env.py
|
| 14 |
+
|
| 15 |
+
# Expose Chainlit default port for HF Spaces
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
|
| 18 |
+
# Run the Chainlit app
|
| 19 |
+
CMD ["chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Schema Translator
|
| 2 |
|
| 3 |
An intelligent contract schema translation system that enables querying across multiple enterprise customers with heterogeneous database schemas using LLM-powered semantic understanding.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Schema Translator
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# Schema Translator
|
| 12 |
|
| 13 |
An intelligent contract schema translation system that enables querying across multiple enterprise customers with heterogeneous database schemas using LLM-powered semantic understanding.
|
setup_env.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Setup environment for Hugging Face Spaces deployment."""
|
| 3 |
+
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
def setup():
|
| 8 |
+
"""Initialize databases and knowledge graph if they don't exist."""
|
| 9 |
+
|
| 10 |
+
# Check if already initialized
|
| 11 |
+
if Path("databases").exists() and Path("knowledge_graph.json").exists():
|
| 12 |
+
print("β Environment already initialized")
|
| 13 |
+
return
|
| 14 |
+
|
| 15 |
+
print("π Initializing environment for first run...")
|
| 16 |
+
|
| 17 |
+
# Generate databases
|
| 18 |
+
print("\n1. Generating customer databases...")
|
| 19 |
+
try:
|
| 20 |
+
from schema_translator.mock_data import main as generate_databases
|
| 21 |
+
generate_databases()
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"β Error generating databases: {e}")
|
| 24 |
+
sys.exit(1)
|
| 25 |
+
|
| 26 |
+
# Generate knowledge graph
|
| 27 |
+
print("\n2. Initializing knowledge graph...")
|
| 28 |
+
try:
|
| 29 |
+
from initialize_kg import main as initialize_kg
|
| 30 |
+
initialize_kg()
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"β Error initializing knowledge graph: {e}")
|
| 33 |
+
sys.exit(1)
|
| 34 |
+
|
| 35 |
+
print("\nβ Environment setup complete!")
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
setup()
|