Skip to content

fix: openAI fallback crash in title generation#474

Open
amahuli03 wants to merge 3 commits intoCodeForPhilly:developfrom
amahuli03:473/openai-title-generation-attribute-error
Open

fix: openAI fallback crash in title generation#474
amahuli03 wants to merge 3 commits intoCodeForPhilly:developfrom
amahuli03:473/openai-title-generation-attribute-error

Conversation

@amahuli03
Copy link
Collaborator

Description

summarize_pdf() in title.py crashed with AttributeError: 'str' object has no attribute 'choices' when the OpenAI fallback was triggered during file upload.

Changes

title.py: Updated summarize_pdf() to treat the return value of openAIServices.openAI() as a string, since it already extracts message.content internally

test_title.py: Updated mock return values from mock response objects with .choices[0].message.content to plain strings, matching the actual return type of openAIServices.openAI()

Related Issue

Fixes #473

Manual Tests

Uploaded a PDF that uses the OpenAI fallback, confirmed that file was uploaded successfully, title was processed with no errors, and the generated title was correct.

Automated Tests

Updated the unit tests related to OpenAI services in test_title.py to reflect the actual data types

Reviewers

@sahilds1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI title generation fallback crashes with: 'str' object has no attribute 'choices'

1 participant