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

TypeError: Client.request() got an unexpected keyword argument 'stream' #10848

Closed
5 tasks done
RollingDonkeyX opened this issue Nov 19, 2024 · 1 comment · Fixed by #10859
Closed
5 tasks done

TypeError: Client.request() got an unexpected keyword argument 'stream' #10848

RollingDonkeyX opened this issue Nov 19, 2024 · 1 comment · Fixed by #10859
Assignees
Labels
🐞 bug Something isn't working

Comments

@RollingDonkeyX
Copy link

RollingDonkeyX commented Nov 19, 2024

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.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When I vectorize the knowledge base file
错误1
docker-worker-1 logs:

024-11-19 07:52:13.154 ERROR [Dummy-3] [indexing_runner.py:92] - consume document failed
Traceback (most recent call last):
  File "/app/api/core/indexing_runner.py", line 66, in run
    text_docs = self._extract(index_processor, dataset_document, processing_rule.to_dict())
  File "/app/api/core/indexing_runner.py", line 313, in _extract
    text_docs = index_processor.extract(extract_setting, process_rule_mode=process_rule["mode"])
  File "/app/api/core/rag/index_processor/processor/paragraph_index_processor.py", line 20, in extract
    text_docs = ExtractProcessor.extract(
  File "/app/api/core/rag/extractor/extract_processor.py", line 157, in extract
    return extractor.extract()
  File "/app/api/core/rag/extractor/word_extractor.py", line 65, in extract
    content = self.parse_docx(self.file_path, "storage")
  File "/app/api/core/rag/extractor/word_extractor.py", line 211, in parse_docx
    image_map = self._extract_images_from_docx(doc, image_folder)
  File "/app/api/core/rag/extractor/word_extractor.py", line 89, in _extract_images_from_docx
    response = ssrf_proxy.get(url, stream=True)
  File "/app/api/core/helper/ssrf_proxy.py", line 70, in get
    return make_request("GET", url, max_retries=max_retries, **kwargs)
  File "/app/api/core/helper/ssrf_proxy.py", line 49, in make_request
    response = client.request(method=method, url=url, **kwargs)
TypeError: Client.request() got an unexpected keyword argument 'stream'

docker-api-1 logs:

  File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
    resp = resource(*args, **kwargs)
  File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
  File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/app/api/controllers/console/wraps.py", line 142, in decorated
    return view(*args, **kwargs)
  File "/app/api/libs/login.py", line 92, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/app/api/controllers/console/wraps.py", line 26, in decorated
    return view(*args, **kwargs)
  File "/app/api/controllers/console/datasets/datasets.py", line 465, in post
    raise IndexingEstimateError(str(e))
controllers.console.datasets.error.IndexingEstimateError: 500 Internal Server Error: Client.request() got an unexpected keyword argument 'stream'

docker ps:
错误2

✔️ Expected Behavior

I vectorized the knowledge base file successfully.

❌ Actual Behavior

I failed to vectorize the knowledge base file.

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

dosubot bot commented Nov 19, 2024

To resolve the "TypeError: Client.request() got an unexpected keyword argument 'stream'" error, ensure that the requests.request method is being called with the correct arguments. The error suggests that the stream argument is not expected in the context where it is being used.

In the Dify codebase, the make_request function in the ssrf_proxy.py file is responsible for handling HTTP requests. It uses the httpx.Client().request() method, which does not support the stream parameter. To fix this issue, you should remove the stream argument from the ssrf_proxy.get call or ensure that the httpx library version you are using supports this parameter.

Here's a brief guide to address the issue:

  1. Check the httpx Library Version: Ensure that you are using a compatible version of the httpx library. You can update it using:

    pip install --upgrade httpx
  2. Modify the Code: If updating the library does not resolve the issue, you may need to modify the code to remove the stream parameter from the ssrf_proxy.get call in the word_extractor.py file.

By following these steps, you should be able to resolve the error and successfully vectorize the knowledge base file.

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