Skip to content

feat: add HTTPX_TIMEOUT config#292

Merged
Stream29 merged 1 commit intomainfrom
feat/configurable-httpx-timeout
Mar 12, 2026
Merged

feat: add HTTPX_TIMEOUT config#292
Stream29 merged 1 commit intomainfrom
feat/configurable-httpx-timeout

Conversation

@Stream29
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Dify plugin's robustness by introducing a configurable timeout for HTTPX requests. This allows users to specify how long the system should wait for an HTTP response before timing out, preventing indefinite waits and improving application stability, especially when interacting with external services and fetching file content.

Highlights

  • New Configuration: Introduced a new configuration setting, HTTPX_TIMEOUT, in DifyPluginEnv to control the timeout for HTTPX requests, defaulting to 5 seconds.
  • File Blob Retrieval Timeout: Applied the newly added HTTPX_TIMEOUT to httpx.get calls made during file blob retrieval, ensuring that file downloads do not hang indefinitely.
  • Plugin Request Execution Timeout: Propagated the HTTPX_TIMEOUT configuration to the _execute_request method within the plugin, allowing for consistent timeout behavior across various plugin operations.
  • Rerank Model API Timeout: Integrated the HTTPX_TIMEOUT into API calls made by the Jina rerank model, specifically for httpx.post requests, to prevent long waits for external reranking services.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • python/dify_plugin/config/config.py
    • Added HTTPX_TIMEOUT field to DifyPluginEnv with a default value of 5 seconds.
  • python/dify_plugin/file/file.py
    • Imported DifyPluginEnv and instantiated it to access configuration.
    • Applied the configured HTTPX_TIMEOUT to httpx.get calls for file blob retrieval.
  • python/dify_plugin/plugin.py
    • Passed the HTTPX_TIMEOUT from the plugin's configuration to the _execute_request method.
  • python/examples/jina/models/rerank/rerank.py
    • Imported DifyPluginEnv and instantiated it to access configuration.
    • Applied the configured HTTPX_TIMEOUT to httpx.post calls made to the rerank model API.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration HTTPX_TIMEOUT to control the timeout for httpx requests, applying it to file downloads and the Jina rerank model. While the feature is useful, I've identified a critical issue where the Session class constructor is called with an unknown argument, which will lead to a runtime error. Additionally, the method used to access the new configuration in several files creates module-level state, which could be improved for better maintainability and testability. I've provided specific comments with suggestions for these points.

@Stream29 Stream29 requested a review from RockChinQ March 12, 2026 08:57
@Stream29 Stream29 merged commit 3fd0f8a into main Mar 12, 2026
3 checks passed
@Stream29 Stream29 deleted the feat/configurable-httpx-timeout branch March 12, 2026 08:59
@korostast
Copy link

korostast commented Mar 12, 2026

Hello, @Stream29, @RockChinQ. This PR contains a bug related to passing a not defined httpx_timeout argument to the Session object. Please provide a hot-fix of this bug.

@Raincwail
Copy link

Hi, @Stream29 ! As gemini and @korostast correctly stated, there is a critical issue that leads to a runtime error. I propose reverting this PR and hot-fixing the issue.

@Stream29
Copy link
Collaborator Author

Stream29 commented Mar 12, 2026

@korostast @Raincwail I admit I made I mistake on this code. I'm going to fix it.

@Stream29
Copy link
Collaborator Author

#294 would fix this.

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.

5 participants