
    hR                         d dl mZm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mZmZ  G d de      Z G d	 d
e      Zy)    )OptionalType)CallbackManagerForToolRun)BaseExampleSelector)FewShotPromptTemplatePromptTemplate)BaseTool)	BaseModel
ConfigDictFieldc                   ,    e Zd ZU  edd      Zeed<   y)_FewShotToolInput.z3The question for which we want example SQL queries.)descriptionquestionN)__name__
__module____qualname__r   r   str__annotations__     e/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/tools/few_shot/tool.pyr   r   
   s    NHc r   r   c                       e Zd ZU dZdZeed<   dZeed<   eZ	e
e   ed<    ed      Zeed<   d	Zeed
<   dZeed<    ed      Z	 ddedee   defdZy)FewShotSQLToolz=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                     t        j                  d| j                   d| j                         }t	        || j
                  d| j                  g      } |j                  di | j                  |iS )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   _runzFewShotSQLTool._run   sz     (554112-@V@V?WX
 ')!22!334	
 v}}B 6 6ABBr   )N)r   r   r   __doc__r   r   r   r   r   r   r   r
   r   r   r   r!   r#   r   model_configr   r   r0   r   r   r   r   r      s    GD#VKV#4Ki4,1$,?)?$s$$s$ $L <@CC 78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>r9      s4    ! > @ H ) 1 1	 CX Cr   