Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reading .har file in OpenaiChat #2396

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Improve reading .har file in OpenaiChat #2396

merged 1 commit into from
Nov 21, 2024

Conversation

hlohaus
Copy link
Collaborator

@hlohaus hlohaus commented Nov 21, 2024

No description provided.

@hlohaus hlohaus merged commit 4be8e69 into xtekky:main Nov 21, 2024
1 check passed
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Pull Request Review

Author: H Lohaus

Title: Improve reading .har file in OpenaiChat

Thank you for contributing to the project! Your changes to improve the reading of .har files in the OpenaiChat provider are appreciated.

Summary of Changes

  • Updated the way user-agent is accessed to use get() for safer retrieval.
  • Improved header handling by ensuring consistent casing for header keys.
  • Enhanced error handling when reading tokens from headers, making the code more robust.

Code Review

  • The use of cls._headers.get("user-agent") is a good improvement as it prevents potential KeyError exceptions.
  • The consistent casing of headers (e.g., changing "Openai-Sentinel-Proof-Token" to "openai-sentinel-proof-token") aligns with common practices and improves readability.
  • The restructuring of the error handling logic makes the code cleaner and easier to maintain.

Suggestions

  • Consider adding comments to explain the purpose of certain blocks of code, especially where tokens are being parsed. This will help future maintainers understand the logic more quickly.
  • It might be beneficial to include unit tests to cover the new functionality introduced in this pull request.

Overall, great work on this improvement! Looking forward to seeing more contributions from you in the future.

g4f/Provider/needs_auth/OpenaiChat.py Show resolved Hide resolved
g4f/Provider/needs_auth/OpenaiChat.py Show resolved Hide resolved
g4f/Provider/needs_auth/OpenaiChat.py Show resolved Hide resolved
g4f/Provider/needs_auth/OpenaiChat.py Show resolved Hide resolved
g4f/Provider/needs_auth/OpenaiChat.py Show resolved Hide resolved
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.

1 participant