diff --git a/00-chartgpt/chainlit/nohup.out b/00-chartgpt/chainlit/nohup.out index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0fa21cdad09b21e145d4afcd7fc19a588895d8b7 100644 --- a/00-chartgpt/chainlit/nohup.out +++ b/00-chartgpt/chainlit/nohup.out @@ -0,0 +1,138 @@ +2023-06-23 08:11:20 - WARNING! engine is not default parameter. + engine was transferred to model_kwargs. + Please confirm that engine is what you intended. +2023-06-23 08:11:20 - Your app is available at http://localhost:8000 +2023-06-23 08:21:13 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:13 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:13 - Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 1.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")). +2023-06-23 08:21:14 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:14 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:14 - Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 2.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")). +2023-06-23 08:21:16 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:16 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:16 - Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")). +2023-06-23 08:21:20 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:20 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:20 - Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 8.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")). +2023-06-23 08:21:28 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:28 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:28 - Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 16.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")). +2023-06-23 08:21:44 - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:44 - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")': //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 +2023-06-23 08:21:44 - Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")) +Traceback (most recent call last): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connection.py", line 200, in _new_conn + sock = connection.create_connection( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/util/connection.py", line 60, in create_connection + for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/socket.py", line 954, in getaddrinfo + for res in _socket.getaddrinfo(host, port, family, type, proto, flags): +socket.gaierror: [Errno 8] nodename nor servname provided, or not known + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 790, in urlopen + response = self._make_request( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 491, in _make_request + raise new_e + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 467, in _make_request + self._validate_conn(conn) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn + conn.connect() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connection.py", line 604, in connect + self.sock = sock = self._new_conn() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connection.py", line 207, in _new_conn + raise NameResolutionError(self.host, self, e) from e +urllib3.exceptions.NameResolutionError: : Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known) + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/requests/adapters.py", line 486, in send + resp = conn.urlopen( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 874, in urlopen + return self.urlopen( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 874, in urlopen + return self.urlopen( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/connectionpool.py", line 844, in urlopen + retries = retries.increment( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/urllib3/util/retry.py", line 515, in increment + raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] +urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")) + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/openai/api_requestor.py", line 520, in request_raw + result = _thread_context.session.request( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/requests/sessions.py", line 589, in request + resp = self.send(prep, **send_kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/requests/sessions.py", line 703, in send + r = adapter.send(request, **kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/requests/adapters.py", line 519, in send + raise ConnectionError(e, request=request) +requests.exceptions.ConnectionError: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")) + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/chainlit/__init__.py", line 61, in wrapper + return await user_function(**params_values) + File "azure_demo.py", line 24, in main + res = await cl.make_async(sync_func)() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/asyncer/_main.py", line 358, in wrapper + return await anyio.to_thread.run_sync( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/anyio/to_thread.py", line 33, in run_sync + return await get_asynclib().run_sync_in_worker_thread( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread + return await future + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/asyncio/futures.py", line 284, in __await__ + yield self # This tells Task to wait for completion. + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/asyncio/tasks.py", line 328, in __wakeup + future.result() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/asyncio/futures.py", line 201, in result + raise self._exception + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 807, in run + result = context.run(func, *args) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/chainlit/sync.py", line 20, in wrapper + res = function(*args, **kwargs) + File "azure_demo.py", line 35, in sync_func + return chat(history) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/base.py", line 208, in __call__ + generation = self.generate( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/base.py", line 102, in generate + raise e + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/base.py", line 94, in generate + results = [ + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/base.py", line 95, in + self._generate(m, stop=stop, run_manager=run_manager, **kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/openai.py", line 359, in _generate + response = self.completion_with_retry(messages=message_dicts, **params) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/openai.py", line 307, in completion_with_retry + return _completion_with_retry(**kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/tenacity/__init__.py", line 289, in wrapped_f + return self(f, *args, **kw) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/tenacity/__init__.py", line 379, in __call__ + do = self.iter(retry_state=retry_state) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/tenacity/__init__.py", line 325, in iter + raise retry_exc.reraise() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/tenacity/__init__.py", line 158, in reraise + raise self.last_attempt.result() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/concurrent/futures/_base.py", line 439, in result + return self.__get_result() + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result + raise self._exception + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/tenacity/__init__.py", line 382, in __call__ + result = fn(*args, **kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/langchain/chat_models/openai.py", line 305, in _completion_with_retry + return self.client.create(**kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create + return super().create(*args, **kwargs) + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create + response, _, api_key = requestor.request( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/openai/api_requestor.py", line 220, in request + result = self.request_raw( + File "/Users/qinyingjie/miniconda3/envs/py36tf1/lib/python3.9/site-packages/openai/api_requestor.py", line 533, in request_raw + raise error.APIConnectionError( +openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='opencatgpt.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 (Caused by NameResolutionError(": Failed to resolve 'opencatgpt.openai.azure.com' ([Errno 8] nodename nor servname provided, or not known)")) diff --git "a/14_\345\210\267\351\242\230/day02/problem_solving_12.py" "b/14_\345\210\267\351\242\230/day02/problem_solving_12.py" new file mode 100644 index 0000000000000000000000000000000000000000..f862ba496f808518a5421a535d3e08b55c5ffed0 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day02/problem_solving_12.py" @@ -0,0 +1,42 @@ +""" +多数元素 +""" +from typing import List + + +class Solution: + def majorityElement(self, nums: List[int]) -> int: + """ + 多数元素 + :param nums: + :return: + """ + count = 0 + candidate = None + for i in nums: + if count == 0: + candidate = i + if i == candidate: + count += 1 + else: + count += -1 + return candidate + + def majorityElement2(self, nums: List[int]) -> int: + """ + 多数元素 + :param nums: + :return: + """ + count = 0 + candidate = None + for i in nums: + if count == 0: + candidate = i + count += (1 if i == candidate else -1) + return candidate + + +if __name__ == '__main__': + root = Solution().majorityElement2([3, 2, 3]) + print(root) diff --git "a/14_\345\210\267\351\242\230/day02/problem_solving_13.py" "b/14_\345\210\267\351\242\230/day02/problem_solving_13.py" new file mode 100644 index 0000000000000000000000000000000000000000..4c1032d927074f891e837260c1804314984011a8 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day02/problem_solving_13.py" @@ -0,0 +1,20 @@ +""" +存在重复元素 +""" +from typing import List + + +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + """ + set集合去重 + :param nums: + :return: + """ + new_list = set(nums) + return len(new_list) != len(nums) + + +if __name__ == '__main__': + root = Solution().containsDuplicate([1, 2, 3, 1]) + print(root) diff --git "a/14_\345\210\267\351\242\230/day02/problem_solving_14.py" "b/14_\345\210\267\351\242\230/day02/problem_solving_14.py" new file mode 100644 index 0000000000000000000000000000000000000000..a1e840589c4e431d6bfbfd17d43664607b02a068 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day02/problem_solving_14.py" @@ -0,0 +1,40 @@ +""" +存在重复元素 II +""" +from typing import List + + +class Solution: + def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: + """ + 基础暴力破解,超出时间限制 + :param nums: + :param k: + :return: + """ + for i, i_val in enumerate(nums): + for j, j_val in enumerate(nums): + if i != j and i_val == j_val and abs(i - j) <= k: + return True + return False + + def containsNearbyDuplicate1(self, nums: List[int], k: int) -> bool: + """ + 字典的使用 + :param nums: + :param k: + :return: + """ + num_dict = {} + for i, num in enumerate(nums): + # 关键判断 + if num in num_dict and i - num_dict.get(num) <= k: + return True + else: + num_dict[num] = i + return False + + +if __name__ == '__main__': + root = Solution().containsNearbyDuplicate1([1, 2, 3, 1], 3) + print(root)