PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
11.93k stars 2.91k forks source link

[Question]: SimpleServer的域名问题 #7155

Closed glnshzh closed 11 months ago

glnshzh commented 11 months ago

请提出你的问题

尝试使用给例子来进行测试,但是在Windows下并没有解决,这个不是很懂,如何调整域名来正确访问? 环境:win11

import requests import json

url =" http://0.0.0.0:8189/taskflow/dialogue" headers = {"Content-Type": "application/json"} texts = ["测试一下", "你在干嘛"] data = { "data": { "text": texts, } } r = requests.post(url=url, headers=headers, data=json.dumps(data)) datas = json.loads(r.text) print(datas)

C:\QQROBOT\bott.venv\Scripts\python.exe C:\QQROBOT\bott\plot_chat.py Traceback (most recent call last): File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connection.py", line 200, in _new_conn sock = connection.create_connection( File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection raise err File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection sock.connect(sa) OSError: [WinError 10049] 在其上下文中,该请求的地址无效。

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connectionpool.py", line 496, in _make_request conn.request( File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connection.py", line 388, in request self.endheaders() File "C:\Users\47818\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1277, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\47818\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1037, in _send_output self.send(msg) File "C:\Users\47818\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 975, in send self.connect() File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connection.py", line 236, in connect self.sock = self._new_conn() File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connection.py", line 215, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000022822CC5BD0>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\QQROBOT\bott.venv\lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen retries = retries.increment( File "C:\QQROBOT\bott.venv\lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=8189): Max retries exceeded with url: /taskflow/dialogue (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000022822CC5BD0>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\QQROBOT\bott\plot_chat.py", line 12, in r = requests.post(url=url, headers=headers, data=json.dumps(data)) File "C:\QQROBOT\bott.venv\lib\site-packages\requests\api.py", line 115, in post return request("post", url, data=data, json=json, kwargs) File "C:\QQROBOT\bott.venv\lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "C:\QQROBOT\bott.venv\lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "C:\QQROBOT\bott.venv\lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, kwargs) File "C:\QQROBOT\bott.venv\lib\site-packages\requests\adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=8189): Max retries exceeded with url: /taskflow/dialogue (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000022822CC5BD0>: Failed to establish a new connection: [WinError 10049] 在其上下文中,该请求的地址无效。'))

Process finished with exit code 1

glnshzh commented 11 months ago

改成127.0.0.1能解决