Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,9 +29,6 @@ index = pc.Index(PINECONE_INDEX)
|
|
| 29 |
embedder = SentenceTransformer("all-mpnet-base-v2")
|
| 30 |
api = HfApi()
|
| 31 |
|
| 32 |
-
# ----------------- EMBEDDER -----------------
|
| 33 |
-
embedder = SentenceTransformer("all-mpnet-base-v2")
|
| 34 |
-
|
| 35 |
# ----------------- HELPERS -----------------
|
| 36 |
def load_reference_text(uploaded_file) -> str:
|
| 37 |
if not uploaded_file:
|
|
@@ -64,14 +61,14 @@ def load_templates_json() -> List[Dict]:
|
|
| 64 |
except Exception:
|
| 65 |
return []
|
| 66 |
|
| 67 |
-
def parse_json_safe(raw_text: str, fallback: str) -> List[str]:
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
def save_template_to_hf(name: str, analysis: str) -> Tuple[bool, str]:
|
| 77 |
"""Save new template into HF dataset repo (templates.json)."""
|
|
@@ -235,7 +232,7 @@ def generate_legal_draft(case_text, uploaded_file, template_name, new_template_n
|
|
| 235 |
yield gr.update(value="🔍 Searching in Knowledge Base..."), None
|
| 236 |
|
| 237 |
queries = build_queries_with_llm(case_text)
|
| 238 |
-
context_text, citations = pinecone_search(queries, top_k=
|
| 239 |
|
| 240 |
# Handle template
|
| 241 |
template_analysis = ""
|
|
|
|
| 29 |
embedder = SentenceTransformer("all-mpnet-base-v2")
|
| 30 |
api = HfApi()
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
# ----------------- HELPERS -----------------
|
| 33 |
def load_reference_text(uploaded_file) -> str:
|
| 34 |
if not uploaded_file:
|
|
|
|
| 61 |
except Exception:
|
| 62 |
return []
|
| 63 |
|
| 64 |
+
# def parse_json_safe(raw_text: str, fallback: str) -> List[str]:
|
| 65 |
+
# try:
|
| 66 |
+
# return json.loads(raw_text)
|
| 67 |
+
# except:
|
| 68 |
+
# matches = re.findall(r'"([^"]+)"', raw_text)
|
| 69 |
+
# if matches:
|
| 70 |
+
# return matches
|
| 71 |
+
# return [fallback[:512]]
|
| 72 |
|
| 73 |
def save_template_to_hf(name: str, analysis: str) -> Tuple[bool, str]:
|
| 74 |
"""Save new template into HF dataset repo (templates.json)."""
|
|
|
|
| 232 |
yield gr.update(value="🔍 Searching in Knowledge Base..."), None
|
| 233 |
|
| 234 |
queries = build_queries_with_llm(case_text)
|
| 235 |
+
context_text, citations = pinecone_search(queries, top_k=15)
|
| 236 |
|
| 237 |
# Handle template
|
| 238 |
template_analysis = ""
|