utils dandy.llm.utils get_estimated_token_count_for_prompt Source code in dandy/llm/utils.py 9 10 11 12 13 14 15 16def get_estimated_token_count_for_prompt( prompt: PromptOrStr, postfix_system_prompt: PromptOrStrOrNone = None ) -> int: return service_system_prompt( system_prompt=postfix_system_prompt ).estimated_token_count + service_user_prompt(prompt).estimated_token_count get_image_mime_type_from_base64_string Source code in dandy/llm/utils.py 19 20 21 22 23 24 25 26 27 28 29 30 31 32def get_image_mime_type_from_base64_string(base64_string): SIGNATURES = { "JVBERi0": "application/pdf", "R0lGODdh": "image/gif", "R0lGODlh": "image/gif", "iVBORw0KGgo": "image/png", "/9j/": "image/jpg" } for signature in SIGNATURES: if base64_string.startswith(signature): return SIGNATURES[signature] return None