JayBene1 commited on
Commit
c222a81
·
verified ·
1 Parent(s): 0e77bfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -4,8 +4,8 @@ import json
4
  from typing import List, Dict, Any
5
  import pandas as pd
6
 
7
- # Hardcoded API endpoint
8
- API_ENDPOINT = "https://huggingface.co/spaces/JayBene1/testapicontacts"
9
 
10
  # Professional color scheme inspired by corporate/real estate companies
11
  theme = gr.themes.Soft(
@@ -54,17 +54,14 @@ def search_contacts(url: str) -> tuple[str, str]:
54
  url = 'https://' + url
55
 
56
  try:
57
- # Prepare the API request
58
  headers = {
59
  'Content-Type': 'application/json'
60
  }
61
 
 
62
  payload = {
63
- "inputs": url,
64
- "parameters": {
65
- "task": "contact_search",
66
- "url": url
67
- }
68
  }
69
 
70
  # Make the API request to the hardcoded endpoint
@@ -79,8 +76,14 @@ def search_contacts(url: str) -> tuple[str, str]:
79
  try:
80
  result = response.json()
81
 
 
 
 
 
 
 
82
  # Format the results for display
83
- formatted_output = format_contact_results(result, url)
84
  raw_json = json.dumps(result, indent=2)
85
 
86
  return formatted_output, raw_json
 
4
  from typing import List, Dict, Any
5
  import pandas as pd
6
 
7
+ # Hardcoded API endpoint - Updated to correct Hugging Face Spaces API format
8
+ API_ENDPOINT = "https://jaybene1-testapicontacts.hf.space/api/predict"
9
 
10
  # Professional color scheme inspired by corporate/real estate companies
11
  theme = gr.themes.Soft(
 
54
  url = 'https://' + url
55
 
56
  try:
57
+ # Prepare the API request for Hugging Face Spaces
58
  headers = {
59
  'Content-Type': 'application/json'
60
  }
61
 
62
+ # Hugging Face Spaces API format
63
  payload = {
64
+ "data": [url]
 
 
 
 
65
  }
66
 
67
  # Make the API request to the hardcoded endpoint
 
76
  try:
77
  result = response.json()
78
 
79
+ # Hugging Face Spaces API returns data in a different format
80
+ if isinstance(result, dict) and 'data' in result:
81
+ actual_result = result['data'][0] if result['data'] else {}
82
+ else:
83
+ actual_result = result
84
+
85
  # Format the results for display
86
+ formatted_output = format_contact_results(actual_result, url)
87
  raw_json = json.dumps(result, indent=2)
88
 
89
  return formatted_output, raw_json