
    NgP                        d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
 d dlmZ erd dlmZ  ej        e          Z	  G d d          ZdS )    )annotationsN)TYPE_CHECKINGAnyDictListOptional)Document)
Connectionc                  &    e Zd ZdZ	 ddd	ZddZdS )OracleSummaryztGet Summary
    Args:
        conn: Oracle Connection,
        params: Summary parameters,
        proxy: Proxy
    Nconnr
   paramsDict[str, Any]proxyOptional[str]c                0    || _         || _        || _        d S N)r   r   summary_params)selfr   r   r   s       b/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/utilities/oracleai.py__init__zOracleSummary.__init__"   s      	
$    docsr   return	List[str]c                   	 ddl }n"# t          $ r}t          d          |d}~ww xY w|g S g }	 d|j        _        | j                                        }| j        r|                    d| j                   t          |t                    rg }|
                    |j                  }|                    d|t          j        | j                  |           ||                    d	           n |                    t          |                                                     nt          |t"                    rg }|
                    |j                  }|                    d|j        t          j        | j                  |           ||                    d	           nk|                    t          |                                                     n5t          |t&                    rg }|D ]	}|
                    |j                  }t          |t                    r1|                    d
|t          j        | j                  |           nZt          |t"                    r6|                    d
|j        t          j        | j                  |           nt)          d          ||                    d	           |                    t          |                                                     nt)          d          |                                 |S # t(          $ rJ}t,                              d|            t1          j                     |                                  d}~ww xY w)a  Get the summary of the input docs.
        Args:
            docs: The documents to generate summary for.
                  Allowed input types: str, Document, List[str], List[Document]
        Returns:
            List of summary text, one for each input doc.
        r   NzIUnable to import oracledb, please install with `pip install -U oracledb`.Fz&begin utl_http.set_proxy(:proxy); end;)r   z
                    declare
                        input clob;
                    begin
                        input := :data;
                        :summ := dbms_vector_chain.utl_to_summary(input, json(:params));
                    end;)datar   summ aQ  
                            declare
                                input clob;
                            begin
                                input := :data;
                                :summ := dbms_vector_chain.utl_to_summary(input, 
                                            json(:params));
                            end;zInvalid input typezAn exception occurred :: )oracledbImportErrordefaults
fetch_lobsr   cursorr   execute
isinstancestrvarDB_TYPE_CLOBjsondumpsr   appendgetvaluer	   page_contentr   	Exceptioncloseloggerinfo	traceback	print_exc)	r   r   r    eresultsr$   summarydocexs	            r   get_summaryzOracleSummary.get_summary)   s   	OOOO 	 	 	-  	 <Ij	+0H(Y%%''Fz <DJ     $$$ X6 **X%:;; :d&9::      ?NN2&&&&NN3w'7'7'9'9#:#:;;;;D(++ B6 **X%:;; *:d&9::      ?NN2&&&&NN3w'7'7'9'9#:#:;;;;D$'' ,6 &@ &@C$jj)>??G!#s++ >$ "%#':d.A#B#B!( '     $C22 >$ "%!1#':d.A#B#B!( '     ((<===r****s7+;+;+=+='>'>????M&@R   4555LLNNNN 	 	 	KK8B88999!!!LLNNN		s)    
&!&K7L( (
M<2AM77M<r   )r   r
   r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r   r:    r   r   r   r      sX          PT% % % % %     r   r   )
__future__r   r*   loggingr3   typingr   r   r   r   r   langchain_core.documentsr	   r    r
   	getLoggerr;   r1   r   r?   r   r   <module>rE      s    # " " " " "       ; ; ; ; ; ; ; ; ; ; ; ; ; ; - - - - - - $######		8	$	$ N N N N N N N Nf r   