File size: 1,190 Bytes
93bc171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38be0ae
a624e23
38be0ae
a624e23
38be0ae
 
 
 
93bc171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
 /*************************************************************************
 * 
 * CONFIDENTIAL
 * __________________
 * 
 *  Copyright (2023-2024) AI Labs, IronOne Technologies, LLC
 *  All Rights Reserved
 *
 *  Author  : Theekshana Samaradiwakara
 *  Description :Python Backend API to chat with private data  
 *  CreatedDate : 14/11/2023
 *  LastModifiedDate : 18/03/2024
 *************************************************************************/
 """

import time
import logging
logger = logging.getLogger(__name__)

from reggpt.chains.llmChain import get_router_chain

from reggpt.configs.model import ROUTER_MODEL_TYPE


router_model_type=ROUTER_MODEL_TYPE

router_chain= get_router_chain(router_model_type)

def run_router_chain(query):
    try:
        logger.info(f"run_router_chain : Question: {query}")
        # Get the answer from the chain
        start = time.time()
        chain_type = router_chain.invoke(query)['text']
        end = time.time()

        # log the result
        logger.info(f"Answer (took {round(end - start, 2)} s.) chain_type: {chain_type}")

        return chain_type
    
    except Exception as e:
        logger.exception(e)
        raise e