Upload code/agentic_chat.py with huggingface_hub
Browse files173 unmodified lines17417517617717817979 unmodified lines2592602612622632642653 unmodified lines269270271272273274275276173 unmodified linesfull_reply_text = ""print(f"\n🤖 ViuAI:")current_color = RESETwhile True:max_new = min(1024, 2048 - input_ids.size(1))79 unmodified linesbreak# String Intercept for Repetition Bug (Fixes <search> loop)if "</search>" in full_reply_text:triggered_search = Truebreak3 unmodified linessys.stdout.write(RESET)print(f"\n\n{CYAN}🔍 [Agent is Searching the Internet...]{RESET}")search_match = re.search(r'<search>(.*?)</search>', full_reply_text, re.DOTALL)query = search_match.group(1).strip() if search_match else ""if query:print(f"{CYAN} Query: {query}{RESET}")173 unmodified lines17417517617717817918079 unmodified lines2602612622632642652662672683 unmodified lines272273274275276277278279280173 unmodified linesfull_reply_text = ""print(f"\n🤖 ViuAI:")current_color = RESETsearch_count = 0while True:max_new = min(1024, 2048 - input_ids.size(1))79 unmodified linesbreak# String Intercept for Repetition Bug (Fixes <search> loop)current_search_count = full_reply_text.count("</search>")if current_search_count > search_count:search_count = current_search_counttriggered_search = Truebreak3 unmodified linessys.stdout.write(RESET)print(f"\n\n{CYAN}🔍 [Agent is Searching the Internet...]{RESET}")# Get the LAST search block in the textsearch_matches = re.findall(r'<search>(.*?)</search>', full_reply_text, re.DOTALL)query = search_matches[-1].strip() if search_matches else ""if query:print(f"{CYAN} Query: {query}{RESET}")
code/agentic_chat.py+7-3