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

Error accessing the openai interface: TimeoutError #11

Open
jacheycheng opened this issue May 6, 2023 · 2 comments
Open

Error accessing the openai interface: TimeoutError #11

jacheycheng opened this issue May 6, 2023 · 2 comments

Comments

@jacheycheng
Copy link

Hi,

I am trying to use iPhone GPT with Jupyterab, which is launched locally.

I got this message when running the example chat: TimeoutError: [WinError 10060]

But I have no problem directly executing the same request using a Python program.

How to handle this situation?

@santiagobasulto
Copy link
Owner

Hello, what lines are you running specifically? Can you send a screenshot of your notebook?

@jacheycheng
Copy link
Author

Execute this command: %chat_models

Report the following error:
TimeoutError Traceback (most recent call last)
Cell In[4], line 1
----> 1 get_ipython().run_line_magic('chat_models', '')

File F:\miniconda\envs\jupyterlab-extension\lib\site-packages\IPython\core\interactiveshell.py:2417, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2415 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2416 with self.builtin_trap:
-> 2417 result = fn(*args, **kwargs)
2419 # The code below prevents the output from being displayed
2420 # when using magics with decodator @output_can_be_silenced
2421 # when the last Python token in the expression is a ';'.
2422 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File F:\miniconda\envs\jupyterlab-extension\lib\site-packages\ipython_gpt_init_.py:39, in IPythonGPT.chat_models(self, line)
36 @line_magic
37 def chat_models(self, line):
38 cmd = ChatModelsBrowserCommand(self._context)
---> 39 result = cmd.execute(line)
40 self.display.display(result)

File F:\miniconda\envs\jupyterlab-extension\lib\site-packages\ipython_gpt\subcommands.py:52, in BaseIPythonGPTCommand.execute(self, line, cell)
50 assert bool(openai_api_key), "OPENAI_API_KEY missing"
51 client = OpenAIClient(openai_api_key)
---> 52 results = self._execute(client, args, line, cell)
53 return results

File F:\miniconda\envs\jupyterlab-extension\lib\site-packages\ipython_gpt\subcommands.py:142, in ChatModelsBrowserCommand._execute(self, client, args, line, cell)
141 def _execute(self, client, args, line, cell):
--> 142 resp = client.request("GET", "/models")
143 models = [
144 m["id"]
145 for m in resp["data"]
146 if args.all_models or m["id"].startswith("gpt")
147 ]
148 formatted_models = "\n".join([f"\t- {model}" for model in models])

File F:\miniconda\envs\jupyterlab-extension\lib\site-packages\ipython_gpt\api_client.py:70, in OpenAIClient.request(self, method, path, headers, query_params, json_body)
61 path += "?" + urllib.parse.urlencode(query_params)
63 try:
64 # print(connection.host)
65 # print(connection.port)
(...)
68 # print(str(body))
69 # print(str(headers))
---> 70 connection.request(method, path, body, headers)
71 resp = connection.getresponse()
72 resp_body = resp.read()

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1279 def request(self, method, url, body=None, headers={}, *,
1280 encode_chunked=False):
1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:1328, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1324 if isinstance(body, str):
1325 # RFC 2616 Section 3.7.1 says that text default has a
1326 # default charset of iso-8859-1.
1327 body = _encode(body, 'body')
-> 1328 self.endheaders(body, encode_chunked=encode_chunked)

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:1277, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1275 else:
1276 raise CannotSendHeader()
-> 1277 self._send_output(message_body, encode_chunked=encode_chunked)

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:1037, in HTTPConnection._send_output(self, message_body, encode_chunked)
1035 msg = b"\r\n".join(self._buffer)
1036 del self._buffer[:]
-> 1037 self.send(msg)
1039 if message_body is not None:
1040
1041 # create a consistent interface to message_body
1042 if hasattr(message_body, 'read'):
1043 # Let file-like take precedence over byte-like. This
1044 # is needed to allow the current position of mmap'ed
1045 # files to be taken into account.

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:975, in HTTPConnection.send(self, data)
973 if self.sock is None:
974 if self.auto_open:
--> 975 self.connect()
976 else:
977 raise NotConnected()

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:1447, in HTTPSConnection.connect(self)
1444 def connect(self):
1445 "Connect to a host on a given (SSL) port."
-> 1447 super().connect()
1449 if self._tunnel_host:
1450 server_hostname = self._tunnel_host

File F:\miniconda\envs\jupyterlab-extension\lib\http\client.py:941, in HTTPConnection.connect(self)
939 """Connect to the host and port specified in init."""
940 sys.audit("http.client.connect", self, self.host, self.port)
--> 941 self.sock = self._create_connection(
942 (self.host,self.port), self.timeout, self.source_address)
943 # Might fail in OSs that don't implement TCP_NODELAY
944 try:

File F:\miniconda\envs\jupyterlab-extension\lib\socket.py:847, in create_connection(address, timeout, source_address)
845 if err is not None:
846 try:
--> 847 raise err
848 finally:
849 # Break explicitly a reference cycle
850 err = None

File F:\miniconda\envs\jupyterlab-extension\lib\socket.py:833, in create_connection(address, timeout, source_address)
831 if source_address:
832 sock.bind(source_address)
--> 833 sock.connect(sa)
834 # Break explicitly a reference cycle
835 err = None

TimeoutError: [WinError 10060] The connection attempt failed because the connecting party did not respond correctly after a period of time or the connected host did not respond.

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

No branches or pull requests

2 participants