
    dh.                     n    S SK JrJr  S SKJrJrJr  S SKJrJ	r	  S SK
Jr  S SKJr  SrSr " S S	\5      rg
)    )AnyDict)convert_to_secret_strget_from_dict_or_envpre_init)Field	SecretStr)
BaseOpenAI)is_openai_v1zhttps://text.octoai.run/v1/zcodellama-7b-instructc                      ^  \ rS rSr% Sr \" \S9r\\	S'   \" \
" S5      S9r\
\	S'   \" \S9r\\	S'   \S\4S	 j5       r\S\\\4   4U 4S
 jj5       r\S\4S j5       r\S\S\4S j5       rSrU =r$ )OctoAIEndpoint   aY  OctoAI LLM Endpoints - OpenAI compatible.

OctoAIEndpoint is a class to interact with OctoAI Compute Service large
language model endpoints.

To use, you should have the environment variable ``OCTOAI_API_TOKEN`` set
with your API token, or pass it as a named parameter to the constructor.

Example:
    .. code-block:: python

        from langchain_community.llms.octoai_endpoint  import OctoAIEndpoint

        llm = OctoAIEndpoint(
            model="llama-2-13b-chat-fp16",
            max_tokens=200,
            presence_penalty=0,
            temperature=0.1,
            top_p=0.9,
        )

defaultoctoai_api_base octoai_api_token
model_namereturnc                     g)NF )clss    `/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/octoai_endpoint.pyis_lc_serializable!OctoAIEndpoint.is_lc_serializable*   s        c                    > SU R                   0U R                  En[        5       (       d6  UR                  U R                  R                  5       U R                  S.5        0 UE[        TU ]   E$ )z,Get the parameters used to invoke the model.model)api_keyapi_base)	r   _default_paramsr   updater   get_secret_valuer   super_invocation_params)selfparams	__class__s     r   r%   !OctoAIEndpoint._invocation_params.   so    
 T__"
"""
 ~~MM#44EEG $ 4 4 8&7EG677r   c                     g)zReturn type of llm.octoai_endpointr   )r&   s    r   	_llm_typeOctoAIEndpoint._llm_type@   s     !r   valuesc                 j   [        USS[        S9US'   [        [        USS5      5      US'   [        USS[        S9US'    SS	Kn[        5       (       a  US   R                  5       US   S
.nUR                  S5      (       d  UR                  " S0 UD6R                  US'   UR                  S5      (       d  UR                  " S0 UD6R                  US'   O.US   US'   US   R                  5       US'   UR                  US'    SUS   ;   a  [        S5      eU$ ! [         a    [        S5      ef = f)z?Validate that api key and python package exists in environment.r   OCTOAI_API_BASEr   r   OCTOAI_API_TOKENr   
MODEL_NAMEr   N)r   base_urlclientasync_clientopenai_api_baseopenai_api_keyzTCould not import openai python package. Please install it with `pip install openai`.endpoint_urlmodel_kwargsz<`endpoint_url` was deprecated, please use `octoai_api_base`.r   )r   DEFAULT_BASE_URLr   DEFAULT_MODELopenair   r#   getOpenAIcompletionsAsyncOpenAI
CompletionImportError
ValueError)r   r.   r<   client_paramss       r   validate_environment#OctoAIEndpoint.validate_environmentE   sv    %9$	%
 ! &; );=OP&
!"  4!	 
|	~~%&89JJL &'8 9! zz(++'-}}'E}'E'Q'QF8$zz.11-3-?-? .'.!k >* -33D,E()+12D+E+V+V+X'(#)#4#4x  VN33N    	? 	s   BD -D D2r   )__name__
__module____qualname____firstlineno____doc__r   r:   r   str__annotations__r	   r   r;   r   classmethodboolr   propertyr   r   r%   r,   r   rE   __static_attributes____classcell__)r(   s   @r   r   r      s    . 3 )9:OS:"'	"">i>M2J24   8DcN 8 8" !3 ! ! /$ /4 / /r   r   N)typingr   r   langchain_core.utilsr   r   r   pydanticr   r	   langchain_community.llms.openair
    langchain_community.utils.openair   r:   r;   r   r   r   r   <module>rX      s0     V V % 6 90 'hZ hr   