Skip to content

Comments

Refactor provider to use OpenAI parser as a fallback and enhance test…#376

Open
jvanderaa wants to merge 4 commits intodevelopfrom
372-fix_openain_iCal
Open

Refactor provider to use OpenAI parser as a fallback and enhance test…#376
jvanderaa wants to merge 4 commits intodevelopfrom
372-fix_openain_iCal

Conversation

@jvanderaa
Copy link
Contributor

…s for processor behavior

Fix for the process of the OpenAI fallback to being a fallback. Includes a modification to not change the ical data.


# Use OpenAI parser as a last resort if all other processors failed.
if os.getenv("PARSER_OPENAI_API_KEY"):
self.add_subject_to_text(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still feels like modifying data in place may lead to bugs in the future. Might be better to change add_subject_to_text(data) so that it returns a modified copy instead of modifying the original in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be good here, this is the last point in the path. Everything should be sent in and should be kept outside of the parsers.

@jvanderaa
Copy link
Contributor Author

Fixes #372


def test_provider_data_not_mutated_when_native_succeeds():
"""Test that add_subject_to_text is not called when native processors succeed."""
os.environ["PARSER_OPENAI_API_KEY"] = "some_api_key"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change all of these test cases to use patch.dict(os.environ, ...) as was done for test_provider_falls_back_to_openai above?

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.

2 participants