
    9i6                     "   S SK r S SKrS SKJr  S SKJrJrJrJrJ	r	J
r
  S SKrS SKJrJrJrJr  SSKJr  SSKJrJr  \" 5       r\ " S S	5      5       rS
 r\" SSSS5      rS rS r/ \" S\" SS5       S3SS9P\" S\" SS5       S3SS9P\" S\" SS5       S\" S5       S3SS9P\" \R8                  S\" SS5       \" 5        S\ S3SS9P\" \R8                  S\" SS 5       \" 5        S\ S3S!S9P\" S\" S"S#5       S\" 5        S\ S\" S$5       S3	S%S9P\" S\" S"S#5       S\" 5        S\" S&5       S\" S'S(5       S3	S)S9P\" S\" S"S#5       S\" 5        S\" S*5       S3S+S9P\" S\" S,5       S3S-S9P\" S\" S.5       S\" S"5       S3S/S9P\" \R8                  S\" S"S#5       \" 5        S\ S3S0S9P\" S\" S1S25       \" 5        S\" S35       S\ S3S4S9P\" S\" S55       S3S6S9P\" S\" S75       S3S8S9P\" S\" S9S:5       S3S;S9P\" S\" S<5       S\" S=5       S3S>S9P\" \R:                  S\" S<5       \" 5        S\ S3S?S9P\" \R<                  S\" S@5       S\" SA5       \" 5        S3SBS9P\" \R>                  S\" S@5       S\" SC5       S\" SD5       S3SES9P\" \R>                  S\" S@5       \" SDSA5       S\" SC5       S3SFS9P\" \R@                  S\" S@5       S\" SD5       \" SA5       \" 5        S\ S3	SGS9P\" \RB                  S\" S@5       \" SDSASC5       \" 5        S\ S3SHS9P\" S\" SI5       S3SJS9P\" S\" S@5       S\" SK5       S3SLS9P\" S\" S@5       S\" SM5       S3SNS9P\" S\" SO5       S\" SC5       S3SPSQSR9P\" S\" SO5       \" 5        S3SSS9P\" S\" ST5       S\" SU5       S3SVS9P\" \RD                  S\" ST5       S\" SC5       S\ S3SWS9P\" \RD                  S\" ST5       \" 5        S\ S3SXS9P\" S\" SY5       S3SZS9P\" S\" S[S\5       S\ S3S]S9P\" \RD                  S\" S^S_5       \" 5        S3S`S9P\" \RD                  S\" Sa5       \" 5        S\ S3SbS9P\" \RF                  \" Sc5       S\" Sd5       S\" Se5       S3SfS9P\" S\" Sg5       S3ShS9P\" \RF                  \" Sc5       S\" SiSj5       S3SkS9P\" \RF                  \" Sc5       S\" SlSm5       Sn\ S3SoS9P\" S\" Sp5       S3SqS9P\" \RF                  \" Sc5       S\" Sd5       S3SrS9P\" S\" S.5       S\" Ss5       S3StS9P\" S\" S.5       S\" Su5       S3SvS9P\" S\" SwSx5       S3SyS9P\" S\" Sz5       S3S{S9P\" S\" S|5       S3S}S9P\" S\" S~S5       S3SS9P\" S\" SS5       \" 5        S\ S3SS9P\" \RH                  S\" SS5       \" 5        S\ S3SS9P\" S\" SS5       S3SS9P\" S\" SS5       \" 5        S3SS9P\" S\" S5       \" 5        S3SS9P\" S\" S5       S\" Su5       S3SS9P\" S\" Su5       S\" SS5       S3SS9P\" S\" Su5       S\" SS5       S3SS9P\" S\" Su5       S\" S5       S3SS9P\" S\" Su5       S\" S5       S3SS9P\" \RJ                  S\" S5       \" 5        S3SS9P\" S\" Su5       S\" S5       S3SS9P\" S\" S5       S3SS9P\" \R:                  S\" SuS5       \" 5        S\ S3SS9P\" S\" SS5       S\" S5       S3SS9P\" \R:                  S\" S5       \" 5        S3SS9P\" \R:                  S\" S5       \" 5        S3SS9P\" S\" SS5       S3SS9P\" S\" S5       S3SS9P\" \RL                  S\" S5       S\" SC5       S\ S3SS9P\" \RN                  S\" S5       \" 5        \" SC5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" \RN                  S\" S5       \" S5       S3SS9P\" \RP                  S\" S5       \" 5        S3S9P\" \RR                  S\" S5       \" 5        S3S9P\" \RT                  S\" SS5       \" 5        S\ S3SS9P\" \RV                  S\" S5       \" 5        S\ S3S9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" \RX                  S\" S5       \" 5        S3SS9P\" S\" S5       S\" S5       S3SS9P\" S\" SS5       S3SS9P\" S\" S5       S3SS9P\" S\" SS5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" \RZ                  S\" S5       \" 5        S3S9P\" \R\                  S\" S5       \" SS5       \" 5        S\ S3S9P\" \R^                  S\" S5       \" 5        S\ S3SS9P\" \R`                  S\" S5       \" 5        S3S9P\" \Rb                  S\" S5       \" 5        S\ S3S9P\" \Rd                  S\" S5       \" 5        S\ S3S9P\" \Rf                  S\" S5       \" 5        S\ S3S9P\" \Rh                  S\" S5       \" 5        S3S9P\" \Rj                  S\" S5       \" 5        S\ S3S9P\" \Rl                  S\" S5       \" SD5       S3S9P\" \Rn                  S\" S5       S\" SD5       S3S9P\" S\" SS5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S3SS9P\" S\" S5       S\" S5       S3SS9P\" S\" S5       S\" S5       S3SS9P\" S\" S5       S\" S5       S\" S5       S3SS9P\" S\" S5       S\" S5       S3GS S9P\" S\" GS5       S\" GSGS5       S3GSS9P\" S\" GS5       S\" GSGS5       S3GSS9P\" S\" GS5       S3GS	S9P\" S\" GS
5       S\" GSGS5       S3GSS9P\" S\" GS
5       S\" GSGS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GSS9P\" S\" GS5       S3GS SQSR9P\" S\" GS!GS"5       S3GS#S9P\" S\" GS$5       S3GS%S9P\" S\" GS&5       S3GS'S9P\" S\" GS(5       S3GS)S9P\" S\" GS*GS+5       S3GS,S9P\" S\" S5       S3GS-S9P\" S\" GS.5       S3GS/S9P\" S\" GS05       S3GS1S9P\" S\" GS25       S3GS3S9P\" S\" GS45       S3GS5S9P\" S\" GS65       S3GS7S9P\" S\" GS85       S3GS9S9P\" S\" GS:5       S3GS;S9P\" S\" GS<5       S3GS=S9P\" S\" GS>5       S\" GS?5       S3GS@S9P\" S\" GSA5       S3GSBS9P\" S\" GSC5       S3GSDS9P\" S\" GSE5       S3GSFS9P\" S\" GSG5       S3GSHS9P\" S\" GSIGSJGSK5       S3GSLS9P\" S\" GSMGSNGSO5       S3GSPS9P\" S\" GSQ5       S3GSRS9P\" S\" GSS5       S3GSTS9P\" S\" GSU5       S3GSVS9P\" S\" GSW5       S3GSXS9P\" S\" GSY5       S3GSZS9P\" S\" GS[5       S3GS\S9P\" S\" GS]5       S3GS^S9P\" S\" GS_5       S\" GS`5       S\" GSa5       S3GSbS9P\" S\" GSc5       S3GSdS9P\" S\" GSe5       S3GSfS9P\" S\" GSg5       S3GShS9P\" S\" GSi5       S3GSjS9P\" S\" GSk5       S3GSlS9P\" S\" GSm5       S3GSnS9P\" S\" GSo5       S3GSpS9P\" S\" GSq5       S3GSrS9P\" S\" GSs5       S\" GSt5       S3GSuS9P\" S\" GSv5       S3GSwS9P\" S\" GSx5       S3GSyS9P\" S\" GSz5       S3GS{S9P\" S\" GS|5       S3GS}S9P\" S\" GS~5       S3GSS9P\" S\" GS5       S3GSS9Pr8 " GS GS5      r9g(      N)	dataclass)AnyDictListUnionOptionalTuple)AutoTokenizer
get_loggersnapshot_download
AutoConfig   )TemplateType)Templateget_templatec                   N    \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\
\S'   Srg)	TemplateInfo   Ntemplatetemplate_regexmodelfile_prefixTallow_general_name )__name__
__module____qualname____firstlineno__r   str__annotations__r   r   r   bool__static_attributes__r       i/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/preprocessors/templates/loader.pyr   r      s,    HcNC c ##r"   r   c                     / nU  H  nSnU HR  nUR                  5       UR                  5       :w  a)  USUR                  5        UR                  5        S3-  nMN  X4-  nMT     UR                  U5        SU;   d  Mv  UR                  UR                  SS5      5        M     [	        U5      S:  a  SR                  U5      nSU-   S	-   nU$ US
   nU$ )N []- r   |()r   )upperlowerappendreplacelenjoin)namesretnameregexletters        r#   casesr8      s    
CF||~/1V\\^,V\\^,<A>>	 
 	

5%<JJu}}S#./  3x!|hhsmCi#o J !fJr"   instructchatz-rlz-itc                      S[        U 6  S3$ )Nz(?!.*r,   )r8   )r3   s    r#   nor<   .   s    5%=/##r"   c                      [        SSSS5      $ )Naudiovideovlvision)r<   r   r"   r#   no_multi_modalrB   2   s    gwh//r"   z.*llama4zllama-4zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama4)r   r   zllama3.3z	llama-3.3zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3.3zllama3.2z	llama-3.2rA   zRhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3.2-visionzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3.2)r   r   r   zllama3.1z	llama-3.1zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3.1llama3zllama-3gradientzRhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3-gradientgroqztool-usetool_usezWhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3-groq-tool-usechatqazPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3-chatqazllava-llama-3zOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llava-llama3dolphinzQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin-llama3zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama3llama2zllama-2chinesezQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama2-chinese	codellamazLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codellama	tinyllamazLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/tinyllamaz	llama-pro	llama_prozLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama-prollamaguardzOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama-guard3zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llama2deepseekzv2.5zPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-v2.5coderv2zThttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-coder-v2zQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-coderzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-v2zOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-llmzDeepSeek-V3.1zPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-v3.1v3zNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-v3r1zNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepseek-r1qwen3zNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen3-coderF)r   r   r   zHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen3zqwen2.5r@   zLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2.5vlzPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2.5-coderzJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2.5z
qwen2-mathzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2-mathzcodeqwen1.5zcodeqwen-1.5zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codeqwenqwen2zqwen1.5zHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwen2qwenzGhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwenpaligemma3nzJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gemma3n	codegemmazLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codegemmagemma3zgemma-3zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gemma3gemma2zgemma-2z\b.*zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gemma2shieldgemmazNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/shieldgemmazHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gemmaz-mixtralzRhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin-mixtralmistralzRhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin-mistraldolphin3z	dolphin-3zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dolphin3zphi-4-reasoningzQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4-reasoningzphi-4-mini-reasoningzVhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4-mini-reasoningz
llava-phi3zllava-phi-3zMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llava-phi3zphi3.5zphi-3.5zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi3.5phi3zphi-3zGhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi3z	phi4-miniz
phi-4-minizLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4-miniphi4zphi-4zGhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phi4phizFhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/phiyarnzOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/yarn-mistralzsmall3.2z	small-3.2zShttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-small3.2zsmall3.1z	small-3.1zShttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-small3.1largezPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-largesmallzPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-smallzMistral-NemozOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-nemoopenorcazShttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistral-openorcamistrallitezNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistrallite	ministralzJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mistralznous-hermes2znous-hermes-2mixtralzWhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nous-hermes2-mixtralzJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mixtral	codestralzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codestralzOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nous-hermes2znous-hermeszNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nous-hermesyizKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/yi-coderzEhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/yibakllavazKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/bakllavallavazHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/llavaznemotron-minizPhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nemotron-mininemotronzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nemotronz	minicpm-vzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/minicpm-vminicpmz-vchatglm2)r   r   chatglm3glm4zglm-4zGhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/glm4baichuanzcommand-r-pluszQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/command-r-pluszcommand-r7b-arabiczUhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/command-r7b-arabiczcommand-r7bzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/command-r7bz	command-rzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/command-rz	command-azLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/command-a	codegeex4zLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/codegeex4zwizard-vicuna
uncensoredz[https://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/wizard-vicuna-uncensored	wizardlm2z
wizardlm-2zLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/wizardlm2wizardcoderzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/wizardcoderzwizard-math
wizardmathzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/wizard-mathwizardlmzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/wizardlm	magistralzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/magistraldevstralzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/devstralvicunazIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/vicunazstable-codezNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/stable-codestablelmzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/stablelm2idefics3internlm	internlm2	internlm3zLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/internlm2YuanxverseskyworkbluelmzephyrorionTeleChattulu3ztulu-3zHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/tulu3z	athene-v2zLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/athene-v2zgranite-guardian-3zThttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-guardiangranitecodezOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite-codez3.3zMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.3z3.2zThttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.2-visionzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.2zgranite-3.12b8bzShttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.1-dense1b3bzQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3.1-moezgranite-embeddingzThttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite-embeddingz	granite-3zQhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-densezOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite3-moe	opencoderzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/opencodersmollm2zJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smollm2smollmzIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smollmzaya-expansezNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/aya-expanseayazFhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/ayafalcon3zJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon3falconz-2zJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falcon2zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/falconsmallthinkerzOhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/smallthinkeropenthinkerzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/openthinkerolmo2zolmo-2zHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/olmo2znomic-embed-textzShttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nomic-embed-textzmxbai-embed-largezThttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mxbai-embed-large
starcoder2zMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/starcoder2z	orca-mini	orca_minizLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/orca-minizIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/zephyrzsnowflake-arctic-embedzYhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/snowflake-arctic-embed	starcoderzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/starcoderz
all-minilmzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/all-minilmopenchatzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/openchat
openhermeszMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/openhermes
reflectionzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/reflectionzneural-chatzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/neural-chat	moondreamzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/moondreamxwinlmzIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/xwinlmsqlcoderzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/sqlcoderzstarling-lmzNhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/starling-lmz	solar-prozLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/solar-prosolarzHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/solarorca2zorca-2orca_2zHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/orca2hermes3zhermes-3hermes_3zJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/hermes3meditronzKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/meditron
nexusravenzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nexusraven	magicoderzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/magicoder	deepcoderzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepcodercogitozIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/cogitozbge-m3zIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/bge-m3notuxzHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/notuxopenorca	platypus2zVhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/open-orca-platypus2notuszHhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/notus	mathstralzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/mathstraldbrxzGhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/dbrx	nuextractzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/nuextractz	reader-lmzLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/reader-lmalfredzIhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/alfredz	bge-largezLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/bge-largezparaphrase-multilingualzZhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/paraphrase-multilingualmarcoo1zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/marco-o1qwqzFhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/qwqexaonezLhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/exaone3.5zr1-1776zJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/r1-1776
deepscalerzMhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/deepscalerzgranite-4.0zKhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/granite4zgpt-osszJhttps://modelscope.oss-cn-beijing.aliyuncs.com/llm_template/ollama/gpt-ossc                   *   \ rS rSr\S\S\4S j5       r\S\S\4S j5       r\S\S\	S	\S
\4S j5       r
\SS\S\S\S\\   S\\\4   4
S jj5       r\      SS\S\S\S\\\4   S\S\S\\\\\\4   \\\4   S4   4S jj5       r\S 5       rSrg)TemplateLoaderi  model_idreturnc                 *   / SQnUR                  S5      nUR                  S5      nUR                  SS5      n[         H  n[        R                  " UR
                  U 5      (       d  M+  UR                  (       d  M>  Uc]   [        U UR                  SS5      US9n[        R                  S	U S
35        [        R                  " XuS9n[        R                  " XuS9n[        R                  " UR                  4X4S.UD6s  $    g! [         a     N4f = f)zLoad a template by model-id

Args:
    model_id: The model-id used to load the proper template
    kwargs:
        revision: the revision of the model, default is `master`
Returns:
    The template instance
)z.+\.bin$z.+\.safetensors$z	.+\.gguf$	tokenizerconfigtrust_remote_codeNrevisionmaster)r   ignore_file_patternz3Use trust_remote_code=True. Will invoke codes from z9. Please make sure that you can trust the external codes.)r   )r   r   )getpoptemplate_infore	fullmatchr   r   r   loggerwarningr
   from_pretrainedr   	Exceptionr   load_by_template_name)r   kwargsr   r   r   r   _info	model_dirs           r#   load_by_model_idTemplateLoader.load_by_model_id  s    OJJ{+	H%"JJ':DA"E||E00(;;>>> (!(9 ()/J)I4G)II #NN-`aj`k lf ,f - )6(E(E ))PI%/%?%?	%oF *??V2;VNTV V# #  ) ! !s   AD
DDtemplate_namec                 n    [        U 4SUR                  SS5      0UD6nUR                  S5      Ul        U$ )a  Load a template by model-id

Args:
    template_name: The template name used to load the proper template
    kwargs:
        tokenizer: The tokenizer of the model
        default_system: The extra default system info
        max_length: The max_length for the sequence
        truncation_strategy: 'delete' or 'truncation_left' the sequence of the length exceeds the limit
Returns:
    The template instance
r   Nr   )r   r   r   r   )r   r   r   s      r#   r   $TemplateLoader.load_by_template_name  s:      aKQU9VaZ`a **X.r"   r   template_listplaceholderkeywordc                    SnU H  n[        U[        5      (       a  XER                  X#5      -  nM-  [        U[        [        45      (       d  MJ  [        US   [
        5      (       a  X@R                  R                  U5      -  nM  U HO  nUS:X  a  X@R                  R                  -  nM#  US:X  a  X@R                  R                  -  nMC  [        SU 35      e   M     U$ )Nr%   r   bos_token_ideos_token_idzUnknown token: )
isinstancer   r0   tuplelistintr   decode	bos_token	eos_token
ValueError)r   r   r   r   	final_strtattrs          r#   replace_and_concat!TemplateLoader.replace_and_concat+  s     	A!S!!YY{<<	At}--adC((!3!3!:!:1!==I !>1%););)E)EEI!^3%););)E)EEI",tf-E"FF !"  r"   Ntemplate_linesparamssplitlicensec           	         U(       a"  U(       a  [         R                  " U5      nXUS.$ SnUS-  nU(       a~  UR                  5        He  u  pV[        U[        5      (       a+  U H#  nUSU S[         R                  " U5       S3-  nM%     ME  USU S[         R                  " U5       S3-  nMg     US-  nU (       a  USU -   S-   -  nU$ )	N)r   r   r   r%   zFROM {gguf_file}

z
PARAMETER r)   
zTEMPLATE """z"""
)jsondumpsitemsr   r   )r   r   r   r   contentkeyvaluesvalues           r#   _format_returnTemplateLoader._format_return?  s     F+$WUU))%||~fd++!'ZuAdjj6G5H#KK "( C5$**V2D1ERHHG  . tOG7'ABGr"   	gguf_file	gguf_metadebugc                 
	   U (       d   U(       d  U(       d  [        SU  SU S35      e[        R                  S5        0 n0 nU(       a  UR                  SS5      n	U	(       a  XS'   U (       a  XS'   UR	                  5        Hl  u  p[
         H]  n[        R                  " UR                  U5      (       d  M+  UR                  (       d  M>  UR                  S	S
5      (       a  MW  X4X'     Mj     Mn     SnSn[        U5      S:X  a  UR                  5       u  nu  pO5[        U5      S:  a&  US   S   R                  (       d  US   u  pOUS   u  pU(       a  [        R                  UR                  S-   5      nU(       d  [        R                  U S35        [        R                  UR                  S-   5      nU(       a  [        R                   " U5      nO[        R                  U S35        [        R                  UR                  S-   5      nU(       d  [        R                  U S35        [        R#                  UUUU5      nU(       a  UU4$ U$ U(       a  [        R$                  " U40 UD6nO[        R&                  " U 40 UD6nU(       d  gSn[        R)                  UUR*                  SS5      nU(       a6  US[        R)                  UUR,                  =(       d    / SS5       SU S3-  nO2US[        R)                  UUR,                  =(       d    / SS5       S3-  nUS[        R)                  UUR.                  SS5       S3-  nUS-  nU[        R)                  UUR0                  SS5      -  n[        R)                  UUR0                  SS5      1n[3        USS5      (       a  [        R)                  US//SS5      nUR5                  U5        [3        USS5      (       a\  [3        UR6                  S5      (       aA  UR6                  R8                  n[        R)                  UU//SS5      nUR5                  U5        [;        5       nU H  nUR=                  U5        M     SU0n[        R#                  UUU5      $ ) a  Export to ollama ModelFile

Args:
    model_id: The model-id to use
    template_name: An extra template name to use
    gguf_file: An extra gguf_file path to use in the `FROM` field
    gguf_meta: An gguf extra meta info
    split: bool. Return str modelfile content, or dict of params and template
    debug: bool. Whether or not to return the matched TemplateInfo
Returns:
    The ModelFile content, or dictionary of params and template, returns `None` if no template found
zPlease make sure you model_id: z and template_name: z is supported.zExporting to ollama:zgeneral.nameNgguf_header_namer   ignore_oss_model_fileFr   z	.templatez has no template file.z.paramsz has no params file.z.licensez has no license file.r%   z{{ if .System }}z
{{SYSTEM}}z{{ .System }}z
{{ else }}z	{{ end }}z{{ if .Prompt }}z	{{QUERY}}z{{ .Prompt }}z{{ .Response }}r   r   r   stop)r   r   infor   r   r   r   r   r   r   r1   popitemr   r   _read_content_from_urlr   loadsr   r   r   r   prefixsystem_prefixpromptsuffixgetattraddr   r   r   r/   )r   r   r   r   r   r   r   r3   match_infosr   	name_typer5   r   _name_template_strr   r   
format_outr   r   _prefixall_eos_tokensr   r   stop_tokenss                             r#   	to_ollamaTemplateLoader.to_ollamaU  sW   * i1( <&&3_NDE E 	*+(}}^TB,<() (*${{}OI&<< 4 4d;;---fjjAXZ_6`6`15.	 '  - {q  + 3 3 5A~u!z*1-@@*:6u*+=>)@@&&46Lug%;<=#::5;Q;QT];]^FF+ug%9:;$;;&&35Gug%:;<'66|VUT[\J!5((%;;)!')H &66$"$H   33HhoorSUV&!44Xx?U?U?[Y[]ikz{| 	!"N &!44Xx?U?U?[Y[]ikz{|!"N 	"008??KYhij	 	++.;;Hhoo<>D 	D );;HhooWY[]^_8[$//&99(nEUDVXZ\^_Iy)x400WX__n5]5]';;*==h,HXZ\^`a	""9-f'Iy) (+&,,^VUKKr"   c                      [         R                  " U 5      nUR                  5         UR
                  nUR                  S5      $ ! [         R                  R                   a
  n S nAg S nAff = f)Nzutf-8)requestsr   raise_for_status
exceptions	HTTPErrorr   r   )urlresponseer   s       r#   r  %TemplateLoader._read_content_from_url  s^    	||C(H%%' ""~~g&& "",, 		s   &A A-(A-r   )N)NNNNFF)r   r   r   r   staticmethodr   r   r   r   r   r   r   r    r   r   r   r   r	   r   r  r  r!   r   r"   r#   r   r     s    V3  VX  V  VD S x  " X d (+69 & s D  PXY\P] inT	j  * "&'+#'.2 % %sLC sL!$sL sL "#s(^sL 	sL
 sL  %S$dL6H0I5QTVbQbKcei%ijsL sLj ' 'r"   r   ):r   r   dataclassesr   typingr   r   r   r   r   r	   r  
modelscoper
   r   r   r   r%   r   baser   r   r   r   r8   chat_suffixr<   rB   rD   rO   deepseek2_5deepseek_coder	deepseek2rQ   rX   rZ   rb   mistral_nemoyi_coderchatmlrr   rs   chatglm4ru   rv   r   r   r   yuanr   r   r   r   r   telechattelechat_v2r   r   r   r"   r#   <module>r1     sO    	  ! : :  O O  (	 $ $ $( Ju5$0
z
U8Y'(+S	z 
U:{+,B/U	z 
U:{+,BuX.?rB\	z* $$
U:{+,^-=,>bRPU+z8 $$
U:{+,^-=,>bRPU9zF 
U8Y'(>+;*<B{m2eT^N_M``bc\	GzR 
U8Y'(>+;*<BuV}oRPUV`blPmOnnpqa	Sz^ 
U8Y'(>+;*<BuX>OrRZ	_zj E/2326jlkzp E),-Rh/@Clnqzv $$
U8Y'()9(:"[MLSwzH 
U8Y'()9(:"U9=M<NbQ\P]]_`[	IzT 
U; #V	Uz` 
U; #V	azl 
U;,-R0V	mzx 
U7^BuW~.b1Y	yzD ##
U7^^-.bR@SEzV ))
U:r%-1A0B"EZWzd ,,
U:r%.!1E$K=C^ezr ,,
U:4 01E'N3C2F[sz@ ''
U:r%+r&zl>;K:LB{m[]^XAzN &&
U:4 9:>;K:LB{m[]^YOz\ E/2326Z\]zd 
U:r%+b1X	ezp 
U:r%+b1X	qz@ E'N+2eGn-=R@X 	AzL E'N+N,<+=R@RMzV E),-Rd}B?VWz` ""E),-Rg/?r+bQZ	azl ""E),-n.>-?r+bQT	mzx E,/03WyzB 
U=.12"[MDU	CzN ""E'956~7G6HKR	OzZ ""E&M?>+;*<B{m2NQ	[zj ##f:,bw(5;-r:Tkzx 
U; #V	yzD ##f:,bx34B7SEzR ##f:,bx34E+bISSz` 
U=!""%X	azl ##f:,bw(+Rmz~ 
U9bz!2 326\	zJ 
U9by!1 2"5\	KzV E*k:;2>UWWzb 
U$%&b)[	czn 
U)*+2.`	ozz 
U</03W	{zF	 
U8Y'()9(:"[MLS	G	zR	 ""
U67#$^%5$6bRHQS	z`	 
U;-.b1V	a	zl	 
U67#$^%5$6b9Q	m	zx	 
U5\N>+,B/P	y	zH
 
U6]O2eI./r2Y	I
zT
 
U9bz;!? @C]	U
z`
 
U9bz;!? @C]	a
zl
 
U9bw 03Z	m
zx
 
U9bw 03Z	y
zD **E.12>3C2DBGY	EzP 
U9bz!2 326]	Qz\ 
U=!""%X	]zj ##
U9k*+N,<+=R}BOTkz| 
U>?34BuY7G6HKa	}zH ##
U9~/03TIzZ ##
U; !1 2"5V[zl 
U>?34B7Y	mzx E-014XZyzD &&E$K=5>*:"[MLU	EzP $$
U4[M.*+BwK=;OQzb 
U:r"U	czn 
U7^BR	oz~ 
U?#$B'Z	zJ 
U:r"U	KzZ E+./r2V[zd $$E),-bhZr:O	ezt &&E*-.~/?.@CEuzz &&E*-.~/?.@CE{z@ &&E&'23N4D3ER}TVWQ	AzP &&
U: 01K=CEQz\ 
U#$%R([	]zh 
U'(),_	izt 
U=!""%X	uz@ 
U; #V	AzN 
U; #V	Oz^ ''E+./0@/ADV	_zn 
U?#$Bu\':&;2>e	ozz 
U;-.b1V	{zF 
U=!""%X	GzR 
U=,/03X	Sz^ 
U:r"U	_zn 
U; #V	oz~ 
U:r"U	zN 
U8_R S	Oz^ 
U=!""%X	_zj 
U:r"V	kzz &&E*-.~/?.@CE{zD &&
U:; <=n>N=OrR]Q^^`aEzR ''
U; !1 2"[MDVSzd ""E&M?>+;*<B?Aezn $$E(O,^-=,>bRPozz %%
U9~/0;-rBD{zF $$E(O,^-=,>bRPGzR $$E(O,^-=,>bACSz\ ##E'N+N,<+=R}BO]zh &&E*-.r$xj;=izr ))E*-.btR@Bsz| E'845R8RT}zH E+./r2VXIzT E"678;^`Uz\ E),-RfbAY[]zd E),-Re~R@WYezl E),-Rh/@5<.PRS^`mzt E),-Re~R@WYuz| E-01E$4E3FbI]_}zD E-01E$4E3FbI[]EzL E"567r:^`MzT E+./r%d2C1DBG[]Uz\ E+./r%d2C1DBGY[]zf E+./r2VXgzr E),-R0TVszz E(O,B/SU{zF E-014XZGzN E%L>,PROzZ E),-R0TV[zb E(O,BuT{m2>TVczj E(O,B/SUkzv E.12"5Y[wz@ E-014X 	"AzL 
U7H%&b)R	MzZ E"456b9]_[zb E"567r:^`czj E,/03WYkzr E+{;<B?VXszz E(O,B/SU{zB E":;<B?ceCzJ E+./r2VXKzR E,/03WYSzZ E*-.b1UW[zb E,/03WYczj E,/03WYkzr E-014XZszz E+./r2VX{zB E&M?"U4[M<SUCzJ E*-.b1UWKzR E-014XZSzZ E+./r2VX[zb E'N+2.RTczj E'8X>?rBRTkzr E)ZDERHTVszz E*-.b1UW{zB E,/03WYCzJ E+./r2VXKzR 
U; #V	XSz\ E(O,B/SU]zd E(O,B/SUezl E'N+2.RTmzt E&M?"U6]O2eK>P=QQST`buz| E'N+2.RT}zD E+./r2VXEzL E&M?"-QSMzT E+./r2VXUz\ E+./r2VX]zd E(O,B/SUezl E+./r2VXmzt E";<=R@dfuz| E'N+2eDk]"=UW}zD E%L>,PREzL E(O,B/VXMzT E),-R0TVUz\ E,/03WY]zd E-014UWezl E),-R0TVmzz_' _'r"   