6fdzddlmZddlZddlmZmZddlZddlmZ ddl Tddl Tddl m Z dd ZddZeddd5Zeddd5ZeZeZdddn #1swxYwYdddn #1swxYwYdZejjjZdS)) annotationsN)ListTuple)utils)*) render_latexy=List[List[str | Tuple[str] | Tuple[str, str] | None] | Tuple]returnList[List[str | Dict | None]]cD|gSg}|D]}t|ttfs Jd|t|dks Jd||||dd||ddg|S) a Parameters: y: List of lists representing the message and response pairs. Each message and response should be a string, which may be in Markdown format. It can also be a tuple whose first element is a string filepath or URL to an image/video/audio, and second (optional) element is the alt text, in which case the media file is displayed. It can also be None, in which case that message is not displayed. Returns: List of lists representing the message and response. Each message and response will be a string of HTML, or a dictionary with media information. Or None if the message is not to be displayed. Nz6Expected a list of lists or list of tuples. Received: zNExpected a list of lists of length 2 or list of tuples of length 2. Received: ruserbot) isinstancetuplelistlenappend_postprocess_chat_messages)selfr processed_messages message_pairs ;/Users/treediagram/dev/ChuanhuChatGPT/modules/overwrites.py postprocessr s 9I  Ludm W WV VV W W WL!!Q&&&n`lnn'&&  % %33LOVLL33LOUKK     "! chat_messagestr | Tuple | List | None message_typestrstr | Dict | Nonec|dSt|ttfrT|d}tj|}||}||t |dkr|dnddddSt|trK|dkrt|st|}n$|dkrt|st|}|Std|)NrrT)name mime_typealt_textdatais_filerrz'Invalid message for Chatbot component: ) rrr client_utils get_mimetypemake_temp_copy_if_neededrr!detect_converted_markconvert_mdtext convert_asis ValueError)rrr filepathr%s rpostprocess_chat_messagesr1*s  4  udm 4 4 W#AH$1(;;I44X>>H &/2#/ #=#=L U|UUVV Vrz./assets/custom.jsrzutf-8)encodingz./assets/external-scripts.jsctddtdtdtrdz fd}|tjj_dS)NzReloading javascript...zaG ct|i|}|jddd|_||S)Nszutf8)GradioTemplateResponseOriginalbodyreplaceencode init_headers)argskwargsresjss rtemplate_responsez,reload_javascript..template_responseSsY,d=f==8##J20E0Ef0M0MNN  r)printcustomJSexternalScriptsrgrroutes templatesTemplateResponse)r@r?s @rreload_javascriptrHKso #$$$ OH O O_ O O OB     ,=BI(((r)r r r r )rrr r!r r") __future__rloggingtypingrr mdtex2html gradio_clientrr)modules.presetsmodules.index_funcmodules.configrrr1openff1readrBrCrHrDrErFrGr7rrrVs""""""////// ''''''"""":WWWW6 T g666 !D 'w??? CEvvxxHggiiO                              === "$!4!Es6B)B9 BB B B BB #B