uslap commited on
Commit
b8f6c2d
·
verified ·
1 Parent(s): cf55fde

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -45,6 +45,13 @@ DESCRIPTION = """
45
  """
46
 
47
 
 
 
 
 
 
 
 
48
  def run_query(query: str) -> str:
49
  if not query or not query.strip():
50
  return "Enter a query above."
@@ -62,11 +69,19 @@ def run_query(query: str) -> str:
62
  )
63
  out = result.stdout.strip()
64
  err = result.stderr.strip()
65
- if out:
66
- return out
67
- if err:
68
- return f"[stderr]\n{err}"
69
- return "(no output)"
 
 
 
 
 
 
 
 
70
  except subprocess.TimeoutExpired:
71
  return "Query timed out (30s)."
72
  except Exception as e:
 
45
  """
46
 
47
 
48
+ NOT_FOUND_MARKERS = [
49
+ "HYPOTHESIS:",
50
+ "No entries found",
51
+ "not found in index",
52
+ "CANDIDATES:",
53
+ ]
54
+
55
  def run_query(query: str) -> str:
56
  if not query or not query.strip():
57
  return "Enter a query above."
 
69
  )
70
  out = result.stdout.strip()
71
  err = result.stderr.strip()
72
+
73
+ if not out:
74
+ return f"[stderr]\n{err}" if err else "(no output)"
75
+
76
+ # Block hypothesis / unconfirmed output — only confirmed DB data shown.
77
+ # Direction: Allah's Arabic → downstream. Hypothesis mode runs the
78
+ # reverse (downstream → candidate AA roots) without a confirmed chain.
79
+ first_line = out.splitlines()[0] if out else ""
80
+ if any(m in first_line for m in NOT_FOUND_MARKERS):
81
+ return f"Not found in DB: '{query.strip()}'\n\nOnly confirmed entries are shown here.\nRun locally with the full engine for hypothesis mode."
82
+
83
+ return out
84
+
85
  except subprocess.TimeoutExpired:
86
  return "Query timed out (30s)."
87
  except Exception as e: