
    :j                     |    d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ  G d	 d
e      Z ede       y)z!
Doubao provider implementation.
    )List)ErrorReason)CheckResult	Condition)trim   )OpenAILikeProvider)register_providerc                   h     e Zd ZdZdee   f fdZdedede	f fdZ
dded	ed
edede	f
 fdZ xZS )DoubaoProviderzDoubao provider implementation.
conditionsc           
      Z    | j                  |ddddddd       t        |   d	d|i| y )
Ndoubaoz!https://ark.cn-beijing.volces.comz/api/v3/chat/completionsz/api/v3/modelszdoubao-pro-32kzep-[0-9]{14}-[a-z0-9]{5})namebase_urlcompletion_path
model_pathdefault_modelmodel_patternr    )defaultssuper__init__)selfr   kwargs	__class__s      =/root/.openclaw/workspace/harvester/search/provider/doubao.pyr   zDoubaoProvider.__init__   s@     ?#=.!1!<
	
 	9J9&9    codemessagereturnc                 t    |dk(  r#t        j                  t        j                        S t        |   ||      S )zJudge Doubao API response.i  )r   failr   INVALID_KEYr   _judge)r   r   r    r   s      r   r%   zDoubaoProvider._judge$   s2    3;##K$;$;<<w~dG,,r   tokenaddressendpointmodelc                 \    t        |      }|s| j                  }t        |   ||||      S )zCheck Doubao token validity.)r&   r'   r(   r)   )r   _default_modelr   check)r   r&   r'   r(   r)   r   s        r   r,   zDoubaoProvider.check+   s2    U''Ew}5'HTY}ZZr   ) r-   r-   )__name__
__module____qualname____doc__r   r   r   intstrr   r%   r,   __classcell__)r   s   @r   r   r      se    ):4	? : -3 - - -[3 [ [S [c [[f [ [r   r   r   N)r1   typingr   
core.enumsr   core.modelsr   r   tools.utilsr   openai_liker	   registryr
   r   r   r   r   <module>r;      s:     " .  + ' ['  [F (N +r   