
    љi                         S SK r S SKJrJr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  \ R                  " \5      r " S S\5      r " S	 S
\5      r " S S\5      r " S S5      rg)    N)DictAnyOptionalList)	APIRouterHTTPExceptionstatus)	BaseModelField   )
LLMServicec                      \ rS rSr% Sr\" SSS9r\\   \	S'   \" SSS9r
\\   \	S'   \" SS	S9r\\   \	S
'   \" SSS9r\\\      \	S'   \" SSS9r\\\      \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'   \" SSS9r\\\      \	S'   \" SSS9r\\   \	S'   \" SSS9r\\   \	S'    " S S5      rSrg)	LlmConfig
   z
LlmConfig is a data model that holds configuration settings for Large Language Model (LLM) components.

All fields are optional and default to None if not provided.
NzHThe system prompt that sets initial instructions or context for the LLM.)defaultdescriptionsystem_promptzKThe name of the model to use, e.g., 'gpt-4o-mini', 'claude-haiku-4-5', etc.modelzZThe temperature for text generation. Higher values increase randomness (range 0.0 to 1.0).temperaturezBA list of delimiter characters used by the LLM to split responses.split_charszDA list of delimiter characters used for splitting optional elements.option_split_charszRA threshold value to control splitting of optional parts based on character count.option_split_thresholdzYFlag indicating whether to split text on control tags like [face:xxx] or [animation:xxx].split_on_control_tagsz4A tag used for voice text extraction, e.g., 'voice'.voice_text_tagzBA list of initial messages to prepend to the conversation context.initial_messagesz:Flag indicating whether to enable dynamic tool invocation.use_dynamic_toolszPFlag indicating whether to enable debug mode. If True, detailed logs are output.debugc                       \ rS rSrSrSrg)LlmConfig.Config=   allow N)__name__
__module____qualname____firstlineno__extra__static_attributes__r"       S/home/james-whalen/.local/lib/python3.13/site-packages/aiavatar/admin/config/llm.pyConfigr   =   s    r)   r+   r"   )r#   r$   r%   r&   __doc__r   r   r   str__annotations__r   r   floatr   r   r   r   intr   boolr   r   dictr   r   r+   r(   r"   r)   r*   r   r   
   sd   
 $)^$M8C=  !aE8C=  $)p$K%  (-X(K$s)$  /4Z/c+  -2h-HSM  -2o-8D>  %*J%NHSM  .3X.htDz*  ).P)x~  "fE8D> 
 r)   r   c                   B    \ rS rSr% \" SS9r\\S'   \" SS9r\	\S'   Sr
g)	LlmConfigResponseA   zType of LLM componentr   typeConfiguration of LLM componentconfigr"   N)r#   r$   r%   r&   r   r7   r-   r.   r9   r   r(   r"   r)   r*   r4   r4   A   s,    +D#  4FI r)   r4   c                   ,    \ rS rSr% \" SS9r\\S'   Srg)UpdateLlmConfigRequestJ   r8   r6   r9   r"   N)	r#   r$   r%   r&   r   r9   r   r.   r(   r"   r)   r*   r;   r;   J   s    4FI r)   r;   c                   (    \ rS rSrS\4S jrS rSrg)LlmConfigAPIP   llmc                     Xl         g )Nr@   )selfr@   s     r*   __init__LlmConfigAPI.__init__Q   s	     r)   c                    ^  [        5       nUR                  SS/SSSSS0SS0S	.S
9S[        4U 4S jj5       nUR                  SS/SSSSS0SS0SS0S.S
9S[        S[
        [        [        4   4U 4S jj5       nU$ )Nz/config/llmr+   zGet LLM configurationzARetrieve the current configuration settings for the LLM componentzKCurrent LLM configuration including model, temperature, and prompt settingsr   z(Successfully retrieved LLM configurationzInternal server error)     )tagssummaryr   response_description	responsesreturnc            	        >#     TR                   n [        U R                  R                  [	        S0 U R                  5       D6S9$ ! [         a5  n[        R                  SU 35        [        [        R                  SS9eS nAff = f7f)N)r7   r9   z$Error retrieving LLM configuration: z8Internal server error while retrieving LLM configurationstatus_codedetailr"   )r@   r4   	__class__r#   r   
get_config	Exceptionloggererrorr   r	   HTTP_500_INTERNAL_SERVER_ERROR)r@   exrC   s     r*   get_config_llm/LlmConfigAPI.get_router.<locals>.get_config_llmZ   s~     hh(//$8s~~'78 
  CB4HI# & E EU s)   BA A B
B0B  BBzUpdate LLM configurationzZUpdate configuration settings for the LLM component. Only non-null values will be updated.z;Dictionary of successfully updated configuration parametersz&Successfully updated LLM configurationz Invalid configuration parameters)rG   i  rH   requestc                    >#     TR                   nUR                  U R                  R                  5       5      $ ! [         a5  n[
        R                  SU 35        [        [        R                  SS9eS nAff = f7f)Nz"Error updating LLM configuration: z6Internal server error while updating LLM configurationrO   )
r@   
set_configr9   
model_dumprT   rU   rV   r   r	   rW   )r[   r@   rX   rC   s      r*   post_config_llm0LlmConfigAPI.get_router.<locals>.post_config_llmu   sl     	hh~~gnn&?&?&ABB A"FG# & E ES s%   A<4: A<
A90A44A99A<)r   getr4   postr;   r   r-   r   )rC   routerrY   r_   s   `   r*   
get_routerLlmConfigAPI.get_routerW   s    	+[!n#%OP#%<= 
 


	&7 	


	  
.t!^#%MN#%GH#%<= 
 


	+A 
	d3PS8n 
	


	 r)   rB   N)r#   r$   r%   r&   r   rD   rd   r(   r"   r)   r*   r>   r>   P   s    6r)   r>   )loggingtypingr   r   r   r   fastapir   r   r	   pydanticr
   r   sts.llmr   	getLoggerr#   rU   r   r4   r;   r>   r"   r)   r*   <module>rl      sY     , , 4 4 % !			8	$4	 4n	 Y = =r)   