jackkuo commited on
Commit
303f670
Β·
1 Parent(s): 37d9cfb

update python

Browse files
Files changed (3) hide show
  1. app.py +9 -82
  2. config.json +1 -1
  3. runtime.txt +1 -0
app.py CHANGED
@@ -301,11 +301,7 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
301
  if not hasattr(callback_func, '_data_counter'):
302
  callback_func._data_counter = 0
303
 
304
- # Initialize persistent storage for all processed data
305
- if not hasattr(callback_func, '_persistent_data'):
306
- callback_func._persistent_data = []
307
- callback_func._persistent_data.append("πŸš€ **Session Started** - All data will be preserved\n")
308
- callback_func._persistent_data.append("---\n")
309
 
310
 
311
 
@@ -473,9 +469,6 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
473
  accumulated_tool.append(f"\nπŸš€ **Task Started**: {content}\n")
474
  # Real-time UI update for task start
475
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
476
- # Show data counter at the top
477
- st.markdown(f"**πŸ“Š Total Data Messages: {callback_func._data_counter}**")
478
- st.markdown("---")
479
  st.markdown("".join(accumulated_tool))
480
  elif "```bdd-long-task-end" in content:
481
  # Extract task info
@@ -490,9 +483,6 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
490
  accumulated_tool.append(f"\nβœ… **Task Completed**: {content}\n")
491
  # Real-time UI update for task completion
492
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
493
- # Show data counter at the top
494
- st.markdown(f"**πŸ“Š Total Data Messages: {callback_func._data_counter}**")
495
- st.markdown("---")
496
  st.markdown("".join(accumulated_tool))
497
  elif "```bdd-resource-lookup" in content:
498
  # Extract resource info
@@ -514,9 +504,6 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
514
  accumulated_tool.append(f"\nπŸ“š **Resources**: {content}\n")
515
  # Real-time UI update for resources
516
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
517
- # Show data counter at the top
518
- st.markdown(f"**πŸ“Š Total Data Messages: {callback_func._data_counter}**")
519
- st.markdown("---")
520
  st.markdown("".join(accumulated_tool))
521
  elif "```bdd-chat-agent-task" in content:
522
  # Extract chat agent task info
@@ -589,45 +576,22 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
589
  timestamp = time.strftime("%H:%M:%S")
590
 
591
  # Format the data for display
592
- data_entry = ""
593
  if isinstance(data_content, str):
594
- data_entry = f"\nπŸ“‘ **Data [{data_type}]** [{timestamp}]: {data_content}\n"
595
  else:
596
- data_entry = f"\nπŸ“‘ **Data [{data_type}]** [{timestamp}]:\n```json\n{json.dumps(data_obj, indent=2)}\n```\n"
597
-
598
- # Add to both temporary and persistent storage
599
- accumulated_tool.append(data_entry)
600
- callback_func._persistent_data.append(data_entry)
601
 
602
  # Immediate real-time UI update for any data: message
603
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
604
- # Show data counter at the top
605
- st.markdown(f"**πŸ“Š Total Data Messages: {callback_func._data_counter}**")
606
- st.markdown("---")
607
- # Show persistent data first, then current accumulated data
608
- st.markdown("".join(callback_func._persistent_data))
609
- st.markdown("---")
610
- st.markdown("**πŸ”„ Current Stream:**")
611
  st.markdown("".join(accumulated_tool))
612
  else:
613
  # Handle non-dict data objects
614
  import time
615
  timestamp = time.strftime("%H:%M:%S")
616
- data_entry = f"\nπŸ“‘ **Raw Data** [{timestamp}]:\n```json\n{json_str}\n```\n"
617
-
618
- # Add to both temporary and persistent storage
619
- accumulated_tool.append(data_entry)
620
- callback_func._persistent_data.append(data_entry)
621
 
622
  # Immediate real-time UI update
623
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
624
- # Show data counter at the top
625
- st.markdown(f"**πŸ“Š Total Data Messages: {callback_func._data_counter}**")
626
- st.markdown("---")
627
- # Show persistent data first, then current accumulated data
628
- st.markdown("".join(callback_func._persistent_data))
629
- st.markdown("---")
630
- st.markdown("**πŸ”„ Current Stream:**")
631
  st.markdown("".join(accumulated_tool))
632
  except json.JSONDecodeError:
633
  # If not valid JSON, check if it's streaming text content
@@ -652,27 +616,11 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
652
  # Real-time UI update
653
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
654
  st.markdown("".join(accumulated_tool))
655
- else:
656
- # Handle empty or whitespace-only data
657
- import time
658
- timestamp = time.strftime("%H:%M:%S")
659
- accumulated_tool.append(f"\nπŸ“‘ **Empty Data** [{timestamp}]: (empty or whitespace)\n")
660
-
661
- # Immediate real-time UI update
662
- with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
663
- st.markdown("".join(accumulated_tool))
664
- except Exception as e:
665
  # Fallback: treat as plain text, but only if it's meaningful
666
- import time
667
- timestamp = time.strftime("%H:%M:%S")
668
  if line.strip() and len(line.strip()) > 1: # Only show non-trivial content
669
- accumulated_tool.append(f"\nπŸ“ **Info** [{timestamp}]: {line.strip()}\n")
670
- else:
671
- accumulated_tool.append(f"\n⚠️ **Error** [{timestamp}]: {str(e)}\n")
672
-
673
- # Immediate real-time UI update for error cases
674
- with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
675
- st.markdown("".join(accumulated_tool))
676
  elif line.startswith('ping - '):
677
  # Handle ping messages directly
678
  timestamp = line.split('ping - ')[-1]
@@ -682,29 +630,8 @@ def get_streaming_callback(text_placeholder, tool_placeholder):
682
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
683
  st.markdown("".join(accumulated_tool))
684
  elif line and not line.startswith(':'):
685
- # Other non-empty lines - capture any other data patterns
686
- import time
687
- timestamp = time.strftime("%H:%M:%S")
688
-
689
- # Check if this line contains any meaningful data
690
- if line.strip() and len(line.strip()) > 1:
691
- # Try to detect if it's JSON-like content
692
- if line.strip().startswith('{') or line.strip().startswith('['):
693
- try:
694
- # Try to parse as JSON for better formatting
695
- import json
696
- parsed_json = json.loads(line.strip())
697
- accumulated_tool.append(f"\nπŸ“‘ **JSON Data** [{timestamp}]:\n```json\n{json.dumps(parsed_json, indent=2)}\n```\n")
698
- except:
699
- # If not valid JSON, show as regular data
700
- accumulated_tool.append(f"\nπŸ“‘ **Data** [{timestamp}]: {line.strip()}\n")
701
- else:
702
- # Regular text data
703
- accumulated_tool.append(f"\nπŸ“ **Info** [{timestamp}]: {line.strip()}\n")
704
-
705
- # Immediate real-time UI update for any captured data
706
- with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
707
- st.markdown("".join(accumulated_tool))
708
  else:
709
  # Regular tool response content
710
  accumulated_tool.append(
 
301
  if not hasattr(callback_func, '_data_counter'):
302
  callback_func._data_counter = 0
303
 
304
+
 
 
 
 
305
 
306
 
307
 
 
469
  accumulated_tool.append(f"\nπŸš€ **Task Started**: {content}\n")
470
  # Real-time UI update for task start
471
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
 
 
 
472
  st.markdown("".join(accumulated_tool))
473
  elif "```bdd-long-task-end" in content:
474
  # Extract task info
 
483
  accumulated_tool.append(f"\nβœ… **Task Completed**: {content}\n")
484
  # Real-time UI update for task completion
485
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
 
 
 
486
  st.markdown("".join(accumulated_tool))
487
  elif "```bdd-resource-lookup" in content:
488
  # Extract resource info
 
504
  accumulated_tool.append(f"\nπŸ“š **Resources**: {content}\n")
505
  # Real-time UI update for resources
506
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
 
 
 
507
  st.markdown("".join(accumulated_tool))
508
  elif "```bdd-chat-agent-task" in content:
509
  # Extract chat agent task info
 
576
  timestamp = time.strftime("%H:%M:%S")
577
 
578
  # Format the data for display
 
579
  if isinstance(data_content, str):
580
+ accumulated_tool.append(f"\nπŸ“‘ **Data [{data_type}]** [{timestamp}]: {data_content}\n")
581
  else:
582
+ accumulated_tool.append(f"\nπŸ“‘ **Data [{data_type}]** [{timestamp}]:\n```json\n{json.dumps(data_obj, indent=2)}\n```\n")
 
 
 
 
583
 
584
  # Immediate real-time UI update for any data: message
585
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
 
 
 
 
 
 
 
586
  st.markdown("".join(accumulated_tool))
587
  else:
588
  # Handle non-dict data objects
589
  import time
590
  timestamp = time.strftime("%H:%M:%S")
591
+ accumulated_tool.append(f"\nπŸ“‘ **Raw Data** [{timestamp}]:\n```json\n{json_str}\n```\n")
 
 
 
 
592
 
593
  # Immediate real-time UI update
594
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
 
 
 
 
 
 
 
595
  st.markdown("".join(accumulated_tool))
596
  except json.JSONDecodeError:
597
  # If not valid JSON, check if it's streaming text content
 
616
  # Real-time UI update
617
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
618
  st.markdown("".join(accumulated_tool))
619
+
620
+ except Exception:
 
 
 
 
 
 
 
 
621
  # Fallback: treat as plain text, but only if it's meaningful
 
 
622
  if line.strip() and len(line.strip()) > 1: # Only show non-trivial content
623
+ accumulated_tool.append(f"\nπŸ“ **Info**: {line.strip()}\n")
 
 
 
 
 
 
624
  elif line.startswith('ping - '):
625
  # Handle ping messages directly
626
  timestamp = line.split('ping - ')[-1]
 
630
  with tool_placeholder.expander("πŸ”§ Tool Call Information", expanded=True):
631
  st.markdown("".join(accumulated_tool))
632
  elif line and not line.startswith(':'):
633
+ # Other non-empty lines
634
+ accumulated_tool.append(f"\nπŸ“ **Info**: {line.strip()}\n")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  else:
636
  # Regular tool response content
637
  accumulated_tool.append(
config.json CHANGED
@@ -8,7 +8,7 @@
8
  },
9
  "qa": {
10
  "transport": "sse",
11
- "url": "http://10.15.56.148:8000/qa"
12
  },
13
  "review_generate": {
14
  "transport": "sse",
 
8
  },
9
  "qa": {
10
  "transport": "sse",
11
+ "url": "http://10.15.56.148:9230/sse"
12
  },
13
  "review_generate": {
14
  "transport": "sse",
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python: 3.12