awacke1 commited on
Commit
1ded060
Β·
verified Β·
1 Parent(s): 33f7a5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -24
app.py CHANGED
@@ -421,7 +421,6 @@ def inject_base_url(url: str) -> str:
421
  return url
422
  return f"{BASE_URL}{url}"
423
 
424
- # Our default diagram, containing the "click" lines with /?q=...
425
  DEFAULT_MERMAID = """
426
  flowchart LR
427
  U((User 😎)) -- "Talk πŸ—£οΈ" --> LLM[LLM Agent πŸ€–\\nExtract Info]
@@ -453,9 +452,8 @@ def main():
453
  st.markdown(search_payload)
454
  process_text(search_payload)
455
 
456
- # If an 'action' param is present
457
- if 'action' in query_params:
458
- action_list = query_params['action']
459
  if action_list:
460
  action = action_list[0]
461
  if action == 'show_message':
@@ -464,8 +462,8 @@ def main():
464
  clear_query_params()
465
 
466
  # If a 'query' param is present, show content or image
467
- if 'query' in query_params:
468
- query_val = query_params['query'][0]
469
  display_content_or_image(query_val)
470
 
471
  # ---------------------------------------------
@@ -480,29 +478,23 @@ def main():
480
  base_diagram = DEFAULT_MERMAID
481
  lines = base_diagram.strip().split("\n")
482
  new_lines = []
483
-
484
  for line in lines:
485
- # We look for lines like: click SOMENODE "/?q=Something" _self
486
  if "click " in line and '"/?' in line:
487
- # Try to extract the URL part
488
- parts = re.split(r'click\s+\S+\s+"([^"]+)"\s+("_self")', line)
489
- if len(parts) == 4:
490
- # Example:
491
- # parts[0] -> 'click LLM '
492
- # parts[1] -> '/?q=LLM%20Agent%20Extract%20Info'
493
- # parts[2] -> ' _self'
494
- # parts[3] -> '' or trailing
495
- old_url = parts[1]
496
- # 1) Prepend base if needed
497
  new_url = inject_base_url(old_url)
498
- # 2) Possibly add &model=1
499
  new_url = append_model_param(new_url, model_selected)
500
 
501
- # Recombine
502
- new_line = f"{parts[0]}\"{new_url}\" {parts[2]}"
503
  new_lines.append(new_line)
504
  else:
505
- # If we can't parse it, keep it as is
506
  new_lines.append(line)
507
  else:
508
  new_lines.append(line)
@@ -550,7 +542,6 @@ def main():
550
  with right_col:
551
  st.subheader("Mermaid Side πŸ§œβ€β™‚οΈ")
552
 
553
- # We store the final code in session state, so user can edit
554
  if "current_mermaid" not in st.session_state:
555
  st.session_state["current_mermaid"] = mermaid_code
556
 
@@ -587,7 +578,7 @@ def main():
587
  num_columns_video = st.slider("Choose Number of Video Columns", 1, 15, 5, key="num_columns_video")
588
  display_videos_and_links(num_columns_video)
589
 
590
- # (Optionally) Extended text interface
591
  showExtendedTextInterface = False
592
  if showExtendedTextInterface:
593
  # For example:
 
421
  return url
422
  return f"{BASE_URL}{url}"
423
 
 
424
  DEFAULT_MERMAID = """
425
  flowchart LR
426
  U((User 😎)) -- "Talk πŸ—£οΈ" --> LLM[LLM Agent πŸ€–\\nExtract Info]
 
452
  st.markdown(search_payload)
453
  process_text(search_payload)
454
 
455
+ if 'action' in st.query_params:
456
+ action_list = st.query_params['action']
 
457
  if action_list:
458
  action = action_list[0]
459
  if action == 'show_message':
 
462
  clear_query_params()
463
 
464
  # If a 'query' param is present, show content or image
465
+ if 'query' in st.query_params:
466
+ query_val = st.query_params['query'][0]
467
  display_content_or_image(query_val)
468
 
469
  # ---------------------------------------------
 
478
  base_diagram = DEFAULT_MERMAID
479
  lines = base_diagram.strip().split("\n")
480
  new_lines = []
 
481
  for line in lines:
 
482
  if "click " in line and '"/?' in line:
483
+ parts = re.split(r'click\s+\S+\s+"([^"]+)"\s+(\S+)', line.strip())
484
+ # e.g. line: click U "/?q=User%20😎" _self
485
+ # parts might be:
486
+ # [ 'click U ', '/?q=User%20😎', '_self', '' ]
487
+ if len(parts) >= 3:
488
+ prefix = parts[0] # e.g. "click U "
489
+ old_url = parts[1] # e.g. /?q=User%20😎
490
+ target = parts[2] # e.g. _self or _blank
491
+
 
492
  new_url = inject_base_url(old_url)
 
493
  new_url = append_model_param(new_url, model_selected)
494
 
495
+ new_line = f'{prefix}"{new_url}" {target}'
 
496
  new_lines.append(new_line)
497
  else:
 
498
  new_lines.append(line)
499
  else:
500
  new_lines.append(line)
 
542
  with right_col:
543
  st.subheader("Mermaid Side πŸ§œβ€β™‚οΈ")
544
 
 
545
  if "current_mermaid" not in st.session_state:
546
  st.session_state["current_mermaid"] = mermaid_code
547
 
 
578
  num_columns_video = st.slider("Choose Number of Video Columns", 1, 15, 5, key="num_columns_video")
579
  display_videos_and_links(num_columns_video)
580
 
581
+ # If you want extended UI for text or glossary
582
  showExtendedTextInterface = False
583
  if showExtendedTextInterface:
584
  # For example: