Upload code/agentic_chat.py with huggingface_hub
Browse files174 unmodified lines17517617717817918055 unmodified lines236237238239240241242243244245246247248249250251174 unmodified linesprint(f"\n🤖 ViuAI:")current_color = RESETsearch_count = 0while True:max_new = min(1024, 2048 - input_ids.size(1))55 unmodified linesfull_reply_text += new_text# --- Live Colorization Logic ---if "[THINK]" in full_reply_text and "[/THINK]" not in full_reply_text:if current_color != GREY:sys.stdout.write(GREY)current_color = GREYelif "<search>" in full_reply_text and "</search>" not in full_reply_text:if current_color != YELLOW:sys.stdout.write(YELLOW)current_color = YELLOWelif "[/THINK]" in full_reply_text or "</search>" in full_reply_text:if current_color != RESET:sys.stdout.write(RESET)current_color = RESET174 unmodified lines17517617717817918018118218318418555 unmodified lines241242243244245246247248249250251252253254255256257258259260261262263264174 unmodified linesprint(f"\n🤖 ViuAI:")current_color = RESETsearch_count = 0# Track open/close counts for proper colorizationthink_open = 0think_close = 0search_open = 0search_close_count = 0while True:max_new = min(1024, 2048 - input_ids.size(1))55 unmodified linesfull_reply_text += new_text# --- Live Colorization Logic (count-based, works across turns) ---think_open = full_reply_text.count("[THINK]")think_close = full_reply_text.count("[/THINK]")search_open = full_reply_text.count("<search>")search_close_count = full_reply_text.count("</search>")in_think = think_open > think_closein_search = search_open > search_close_countif in_think:if current_color != GREY:sys.stdout.write(GREY)current_color = GREYelif in_search:if current_color != YELLOW:sys.stdout.write(YELLOW)current_color = YELLOWelse:if current_color != RESET:sys.stdout.write(RESET)current_color = RESET
code/agentic_chat.py+17-4