gpt-batch 0.1.2__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gpt_batch/batcher.py CHANGED
@@ -57,22 +57,26 @@ class GPTBatcher:
57
57
  new_list = []
58
58
  num_workers = self.num_workers
59
59
  timeout_duration = self.timeout_duration
60
- retry_attempts=2
61
-
60
+ retry_attempts = 2
61
+
62
62
  executor = ThreadPoolExecutor(max_workers=num_workers)
63
63
  message_chunks = list(self.chunk_list(message_list, num_workers))
64
- for chunk in tqdm(message_chunks, desc="Processing messages"):
65
- future_to_message = {executor.submit(self.get_attitude, message): message for message in chunk}
66
- for _ in range(retry_attempts):
67
- done, not_done = wait(future_to_message.keys(), timeout=timeout_duration)
68
- for future in not_done:
69
- future.cancel()
70
- new_list.extend(future.result() for future in done if future.done())
71
- if len(not_done) == 0:
72
- break
73
- future_to_message = {executor.submit(self.get_attitude, future_to_message[future]): future_to_message[future] for future, msg in not_done}
74
- executor.shutdown(wait=False)
75
- return new_list
64
+ try:
65
+ for chunk in tqdm(message_chunks, desc="Processing messages"):
66
+ future_to_message = {executor.submit(self.get_attitude, message): message for message in chunk}
67
+ for _ in range(retry_attempts):
68
+ done, not_done = wait(future_to_message.keys(), timeout=timeout_duration)
69
+ for future in not_done:
70
+ future.cancel()
71
+ new_list.extend(future.result() for future in done if future.done())
72
+ if len(not_done) == 0:
73
+ break
74
+ future_to_message = {executor.submit(self.get_attitude, future_to_message[future]): future for future in not_done}
75
+ except Exception as e:
76
+ print(f"Error occurred: {e}")
77
+ finally:
78
+ executor.shutdown(wait=False)
79
+ return new_list
76
80
 
77
81
  def complete_attitude_list(self,attitude_list, max_length):
78
82
  completed_list = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gpt-batch
3
- Version: 0.1.2
3
+ Version: 0.1.5
4
4
  Summary: A package for batch processing with OpenAI API.
5
5
  Home-page: https://github.com/fengsxy/gpt_batch
6
6
  Author: Ted Yu
@@ -23,7 +23,7 @@ A simple tool to batch process messages using OpenAI's GPT models. `GPTBatcher`
23
23
  To get started with `GPTBatcher`, clone this repository to your local machine. Navigate to the repository directory and install the required dependencies (if any) by running:
24
24
 
25
25
  ```bash
26
- pip install -r requirements.txt
26
+ pip install gpt_batch
27
27
  ```
28
28
 
29
29
  ## Quick Start
@@ -77,11 +77,4 @@ The `GPTBatcher` class can be customized with several parameters to adjust its p
77
77
 
78
78
  For more detailed documentation on the parameters and methods, refer to the class docstring.
79
79
 
80
- ## License
81
-
82
- Specify your licensing information here.
83
-
84
- ```
85
-
86
- This README provides clear instructions on how to install and use the `GPTBatcher`, along with detailed explanations of its configuration parameters. Adjust the "License" section as necessary based on your project's licensing terms.
87
80
 
@@ -0,0 +1,8 @@
1
+ gpt_batch/__init__.py,sha256=zGDItktTxKLSQr44GY78dl5LKsSJig0Q59dzusqhU0U,59
2
+ gpt_batch/batcher.py,sha256=YvOX1V_9iX5jTX7xZOhjOWeT0IUlv9c-_UkLW2s1wFo,7395
3
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ tests/test_batcher.py,sha256=N88RZrSuBaDti6Lry7xipyGXHn3jKg85O12mjcHHZA0,3006
5
+ gpt_batch-0.1.5.dist-info/METADATA,sha256=kb524fTeHxmmYZM6MnhG_G_gqwLRy4ptdVmjIcaIdac,2932
6
+ gpt_batch-0.1.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
+ gpt_batch-0.1.5.dist-info/top_level.txt,sha256=FtvJB_L9W_S6jL4G8Em_YWphG1wdKAF20BHUrf4B0yM,16
8
+ gpt_batch-0.1.5.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- gpt_batch/__init__.py,sha256=zGDItktTxKLSQr44GY78dl5LKsSJig0Q59dzusqhU0U,59
2
- gpt_batch/batcher.py,sha256=CbOxb42ZN9mbZK-fdJH3tCwBhGS8E4DFI_0eCUtt0nA,7263
3
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- tests/test_batcher.py,sha256=N88RZrSuBaDti6Lry7xipyGXHn3jKg85O12mjcHHZA0,3006
5
- gpt_batch-0.1.2.dist-info/METADATA,sha256=e3jMa5f4ElYQthBbAoQJOAsLJQZHAgX2yqqVsdJTUf8,3234
6
- gpt_batch-0.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
- gpt_batch-0.1.2.dist-info/top_level.txt,sha256=FtvJB_L9W_S6jL4G8Em_YWphG1wdKAF20BHUrf4B0yM,16
8
- gpt_batch-0.1.2.dist-info/RECORD,,