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

AttributeError: 'NoneType' object has no attribute 'results' #10852

Closed
5 tasks done
guxiyang opened this issue Nov 19, 2024 · 7 comments · Fixed by #10857
Closed
5 tasks done

AttributeError: 'NoneType' object has no attribute 'results' #10852

guxiyang opened this issue Nov 19, 2024 · 7 comments · Fixed by #10857
Assignees
Labels
🐞 bug Something isn't working

Comments

@guxiyang
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Hello, I have a question on my end. I don't know what's going on. Can you help me take a look,

  • Request: https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank failed, status: 429, message: Requests rate limit exceeded, please try again later.
    2024-11-19 08:42:18,689.689 ERROR [Thread-17368 (_generate_worker)] [node.py:72] - Node 1730856299318 failed to run
    Traceback (most recent call last):
    File "/app/api/core/model_runtime/model_providers/__base/rerank_model.py", line 42, in invoke
    return self._invoke(model, credentials, query, docs, score_threshold, top_n, user)
    File "/app/api/core/model_runtime/model_providers/tongyi/rerank/rerank.py", line 68, in _invoke
    for _, result in enumerate(response.output.results):
    AttributeError: 'NoneType' object has no attribute 'results'
    During handling of the above exception, another exception occurred:

✔️ Expected Behavior

No response

❌ Actual Behavior

@dosubot dosubot bot added the 🐞 bug Something isn't working label Nov 19, 2024
Copy link

dosubot bot commented Nov 19, 2024

The error you're encountering, "AttributeError: 'NoneType' object has no attribute 'results'," suggests that the response.output is None, which means the results attribute cannot be accessed. This issue is likely related to the rate limiting error you mentioned, where the request to the rerank service failed with a 429 status code, indicating that the request rate limit was exceeded.

To address this issue, consider the following steps:

  1. Rate Limiting: Since the error message indicates a rate limit issue, you should implement a retry mechanism with exponential backoff to handle 429 errors. This involves waiting for a certain period before retrying the request, and increasing the wait time with each subsequent failure.

  2. Error Handling: Ensure that your code gracefully handles cases where the response is None. You can add a check before accessing the results attribute to prevent the application from crashing:

    if response.output is None:
        raise ValueError("The response from the rerank service is None. Please check the service status and rate limits.")
  3. Logging and Monitoring: Use logging to capture detailed information about the requests and responses, especially when rate limits are hit. This can help in diagnosing and resolving such issues more effectively.

  4. Service Configuration: Review the configuration of the rerank service to ensure that it is set up to handle the expected load. If necessary, consider increasing the rate limit or optimizing the request patterns to reduce the load.

These steps should help mitigate the issue and improve the robustness of your application when dealing with rate limits and unexpected None responses.

To continue talking to Dosu, mention @dosu.

@guxiyang
Copy link
Author

guxiyang commented Nov 19, 2024 via email

Copy link

dosubot bot commented Nov 19, 2024

Yes, the 429 status code indicates that the request rate limit was exceeded, which means that Alibaba Cloud's interface is likely limiting the flow of requests. This is a common response when too many requests are made in a short period, and it suggests that the service is enforcing rate limits to manage traffic. Implementing a retry mechanism with exponential backoff can help manage these rate limits effectively.

To continue talking to Dosu, mention @dosu.

@guxiyang
Copy link
Author

guxiyang commented Nov 19, 2024 via email

Copy link

dosubot bot commented Nov 19, 2024

Hey @guxiyang! It looks like you're trying to respond to an email or message thread. I'm here to help with technical questions, bug fixes, and engineering knowledge, but handling email threads isn't quite my thing. If you think I should be able to help with this, feel free to reach out to the Dosu Team. They'll be happy to hear your feedback! 😊

To continue talking to Dosu, mention @dosu.

@JohnJyong JohnJyong self-assigned this Nov 19, 2024
@guxiyang
Copy link
Author

guxiyang commented Nov 19, 2024 via email

Copy link

dosubot bot commented Nov 19, 2024

The model being called is the "qwen-plus-chat" model, not the Lingji model [1].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants