mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(cookbook): also guard message.content=None for tool-call responses
This commit is contained in:
parent
f3ff56ca2b
commit
c38cf40e7c
1 changed files with 2 additions and 1 deletions
|
|
@ -99,9 +99,10 @@ def make_openai_completion(question):
|
|||
# Log the request details
|
||||
if not response.choices or response.choices[0].message is None:
|
||||
raise ValueError("LLM returned empty or filtered response")
|
||||
content_preview = (response.choices[0].message.content or "")[:10]
|
||||
with open("request_log.txt", "a") as log_file:
|
||||
log_file.write(
|
||||
f"Question: {question[:100]}\nResponse ID:{response.id} Content:{response.choices[0].message.content[:10]}\nTime: {end_time - start_time:.2f} seconds\n\n"
|
||||
f"Question: {question[:100]}\nResponse ID:{response.id} Content:{content_preview}\nTime: {end_time - start_time:.2f} seconds\n\n"
|
||||
)
|
||||
|
||||
return response
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue