Skip to content

Commit e2e03e8

Browse files
committed
better observability
1 parent bee6ba5 commit e2e03e8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main(vrn, d):
1818
print('Sending request to LLM.')
1919
l = llm_client.get_response(p)
2020
log_file = f"./fern/apis/{vrn}/changelog/{d}.md"
21-
if (l):
21+
if (l) and 'Error' not in l.partition('\n')[0]:
2222
with open(log_file, 'w', encoding="utf-8") as outfile:
2323
outfile.write(llm_client.get_lines_between_tags(l, 'changelog'))
2424
print(f"Wrote log to {log_file}.")

llm_client.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ def get_response(prompt):
3737
# Check if final response is empty
3838
if not response:
3939
raise ValueError("Empty content received from API")
40-
41-
return response
40+
else:
41+
print("Response received from LLM.")
42+
return response
4243

4344
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
4648
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
4952
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
5256

5357
def get_lines_between_tags(text, tag):
5458
pattern = r'<' + tag + r'>(.*?)<\/' + tag + r'>'

0 commit comments

Comments
 (0)