
    dhR                         S SK JrJr  S SKJr  S SKJr  S SKJrJ	r	  S SK
Jr  S SKJrJrJr   " S S\5      r " S	 S
\5      rg)    )OptionalType)CallbackManagerForToolRun)BaseExampleSelector)FewShotPromptTemplatePromptTemplate)BaseTool)	BaseModel
ConfigDictFieldc                   .    \ rS rSr% \" SSS9r\\S'   Srg)_FewShotToolInput
   .z3The question for which we want example SQL queries.)descriptionquestion N)	__name__
__module____qualname____firstlineno__r   r   str__annotations____static_attributes__r       _/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/few_shot/tool.pyr   r   
   s    NHc r   r   c                       \ rS rSr% SrSr\\S'   Sr\\S'   \	r
\\   \S'   \" SS9r\\S	'   S
r\\S'   Sr\\S'   \" SS9r SS\S\\   S\4S jjrSrg)FewShotSQLTool   z=Tool to get example SQL queries related to an input question.few_shot_sqlnamer   args_schemaT)excludeexample_selectorinputexample_input_keyqueryexample_query_key)arbitrary_types_allowedNr   run_managerreturnc                     [         R                  " SU R                   SU R                   35      n[	        UU R
                  SU R                  /S9nUR                  " S0 U R                  U0D6$ )z:Execute the query, return the results or an error message.zUser input: z
SQL query:  )example_promptr#   suffixinput_variablesr   )r   from_templater%   r'   r   r#   format)selfr   r)   r-   prompts        r   _runFewShotSQLTool._run   sx     (554112-@V@V?WX
 ')!22!334	
 }}B 6 6ABBr   r   )N)r   r   r   r   __doc__r    r   r   r   r   r!   r   r
   r   r#   r   r%   r'   r   model_configr   r   r4   r   r   r   r   r   r      s    GD#VKV#4Ki4,1$,?)?$s$$s$ $L <@CC 78C 
	C Cr   r   N)typingr   r   langchain_core.callbacksr    langchain_core.example_selectorsr   langchain_core.promptsr   r   langchain_core.toolsr	   pydanticr
   r   r   r   r   r   r   r   <module>r>      s4    ! > @ H ) 1 1	 CX Cr   