Skip to content

Commit

Permalink
fix: handling OpenAI returning None objects (#2280)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaninejuliettes authored Feb 7, 2025
1 parent 0a5d1fb commit f3900ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bertopic/representation/_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def extract_topics(

# Check whether content was actually generated
# Addresses #1570 for potential issues with OpenAI's content filter
if hasattr(response.choices[0].message, "content"):
# Addresses #2176 for potential issues when openAI returns a None type object
if response and hasattr(response.choices[0].message, "content"):
label = response.choices[0].message.content.strip().replace("topic: ", "")
else:
label = "No label returned"
Expand Down

0 comments on commit f3900ad

Please sign in to comment.