Spaces:
Sleeping
Sleeping
Update appStore/rag_utils.py
Browse files- appStore/rag_utils.py +3 -4
appStore/rag_utils.py
CHANGED
@@ -39,17 +39,16 @@ def build_context_for_result(res, compute_title_fn):
|
|
39 |
|
40 |
def highlight_query(text, query):
|
41 |
"""
|
42 |
-
Highlight the query text in the given string with
|
43 |
-
|
44 |
Args:
|
45 |
text (str): The full text in which to highlight matches.
|
46 |
query (str): The substring (query) to highlight.
|
47 |
|
48 |
Returns:
|
49 |
-
str: The
|
50 |
"""
|
51 |
pattern = re.compile(re.escape(query), re.IGNORECASE)
|
52 |
-
return pattern.sub(lambda m: f"
|
53 |
|
54 |
def format_project_id(pid):
|
55 |
"""
|
|
|
39 |
|
40 |
def highlight_query(text, query):
|
41 |
"""
|
42 |
+
Highlight the query text in the given string with simple bold markdown.
|
|
|
43 |
Args:
|
44 |
text (str): The full text in which to highlight matches.
|
45 |
query (str): The substring (query) to highlight.
|
46 |
|
47 |
Returns:
|
48 |
+
str: The markdown-formatted string with highlighted matches.
|
49 |
"""
|
50 |
pattern = re.compile(re.escape(query), re.IGNORECASE)
|
51 |
+
return pattern.sub(lambda m: f"**{m.group(0)}**", text)
|
52 |
|
53 |
def format_project_id(pid):
|
54 |
"""
|