File size: 1,820 Bytes
f61ef17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# FILE: /home/mrdbo/projects/moltbot-hybrid-engine/trigger_cloud.py
# PURPOSE: Use this on your LOCAL machine to send a report to the cloud for analysis.

import requests
import sys

# This MUST be your actual Hugging Face Space URL.
HF_SPACE_URL = "https://deebee7-moltbot-hybrid-engine.hf.space"

def send_report_for_analysis(report_path: str):
    """Sends a local report file to the cloud for analysis."""
    
    # This is the address of the specific tool we want to use.
    tool_endpoint = f"{HF_SPACE_URL}/tools/analyze_report"
    
    try:
        with open(report_path, 'rb') as f:
            files = {'report_file': (report_path, f, 'application/json')}
            
            print(f"🚀 Sending '{report_path}' to the cloud toolbox for analysis...")
            response = requests.post(tool_endpoint, files=files, timeout=60)

        if response.status_code == 200:
            data = response.json()
            print("✅ Analysis Complete:")
            print(json.dumps(data, indent=2))
            return True
        else:
            print(f"❌ Cloud tool failed: {response.status_code} - {response.text}")
            return False

    except FileNotFoundError:
        print(f"❌ Error: The file was not found at '{report_path}'")
        return False
    except Exception as e:
        print(f"❌ Connection or local error: {e}")
        return False

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python trigger_cloud.py <path_to_report.json>")
        # Example usage:
        print("Example: python trigger_cloud.py /home/mrdbo/court_data/2nd_CourtBundleOutput/ENHANCED_STRUCTURE_REPORT.json")
        sys.exit(1)
        
    local_report_path = sys.argv[1]
    send_report_for_analysis(local_report_path)