@@ -629,7 +629,7 @@ def check_vulnerability(input_query: str):
629629
630630
631631def generate_suggestions (remote_url , client_key :str , column_names : list , n_qs : int = 10 ):
632- results = []
632+ text_completion = []
633633
634634 column_info = ',' .join (column_names )
635635 _system_prompt = f"Act as a data analyst, based on below data schema help answer the question"
@@ -640,12 +640,13 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
640640 if "h2ogpt-" in recommender_model :
641641 try :
642642 client = H2OGPTE (address = remote_url , api_key = client_key )
643- text_completion = client .answer_question (
643+ response = client .answer_question (
644644 system_prompt = _system_prompt ,
645645 text_context_list = [],
646646 question = _user_prompt ,
647647 llm = recommender_model
648648 )
649+ text_completion = response .content .split ("\n " )[2 :]
649650 except Exception as e :
650651 remote_url = os .getenv ("H2OGPT_BASE_URL" , None )
651652 client_key = os .getenv ("H2OGPT_BASE_API_TOKEN" , None )
@@ -660,7 +661,7 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
660661 max_tokens = 512 ,
661662 temperature = 0.5 ,
662663 seed = 42 )
663- text_completion = completion .choices [0 ].message
664+ text_completion = completion .choices [0 ].message . content . split ( " \n " )[ 2 :]
664665 elif 'gpt-3.5' in recommender_model .lower () or 'gpt-4' in recommender_model .lower ():
665666 # Check if the API key is set, else inform user
666667 logger .info (f"Using OpenAI model: { recommender_model } " )
@@ -674,9 +675,8 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
674675 seed = 42 ,
675676 temperature = 0.7
676677 )
677- text_completion = completion .choices [0 ].message
678+ text_completion = completion .choices [0 ].message . content . split ( " \n " )
678679 else :
679680 raise Exception ("Model url or key is missing." )
680- _res = text_completion .content .split ("\n " )[2 :]
681- results = "\n " .join (_res )
681+ results = "\n " .join (text_completion )
682682 return results
0 commit comments