File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 4949
5050
5151def  _post_process (content : str ) ->  tuple :
52-     lines  =  content .split ('\n ' )
53-     question  =  lines [0 ].split ('[question]: ' )[1 ]
54-     answer  =  lines [1 ].split ('[answer]: ' )[1 ]
55-     return  question , answer 
52+     if  "[question]:"  in  content  and  "[answer]:"  in  content :
53+         question  =  content .split ('[question]: ' )[1 ].split ('[answer]: ' )[0 ]
54+         answer  =  content .split ('[answer]: ' )[1 ]
55+         return  question , answer 
56+     return  None , None 
5657
5758
5859@dataclass  
@@ -81,10 +82,11 @@ async def process_chunk(content: str):
8182        for  result  in  tqdm_async (asyncio .as_completed (tasks ), total = len (tasks ), desc = "Generating using Genie" ):
8283            try :
8384                question , answer  =  _post_process (await  result )
84-                 final_results [compute_content_hash (question )] =  {
85-                     'question' : question ,
86-                     'answer' : answer 
87-                 }
85+                 if  question  and  answer :
86+                     final_results [compute_content_hash (question )] =  {
87+                         'question' : question ,
88+                         'answer' : answer 
89+                     }
8890            except  Exception  as  e : # pylint: disable=broad-except 
8991                print (f"Error: { e }  " )
9092        return  final_results 
Original file line number Diff line number Diff line change @@ -51,4 +51,4 @@ def plot_loss_distribution(stats: list[dict]):
5151                'tickvals' : list (range (len (sorted_bins )))[::2 ]
5252            }
5353        )
54-     return  fig 
54+     return  fig 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments