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

Version of urllib3 and HTTPSConnection error #10

Closed
WayneMao opened this issue Aug 22, 2023 · 7 comments
Closed

Version of urllib3 and HTTPSConnection error #10

WayneMao opened this issue Aug 22, 2023 · 7 comments

Comments

@WayneMao
Copy link

When I save the result of video, I have a problem:
Example:
image

Error:

> Finished chain.
Moviepy - Building video /data/GitHub/DriveLikeAHuman/results-video/highwayv0-episode-0.mp4.
Moviepy - Writing video /data/GitHub/DriveLikeAHuman/results-video/highwayv0-episode-0.mp4

                                                  
Moviepy - Done !
Moviepy - video ready /data/GitHub/DriveLikeAHuman/results-video/highwayv0-episode-0.mp4

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connection.py:203, in HTTPConnection._new_conn(self)
    202 try:
--> 203     sock = connection.create_connection(
    204         (self._dns_host, self.port),
    205         self.timeout,
    206         source_address=self.source_address,
    207         socket_options=self.socket_options,
    208     )
    209 except socket.gaierror as e:

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/util/connection.py:85, in create_connection(address, timeout, source_address, socket_options)
     84 try:
---> 85     raise err
     86 finally:
     87     # Break explicitly a reference cycle

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/util/connection.py:73, in create_connection(address, timeout, source_address, socket_options)
     72     sock.bind(source_address)
---> 73 sock.connect(sa)
     74 # Break explicitly a reference cycle

TimeoutError: [Errno 110] Connection timed out

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

ConnectTimeoutError                       Traceback (most recent call last)
File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connectionpool.py:790, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
    789 # Make the request on the HTTPConnection object
--> 790 response = self._make_request(
    791     conn,
    792     method,
    793     url,
    794     timeout=timeout_obj,
    795     body=body,
    796     headers=headers,
    797     chunked=chunked,
    798     retries=retries,
    799     response_conn=response_conn,
    800     preload_content=preload_content,
    801     decode_content=decode_content,
    802     **response_kw,
    803 )
    805 # Everything went great!

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connectionpool.py:491, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
    490         new_e = _wrap_proxy_error(new_e, conn.proxy.scheme)
--> 491     raise new_e
    493 # conn.request() calls http.client.*.request, not the method in
    494 # urllib3.request. It also calls makefile (recv) on the socket.

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connectionpool.py:467, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
    466 try:
--> 467     self._validate_conn(conn)
    468 except (SocketTimeout, BaseSSLError) as e:

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connectionpool.py:1092, in HTTPSConnectionPool._validate_conn(self, conn)
   1091 if conn.is_closed:
-> 1092     conn.connect()
   1094 if not conn.is_verified:

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connection.py:611, in HTTPSConnection.connect(self)
    610 sock: socket.socket | ssl.SSLSocket
--> 611 self.sock = sock = self._new_conn()
    612 server_hostname: str = self.host

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connection.py:212, in HTTPConnection._new_conn(self)
    211 except SocketTimeout as e:
--> 212     raise ConnectTimeoutError(
    213         self,
    214         f"Connection to {self.host} timed out. (connect timeout={self.timeout})",
    215     ) from e
    217 except OSError as e:

ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f0c0bb01480>, 'Connection to openaipublic.blob.core.windows.net timed out. (connect timeout=None)')

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

MaxRetryError                             Traceback (most recent call last)
File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/adapters.py:486, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    485 try:
--> 486     resp = conn.urlopen(
    487         method=request.method,
    488         url=url,
    489         body=request.body,
    490         headers=request.headers,
    491         redirect=False,
    492         assert_same_host=False,
    493         preload_content=False,
    494         decode_content=False,
    495         retries=self.max_retries,
    496         timeout=timeout,
    497         chunked=chunked,
    498     )
    500 except (ProtocolError, OSError) as err:

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/connectionpool.py:844, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
    842     new_e = ProtocolError("Connection aborted.", new_e)
--> 844 retries = retries.increment(
    845     method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    846 )
    847 retries.sleep()

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/urllib3/util/retry.py:515, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    514     reason = error or ResponseError(cause)
--> 515     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    517 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f0c0bb01480>, 'Connection to openaipublic.blob.core.windows.net timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

ConnectTimeout                            Traceback (most recent call last)
File /data/GitHub/DriveLikeAHuman/HELLM.py:105
    103 while not (done or truncated):
    104     sce.upateVehicles(obs, frame)
--> 105     DA.agentRun(output)
    106     da_output = DA.exportThoughts()
    107     output = outputParser.agentRun(da_output)

File /data/GitHub/DriveLikeAHuman/LLMDriver/driverAgent.py:72, in DriverAgent.agentRun(self, last_step_decision)
     70     last_step_explanation = "Not available"
     71 with get_openai_callback() as cb:
---> 72     self.agent.run(
     73         f"""
     74         You, the 'ego' car, are now driving a car on a highway. You have already drive for {self.sce.frame} seconds.
     75         The decision you made LAST time step was `{last_step_action}`. Your explanation was `{last_step_explanation}`. 
     76         Here is the current scenario: \n ```json\n{self.sce.export2json()}\n```\n. 
     77         Please make decision for the `ego` car. You have to describe the state of the `ego`, then analyze the possible actions, and finally output your decision. 
     78 
     79         There are several rules you need to follow when you drive on a highway:
     80         {TRAFFIC_RULES}
     81 
     82         Here are your attentions points:
     83         {DECISION_CAUTIONS}
     84         
     85         Let's think step by step. Once you made a final decision, output it in the following format: \n
     86         ```
     87         Final Answer: 
     88             "decision":{{"ego car's decision, ONE of the available actions"}},
     89             "expalanations":{{"your explaination about your decision, described your suggestions to the driver"}}
     90         ``` \n
     91         """,
     92         callbacks=[self.ch]
     93     )
     94 print(cb)
     95 print('[cyan]Final decision:[/cyan]')

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/chains/base.py:315, in Chain.run(self, callbacks, tags, metadata, *args, **kwargs)
    313     if len(args) != 1:
    314         raise ValueError("`run` supports only one positional argument.")
--> 315     return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
    316         _output_key
    317     ]
    319 if kwargs and not args:
    320     return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[
    321         _output_key
    322     ]

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/chains/base.py:183, in Chain.__call__(self, inputs, return_only_outputs, callbacks, tags, metadata, include_run_info)
    181     raise e
    182 run_manager.on_chain_end(outputs)
--> 183 final_outputs: Dict[str, Any] = self.prep_outputs(
    184     inputs, outputs, return_only_outputs
    185 )
    186 if include_run_info:
    187     final_outputs[RUN_KEY] = RunInfo(run_id=run_manager.run_id)

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/chains/base.py:257, in Chain.prep_outputs(self, inputs, outputs, return_only_outputs)
    255 self._validate_outputs(outputs)
    256 if self.memory is not None:
--> 257     self.memory.save_context(inputs, outputs)
    258 if return_only_outputs:
    259     return outputs

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/memory/token_buffer.py:48, in ConversationTokenBufferMemory.save_context(self, inputs, outputs)
     46 # Prune buffer if it exceeds max token limit
     47 buffer = self.chat_memory.messages
---> 48 curr_buffer_length = self.llm.get_num_tokens_from_messages(buffer)
     49 if curr_buffer_length > self.max_token_limit:
     50     pruned_memory = []

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/chat_models/openai.py:499, in ChatOpenAI.get_num_tokens_from_messages(self, messages)
    497 if sys.version_info[1] <= 7:
    498     return super().get_num_tokens_from_messages(messages)
--> 499 model, encoding = self._get_encoding_model()
    500 if model.startswith("gpt-3.5-turbo"):
    501     # every message follows <im_start>{role/name}\n{content}<im_end>\n
    502     tokens_per_message = 4

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/langchain/chat_models/openai.py:477, in ChatOpenAI._get_encoding_model(self)
    475 # Returns the number of tokens used by a list of messages.
    476 try:
--> 477     encoding = tiktoken_.encoding_for_model(model)
    478 except KeyError:
    479     logger.warning("Warning: model not found. Using cl100k_base encoding.")

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken/model.py:67, in encoding_for_model(model_name)
     65     for model_prefix, model_encoding_name in MODEL_PREFIX_TO_ENCODING.items():
     66         if model_name.startswith(model_prefix):
---> 67             return get_encoding(model_encoding_name)
     69 if encoding_name is None:
     70     raise KeyError(
     71         f"Could not automatically map {model_name} to a tokeniser. "
     72         "Please use `tiktok.get_encoding` to explicitly get the tokeniser you expect."
     73     ) from None

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken/registry.py:63, in get_encoding(encoding_name)
     60     raise ValueError(f"Unknown encoding {encoding_name}")
     62 constructor = ENCODING_CONSTRUCTORS[encoding_name]
---> 63 enc = Encoding(**constructor())
     64 ENCODINGS[encoding_name] = enc
     65 return enc

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken_ext/openai_public.py:64, in cl100k_base()
     63 def cl100k_base():
---> 64     mergeable_ranks = load_tiktoken_bpe(
     65         "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken"
     66     )
     67     special_tokens = {
     68         ENDOFTEXT: 100257,
     69         FIM_PREFIX: 100258,
   (...)
     72         ENDOFPROMPT: 100276,
     73     }
     74     return {
     75         "name": "cl100k_base",
     76         "pat_str": r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+""",
     77         "mergeable_ranks": mergeable_ranks,
     78         "special_tokens": special_tokens,
     79     }

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken/load.py:116, in load_tiktoken_bpe(tiktoken_bpe_file)
    114 def load_tiktoken_bpe(tiktoken_bpe_file: str) -> dict[bytes, int]:
    115     # NB: do not add caching to this function
--> 116     contents = read_file_cached(tiktoken_bpe_file)
    117     return {
    118         base64.b64decode(token): int(rank)
    119         for token, rank in (line.split() for line in contents.splitlines() if line)
    120     }

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken/load.py:48, in read_file_cached(blobpath)
     45     with open(cache_path, "rb") as f:
     46         return f.read()
---> 48 contents = read_file(blobpath)
     50 os.makedirs(cache_dir, exist_ok=True)
     51 tmp_filename = cache_path + "." + str(uuid.uuid4()) + ".tmp"

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/tiktoken/load.py:24, in read_file(blobpath)
     22         return f.read()
     23 # avoiding blobfile for public files helps avoid auth issues, like MFA prompts
---> 24 resp = requests.get(blobpath)
     25 resp.raise_for_status()
     26 return resp.content

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/api.py:73, in get(url, params, **kwargs)
     62 def get(url, params=None, **kwargs):
     63     r"""Sends a GET request.
     64 
     65     :param url: URL for the new :class:`Request` object.
   (...)
     70     :rtype: requests.Response
     71     """
---> 73     return request("get", url, params=params, **kwargs)

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/api.py:59, in request(method, url, **kwargs)
     55 # By using the 'with' statement we are sure the session is closed, thus we
     56 # avoid leaving sockets open which can trigger a ResourceWarning in some
     57 # cases, and look like a memory leak in others.
     58 with sessions.Session() as session:
---> 59     return session.request(method=method, url=url, **kwargs)

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    584 send_kwargs = {
    585     "timeout": timeout,
    586     "allow_redirects": allow_redirects,
    587 }
    588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
    591 return resp

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/sessions.py:703, in Session.send(self, request, **kwargs)
    700 start = preferred_clock()
    702 # Send the request
--> 703 r = adapter.send(request, **kwargs)
    705 # Total elapsed time of the request (approximately)
    706 elapsed = preferred_clock() - start

File ~/anaconda3/envs/llama/lib/python3.10/site-packages/requests/adapters.py:507, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    504 if isinstance(e.reason, ConnectTimeoutError):
    505     # TODO: Remove this in 3.0.0: see #2811
    506     if not isinstance(e.reason, NewConnectionError):
--> 507         raise ConnectTimeout(e, request=request)
    509 if isinstance(e.reason, ResponseError):
    510     raise RetryError(e, request=request)

ConnectTimeout: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f0c0bb01480>, 'Connection to openaipublic.blob.core.windows.net timed out. (connect timeout=None)'))

MY Version:

python==3.10
urllib3==2.0.4
moviepy==1.0.3
tiktoken==0.4.0

I guess it may be a problem with the urllib3 version, my current version is urllib3==2.0.4,
I would like to ask your the version of urllib3 , python, moviepy and tiktoken.

Thank you.

@zijinoier
Copy link
Contributor

Hello, I noticed you're using LLama instead of our original GPT-3/4 in the repo.
The error you posted, especially the last line mentioning a connection timeout to openaipublic.blob.core.windows.net, seems like a network issue rather than a problem with saving movies. Please verify your network connection to the LLama server.

@WayneMao
Copy link
Author

WayneMao commented Aug 23, 2023

Thank you for your reply.

  1. LLama is just the Conda environment name. The model I used was "gpt-3.5-turbo-16k-0613". And I can use GPT3.5 directly through the proxy.
  2. Some people experienced similar problems and changed the urllib3 version from 2.0.4 to 1.25.11
    requests.exceptions.SSLError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))) Significant-Gravitas/AutoGPT#1909
  3. I changed the version of urllib3 to 1.25.11, but it doesn't work.

@zijinoier
Copy link
Contributor

For your information, My current urllib3 version is 1.26.15.

@WayneMao
Copy link
Author

Thank you very much.
Finally, I solved the problem by specifying urllib3==1.26.15 and tiktoken==0.4.0;

@shaunck96
Copy link

image
image
image
Still experiencing this issue someone please help out with the same. Tried matching the versions of tiktoken and urllib3 to the versions above and Im trying to count tokens in my prompt using vscode locally.

@entzyeung
Copy link

I have the same problem here.
I have already aligned my environment to the suggested with

 !pip install urllib3==1.26.15
!pip install tiktoken==0.4.0

TimeoutError Traceback (most recent call last)
File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connection.py:174, in HTTPConnection._new_conn(self)
173 try:
--> 174 conn = connection.create_connection(
175 (self._dns_host, self.port), self.timeout, **extra_kw
176 )
178 except SocketTimeout:

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/util/connection.py:95, in create_connection(address, timeout, source_address, socket_options)
94 if err is not None:
---> 95 raise err
97 raise socket.error("getaddrinfo returns an empty list")

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/util/connection.py:85, in create_connection(address, timeout, source_address, socket_options)
84 sock.bind(source_address)
---> 85 sock.connect(sa)
86 return sock

TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

NewConnectionError Traceback (most recent call last)
File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connectionpool.py:715, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
714 # Make the request on the httplib connection object.
--> 715 httplib_response = self._make_request(
716 conn,
717 method,
718 url,
719 timeout=timeout_obj,
720 body=body,
721 headers=headers,
722 chunked=chunked,
723 )
725 # If we're going to release the connection in finally:, then
726 # the response doesn't need to know about the connection. Otherwise
727 # it will also try to release it and we'll have a double-release
728 # mess.

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connectionpool.py:404, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
403 try:
--> 404 self._validate_conn(conn)
405 except (SocketTimeout, BaseSSLError) as e:
406 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connectionpool.py:1058, in HTTPSConnectionPool._validate_conn(self, conn)
1057 if not getattr(conn, "sock", None): # AppEngine might not have .sock
-> 1058 conn.connect()
1060 if not conn.is_verified:

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connection.py:363, in HTTPSConnection.connect(self)
361 def connect(self):
362 # Add certificate verification
--> 363 self.sock = conn = self._new_conn()
364 hostname = self.host

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connection.py:186, in HTTPConnection._new_conn(self)
185 except SocketError as e:
--> 186 raise NewConnectionError(
187 self, "Failed to establish a new connection: %s" % e
188 )
190 return conn

NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f64568f1fd0>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

MaxRetryError Traceback (most recent call last)
File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/adapters.py:486, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
485 try:
--> 486 resp = conn.urlopen(
487 method=request.method,
488 url=url,
489 body=request.body,
490 headers=request.headers,
491 redirect=False,
492 assert_same_host=False,
493 preload_content=False,
494 decode_content=False,
495 retries=self.max_retries,
496 timeout=timeout,
497 chunked=chunked,
498 )
500 except (ProtocolError, OSError) as err:

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/connectionpool.py:799, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
797 e = ProtocolError("Connection aborted.", e)
--> 799 retries = retries.increment(
800 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
801 )
802 retries.sleep()

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
591 if new_retry.is_exhausted():
--> 592 raise MaxRetryError(_pool, url, error or ResponseError(cause))
594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f64568f1fd0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

ConnectionError Traceback (most recent call last)
Cell In[24], line 15
11 # Update this line based on the type of client you are using
12 # For example, for a persistent client:
13 client = chromadb.PersistentClient(path=f"{path_for_directory_of_pdf}_db")
---> 15 vectorstore = Chroma.from_documents(
16 documents, embeddings, client=client # Pass the client here
17 )
19 # saving the current state of the vectorstore object to disk.
20 vectorstore.persist()

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/langchain/vectorstores/chroma.py:462, in Chroma.from_documents(cls, documents, embedding, ids, collection_name, persist_directory, client_settings, client, **kwargs)
460 texts = [doc.page_content for doc in documents]
461 metadatas = [doc.metadata for doc in documents]
--> 462 return cls.from_texts(
463 texts=texts,
464 embedding=embedding,
465 metadatas=metadatas,
466 ids=ids,
467 collection_name=collection_name,
468 persist_directory=persist_directory,
469 client_settings=client_settings,
470 client=client,
471 )

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/langchain/vectorstores/chroma.py:430, in Chroma.from_texts(cls, texts, embedding, metadatas, ids, collection_name, persist_directory, client_settings, client, **kwargs)
406 """Create a Chroma vectorstore from a raw documents.
407
408 If a persist_directory is specified, the collection will be persisted there.
(...)
421 Chroma: Chroma vectorstore.
422 """
423 chroma_collection = cls(
424 collection_name=collection_name,
425 embedding_function=embedding,
(...)
428 client=client,
429 )
--> 430 chroma_collection.add_texts(texts=texts, metadatas=metadatas, ids=ids)
431 return chroma_collection

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/langchain/vectorstores/chroma.py:149, in Chroma.add_texts(self, texts, metadatas, ids, **kwargs)
147 embeddings = None
148 if self._embedding_function is not None:
--> 149 embeddings = self._embedding_function.embed_documents(list(texts))
150 self._collection.upsert(
151 metadatas=metadatas, embeddings=embeddings, documents=texts, ids=ids
152 )
153 return ids

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/langchain/embeddings/openai.py:452, in OpenAIEmbeddings.embed_documents(self, texts, chunk_size)
440 """Call out to OpenAI's embedding endpoint for embedding search docs.
441
442 Args:
(...)
448 List of embeddings, one for each text.
449 """
450 # NOTE: to keep things simple, we assume the list may contain texts longer
451 # than the maximum context and use length-safe embedding function.
--> 452 return self._get_len_safe_embeddings(texts, engine=self.deployment)

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/langchain/embeddings/openai.py:280, in OpenAIEmbeddings._get_len_safe_embeddings(self, texts, engine, chunk_size)
278 model_name = self.tiktoken_model_name or self.model
279 try:
--> 280 encoding = tiktoken.encoding_for_model(model_name)
281 except KeyError:
282 logger.warning("Warning: model not found. Using cl100k_base encoding.")

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken/model.py:75, in encoding_for_model(model_name)
69 if encoding_name is None:
70 raise KeyError(
71 f"Could not automatically map {model_name} to a tokeniser. "
72 "Please use tiktok.get_encoding to explicitly get the tokeniser you expect."
73 ) from None
---> 75 return get_encoding(encoding_name)

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken/registry.py:63, in get_encoding(encoding_name)
60 raise ValueError(f"Unknown encoding {encoding_name}")
62 constructor = ENCODING_CONSTRUCTORS[encoding_name]
---> 63 enc = Encoding(**constructor())
64 ENCODINGS[encoding_name] = enc
65 return enc

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken_ext/openai_public.py:64, in cl100k_base()
63 def cl100k_base():
---> 64 mergeable_ranks = load_tiktoken_bpe(
65 "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken"
66 )
67 special_tokens = {
68 ENDOFTEXT: 100257,
69 FIM_PREFIX: 100258,
(...)
72 ENDOFPROMPT: 100276,
73 }
74 return {
75 "name": "cl100k_base",
76 "pat_str": r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]|\s[\r\n]+|\s+(?!\S)|\s+""",
77 "mergeable_ranks": mergeable_ranks,
78 "special_tokens": special_tokens,
79 }

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken/load.py:116, in load_tiktoken_bpe(tiktoken_bpe_file)
114 def load_tiktoken_bpe(tiktoken_bpe_file: str) -> dict[bytes, int]:
115 # NB: do not add caching to this function
--> 116 contents = read_file_cached(tiktoken_bpe_file)
117 return {
118 base64.b64decode(token): int(rank)
119 for token, rank in (line.split() for line in contents.splitlines() if line)
120 }

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken/load.py:48, in read_file_cached(blobpath)
45 with open(cache_path, "rb") as f:
46 return f.read()
---> 48 contents = read_file(blobpath)
50 os.makedirs(cache_dir, exist_ok=True)
51 tmp_filename = cache_path + "." + str(uuid.uuid4()) + ".tmp"

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/tiktoken/load.py:24, in read_file(blobpath)
22 return f.read()
23 # avoiding blobfile for public files helps avoid auth issues, like MFA prompts
---> 24 resp = requests.get(blobpath)
25 resp.raise_for_status()
26 return resp.content

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/api.py:73, in get(url, params, **kwargs)
62 def get(url, params=None, **kwargs):
63 r"""Sends a GET request.
64
65 :param url: URL for the new :class:Request object.
(...)
70 :rtype: requests.Response
71 """
---> 73 return request("get", url, params=params, **kwargs)

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/api.py:59, in request(method, url, **kwargs)
55 # By using the 'with' statement we are sure the session is closed, thus we
56 # avoid leaving sockets open which can trigger a ResourceWarning in some
57 # cases, and look like a memory leak in others.
58 with sessions.Session() as session:
---> 59 return session.request(method=method, url=url, **kwargs)

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
584 send_kwargs = {
585 "timeout": timeout,
586 "allow_redirects": allow_redirects,
587 }
588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
591 return resp

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/sessions.py:703, in Session.send(self, request, **kwargs)
700 start = preferred_clock()
702 # Send the request
--> 703 r = adapter.send(request, **kwargs)
705 # Total elapsed time of the request (approximately)
706 elapsed = preferred_clock() - start

File /opt/saturncloud/envs/saturn/lib/python3.9/site-packages/requests/adapters.py:519, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
515 if isinstance(e.reason, _SSLError):
516 # This branch is for urllib3 v1.22 and later.
517 raise SSLError(e, request=request)
--> 519 raise ConnectionError(e, request=request)
521 except ClosedPoolError as e:
522 raise ConnectionError(e, request=request)

ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f64568f1fd0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

@macsunmood
Copy link

@entzyeung Hi! The same problem here with SaturnCloud. Have you found a solution?

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

5 participants