File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def main(vrn, d):
18
18
print ('Sending request to LLM.' )
19
19
l = llm_client .get_response (p )
20
20
log_file = f"./fern/apis/{ vrn } /changelog/{ d } .md"
21
- if (l ):
21
+ if (l ) and 'Error' not in l . partition ( ' \n ' )[ 0 ] :
22
22
with open (log_file , 'w' , encoding = "utf-8" ) as outfile :
23
23
outfile .write (llm_client .get_lines_between_tags (l , 'changelog' ))
24
24
print (f"Wrote log to { log_file } ." )
Original file line number Diff line number Diff line change @@ -37,18 +37,22 @@ def get_response(prompt):
37
37
# Check if final response is empty
38
38
if not response :
39
39
raise ValueError ("Empty content received from API" )
40
-
41
- return response
40
+ else :
41
+ print ("Response received from LLM." )
42
+ return response
42
43
43
44
except requests .RequestException as e :
44
- print (f"HTTP request failed. Error: { type (e )} { e } " )
45
- return None
45
+ msg = f"HTTP request failed. Error: { type (e )} { e } "
46
+ print (msg )
47
+ return msg
46
48
except ValueError as e :
47
- print (f"Invalid response received. Error: { e } " )
48
- return None
49
+ msg = f"Invalid response received. Error: { e } "
50
+ print (msg )
51
+ return msg
49
52
except Exception as e :
50
- print (f"Failed to generate response. Error: { type (e )} { e } " )
51
- return None
53
+ msg = f"Failed to generate response. Error: { type (e )} { e } "
54
+ print (msg )
55
+ return msg
52
56
53
57
def get_lines_between_tags (text , tag ):
54
58
pattern = r'<' + tag + r'>(.*?)<\/' + tag + r'>'
You can’t perform that action at this time.
0 commit comments