KevanSoon commited on
Commit
1899ec7
·
1 Parent(s): 91a1f6b

testing endpoint

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -88,41 +88,41 @@ SUPABASE_SERVICE_ROLE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY")
88
  # --- START: NEW ENDPOINT FOR THE REFACTORED TOOL ---
89
 
90
 
91
- @app.post("/api/analyze_contract")
92
- async def analyze_contract_endpoint(file: UploadFile = File(...)):
93
- """
94
- Receives an uploaded HTML contract, analyzes it to extract key clauses
95
- and language, and returns a structured JSON response containing a
96
- user-friendly HTML summary sheet.
97
- """
98
- # 1. Validate file type
99
- if file.content_type != "text/html":
100
- raise HTTPException(
101
- status_code=400, detail="Unsupported file type. Please upload a .html file."
102
- )
103
 
104
- try:
105
- # 2. Read HTML content from the uploaded file
106
- html_content_bytes = await file.read()
107
- html_content = html_content_bytes.decode("utf-8")
108
 
109
- # 3. Call the new, powerful analysis tool
110
- analysis_results = await analyze_contract(html_content)
111
 
112
- # 4. Handle potential errors returned from the tool
113
- if "error" in analysis_results:
114
- # Use a 500 server error for tool-side failures
115
- raise HTTPException(status_code=500, detail=analysis_results["error"])
116
 
117
- # 5. Return the successful analysis results
118
- # FastAPI will automatically convert the dictionary to a JSON response
119
- return analysis_results
120
 
121
- except Exception as e:
122
- # Catch any other unexpected errors during file processing or the API call
123
- raise HTTPException(
124
- status_code=500, detail=f"An unexpected server error occurred: {str(e)}"
125
- )
126
 
127
 
128
  # @app.post("/upload")
 
88
  # --- START: NEW ENDPOINT FOR THE REFACTORED TOOL ---
89
 
90
 
91
+ # @app.post("/api/analyze_contract")
92
+ # async def analyze_contract_endpoint(file: UploadFile = File(...)):
93
+ # """
94
+ # Receives an uploaded HTML contract, analyzes it to extract key clauses
95
+ # and language, and returns a structured JSON response containing a
96
+ # user-friendly HTML summary sheet.
97
+ # """
98
+ # # 1. Validate file type
99
+ # if file.content_type != "text/html":
100
+ # raise HTTPException(
101
+ # status_code=400, detail="Unsupported file type. Please upload a .html file."
102
+ # )
103
 
104
+ # try:
105
+ # # 2. Read HTML content from the uploaded file
106
+ # html_content_bytes = await file.read()
107
+ # html_content = html_content_bytes.decode("utf-8")
108
 
109
+ # # 3. Call the new, powerful analysis tool
110
+ # analysis_results = await analyze_contract(html_content)
111
 
112
+ # # 4. Handle potential errors returned from the tool
113
+ # if "error" in analysis_results:
114
+ # # Use a 500 server error for tool-side failures
115
+ # raise HTTPException(status_code=500, detail=analysis_results["error"])
116
 
117
+ # # 5. Return the successful analysis results
118
+ # # FastAPI will automatically convert the dictionary to a JSON response
119
+ # return analysis_results
120
 
121
+ # except Exception as e:
122
+ # # Catch any other unexpected errors during file processing or the API call
123
+ # raise HTTPException(
124
+ # status_code=500, detail=f"An unexpected server error occurred: {str(e)}"
125
+ # )
126
 
127
 
128
  # @app.post("/upload")