ag2 0.4.1__py3-none-any.whl → 0.4.2b1__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.

Potentially problematic release.


This version of ag2 might be problematic. Click here for more details.

Files changed (161) hide show
  1. ag2-0.4.2b1.dist-info/METADATA +19 -0
  2. ag2-0.4.2b1.dist-info/RECORD +6 -0
  3. ag2-0.4.2b1.dist-info/top_level.txt +1 -0
  4. ag2-0.4.1.dist-info/METADATA +0 -500
  5. ag2-0.4.1.dist-info/RECORD +0 -158
  6. ag2-0.4.1.dist-info/top_level.txt +0 -1
  7. autogen/__init__.py +0 -17
  8. autogen/_pydantic.py +0 -116
  9. autogen/agentchat/__init__.py +0 -42
  10. autogen/agentchat/agent.py +0 -142
  11. autogen/agentchat/assistant_agent.py +0 -85
  12. autogen/agentchat/chat.py +0 -306
  13. autogen/agentchat/contrib/__init__.py +0 -0
  14. autogen/agentchat/contrib/agent_builder.py +0 -788
  15. autogen/agentchat/contrib/agent_eval/agent_eval.py +0 -107
  16. autogen/agentchat/contrib/agent_eval/criterion.py +0 -47
  17. autogen/agentchat/contrib/agent_eval/critic_agent.py +0 -47
  18. autogen/agentchat/contrib/agent_eval/quantifier_agent.py +0 -42
  19. autogen/agentchat/contrib/agent_eval/subcritic_agent.py +0 -48
  20. autogen/agentchat/contrib/agent_eval/task.py +0 -43
  21. autogen/agentchat/contrib/agent_optimizer.py +0 -450
  22. autogen/agentchat/contrib/capabilities/__init__.py +0 -0
  23. autogen/agentchat/contrib/capabilities/agent_capability.py +0 -21
  24. autogen/agentchat/contrib/capabilities/generate_images.py +0 -297
  25. autogen/agentchat/contrib/capabilities/teachability.py +0 -406
  26. autogen/agentchat/contrib/capabilities/text_compressors.py +0 -72
  27. autogen/agentchat/contrib/capabilities/transform_messages.py +0 -92
  28. autogen/agentchat/contrib/capabilities/transforms.py +0 -565
  29. autogen/agentchat/contrib/capabilities/transforms_util.py +0 -120
  30. autogen/agentchat/contrib/capabilities/vision_capability.py +0 -217
  31. autogen/agentchat/contrib/captainagent/tools/__init__.py +0 -0
  32. autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_correlation.py +0 -41
  33. autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_skewness_and_kurtosis.py +0 -29
  34. autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_iqr.py +0 -29
  35. autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_zscore.py +0 -29
  36. autogen/agentchat/contrib/captainagent/tools/data_analysis/explore_csv.py +0 -22
  37. autogen/agentchat/contrib/captainagent/tools/data_analysis/shapiro_wilk_test.py +0 -31
  38. autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py +0 -26
  39. autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py +0 -55
  40. autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_image.py +0 -54
  41. autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_text.py +0 -39
  42. autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_wikipedia_text.py +0 -22
  43. autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_youtube_caption.py +0 -35
  44. autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py +0 -61
  45. autogen/agentchat/contrib/captainagent/tools/information_retrieval/optical_character_recognition.py +0 -62
  46. autogen/agentchat/contrib/captainagent/tools/information_retrieval/perform_web_search.py +0 -48
  47. autogen/agentchat/contrib/captainagent/tools/information_retrieval/scrape_wikipedia_tables.py +0 -34
  48. autogen/agentchat/contrib/captainagent/tools/information_retrieval/transcribe_audio_file.py +0 -22
  49. autogen/agentchat/contrib/captainagent/tools/information_retrieval/youtube_download.py +0 -36
  50. autogen/agentchat/contrib/captainagent/tools/math/calculate_circle_area_from_diameter.py +0 -22
  51. autogen/agentchat/contrib/captainagent/tools/math/calculate_day_of_the_week.py +0 -19
  52. autogen/agentchat/contrib/captainagent/tools/math/calculate_fraction_sum.py +0 -29
  53. autogen/agentchat/contrib/captainagent/tools/math/calculate_matrix_power.py +0 -32
  54. autogen/agentchat/contrib/captainagent/tools/math/calculate_reflected_point.py +0 -17
  55. autogen/agentchat/contrib/captainagent/tools/math/complex_numbers_product.py +0 -26
  56. autogen/agentchat/contrib/captainagent/tools/math/compute_currency_conversion.py +0 -24
  57. autogen/agentchat/contrib/captainagent/tools/math/count_distinct_permutations.py +0 -28
  58. autogen/agentchat/contrib/captainagent/tools/math/evaluate_expression.py +0 -29
  59. autogen/agentchat/contrib/captainagent/tools/math/find_continuity_point.py +0 -35
  60. autogen/agentchat/contrib/captainagent/tools/math/fraction_to_mixed_numbers.py +0 -40
  61. autogen/agentchat/contrib/captainagent/tools/math/modular_inverse_sum.py +0 -23
  62. autogen/agentchat/contrib/captainagent/tools/math/simplify_mixed_numbers.py +0 -37
  63. autogen/agentchat/contrib/captainagent/tools/math/sum_of_digit_factorials.py +0 -16
  64. autogen/agentchat/contrib/captainagent/tools/math/sum_of_primes_below.py +0 -16
  65. autogen/agentchat/contrib/captainagent/tools/requirements.txt +0 -10
  66. autogen/agentchat/contrib/captainagent/tools/tool_description.tsv +0 -34
  67. autogen/agentchat/contrib/captainagent.py +0 -490
  68. autogen/agentchat/contrib/gpt_assistant_agent.py +0 -545
  69. autogen/agentchat/contrib/graph_rag/__init__.py +0 -0
  70. autogen/agentchat/contrib/graph_rag/document.py +0 -30
  71. autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +0 -111
  72. autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +0 -81
  73. autogen/agentchat/contrib/graph_rag/graph_query_engine.py +0 -56
  74. autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +0 -64
  75. autogen/agentchat/contrib/img_utils.py +0 -390
  76. autogen/agentchat/contrib/llamaindex_conversable_agent.py +0 -123
  77. autogen/agentchat/contrib/llava_agent.py +0 -176
  78. autogen/agentchat/contrib/math_user_proxy_agent.py +0 -471
  79. autogen/agentchat/contrib/multimodal_conversable_agent.py +0 -128
  80. autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +0 -325
  81. autogen/agentchat/contrib/retrieve_assistant_agent.py +0 -56
  82. autogen/agentchat/contrib/retrieve_user_proxy_agent.py +0 -705
  83. autogen/agentchat/contrib/society_of_mind_agent.py +0 -203
  84. autogen/agentchat/contrib/swarm_agent.py +0 -463
  85. autogen/agentchat/contrib/text_analyzer_agent.py +0 -76
  86. autogen/agentchat/contrib/tool_retriever.py +0 -120
  87. autogen/agentchat/contrib/vectordb/__init__.py +0 -0
  88. autogen/agentchat/contrib/vectordb/base.py +0 -243
  89. autogen/agentchat/contrib/vectordb/chromadb.py +0 -326
  90. autogen/agentchat/contrib/vectordb/mongodb.py +0 -559
  91. autogen/agentchat/contrib/vectordb/pgvectordb.py +0 -958
  92. autogen/agentchat/contrib/vectordb/qdrant.py +0 -334
  93. autogen/agentchat/contrib/vectordb/utils.py +0 -126
  94. autogen/agentchat/contrib/web_surfer.py +0 -305
  95. autogen/agentchat/conversable_agent.py +0 -2908
  96. autogen/agentchat/groupchat.py +0 -1668
  97. autogen/agentchat/user_proxy_agent.py +0 -109
  98. autogen/agentchat/utils.py +0 -207
  99. autogen/browser_utils.py +0 -291
  100. autogen/cache/__init__.py +0 -10
  101. autogen/cache/abstract_cache_base.py +0 -78
  102. autogen/cache/cache.py +0 -182
  103. autogen/cache/cache_factory.py +0 -85
  104. autogen/cache/cosmos_db_cache.py +0 -150
  105. autogen/cache/disk_cache.py +0 -109
  106. autogen/cache/in_memory_cache.py +0 -61
  107. autogen/cache/redis_cache.py +0 -128
  108. autogen/code_utils.py +0 -745
  109. autogen/coding/__init__.py +0 -22
  110. autogen/coding/base.py +0 -113
  111. autogen/coding/docker_commandline_code_executor.py +0 -262
  112. autogen/coding/factory.py +0 -45
  113. autogen/coding/func_with_reqs.py +0 -203
  114. autogen/coding/jupyter/__init__.py +0 -22
  115. autogen/coding/jupyter/base.py +0 -32
  116. autogen/coding/jupyter/docker_jupyter_server.py +0 -164
  117. autogen/coding/jupyter/embedded_ipython_code_executor.py +0 -182
  118. autogen/coding/jupyter/jupyter_client.py +0 -224
  119. autogen/coding/jupyter/jupyter_code_executor.py +0 -161
  120. autogen/coding/jupyter/local_jupyter_server.py +0 -168
  121. autogen/coding/local_commandline_code_executor.py +0 -410
  122. autogen/coding/markdown_code_extractor.py +0 -44
  123. autogen/coding/utils.py +0 -57
  124. autogen/exception_utils.py +0 -46
  125. autogen/extensions/__init__.py +0 -0
  126. autogen/formatting_utils.py +0 -76
  127. autogen/function_utils.py +0 -362
  128. autogen/graph_utils.py +0 -148
  129. autogen/io/__init__.py +0 -15
  130. autogen/io/base.py +0 -105
  131. autogen/io/console.py +0 -43
  132. autogen/io/websockets.py +0 -213
  133. autogen/logger/__init__.py +0 -11
  134. autogen/logger/base_logger.py +0 -140
  135. autogen/logger/file_logger.py +0 -287
  136. autogen/logger/logger_factory.py +0 -29
  137. autogen/logger/logger_utils.py +0 -42
  138. autogen/logger/sqlite_logger.py +0 -459
  139. autogen/math_utils.py +0 -356
  140. autogen/oai/__init__.py +0 -33
  141. autogen/oai/anthropic.py +0 -428
  142. autogen/oai/bedrock.py +0 -606
  143. autogen/oai/cerebras.py +0 -270
  144. autogen/oai/client.py +0 -1148
  145. autogen/oai/client_utils.py +0 -167
  146. autogen/oai/cohere.py +0 -453
  147. autogen/oai/completion.py +0 -1216
  148. autogen/oai/gemini.py +0 -469
  149. autogen/oai/groq.py +0 -281
  150. autogen/oai/mistral.py +0 -279
  151. autogen/oai/ollama.py +0 -582
  152. autogen/oai/openai_utils.py +0 -811
  153. autogen/oai/together.py +0 -343
  154. autogen/retrieve_utils.py +0 -487
  155. autogen/runtime_logging.py +0 -163
  156. autogen/token_count_utils.py +0 -259
  157. autogen/types.py +0 -20
  158. autogen/version.py +0 -7
  159. {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/LICENSE +0 -0
  160. {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/NOTICE.md +0 -0
  161. {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/WHEEL +0 -0
autogen/agentchat/chat.py DELETED
@@ -1,306 +0,0 @@
1
- # Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
2
- #
3
- # SPDX-License-Identifier: Apache-2.0
4
- #
5
- # Portions derived from https://github.com/microsoft/autogen are under the MIT License.
6
- # SPDX-License-Identifier: MIT
7
- import asyncio
8
- import datetime
9
- import logging
10
- import warnings
11
- from collections import abc, defaultdict
12
- from dataclasses import dataclass
13
- from functools import partial
14
- from typing import Any, Dict, List, Set, Tuple
15
-
16
- from ..formatting_utils import colored
17
- from ..io.base import IOStream
18
- from .utils import consolidate_chat_info
19
-
20
- logger = logging.getLogger(__name__)
21
- Prerequisite = Tuple[int, int]
22
-
23
-
24
- @dataclass
25
- class ChatResult:
26
- """(Experimental) The result of a chat. Almost certain to be changed."""
27
-
28
- chat_id: int = None
29
- """chat id"""
30
- chat_history: List[Dict[str, Any]] = None
31
- """The chat history."""
32
- summary: str = None
33
- """A summary obtained from the chat."""
34
- cost: Dict[str, dict] = None # keys: "usage_including_cached_inference", "usage_excluding_cached_inference"
35
- """The cost of the chat.
36
- The value for each usage type is a dictionary containing cost information for that specific type.
37
- - "usage_including_cached_inference": Cost information on the total usage, including the tokens in cached inference.
38
- - "usage_excluding_cached_inference": Cost information on the usage of tokens, excluding the tokens in cache. No larger than "usage_including_cached_inference".
39
- """
40
- human_input: List[str] = None
41
- """A list of human input solicited during the chat."""
42
-
43
-
44
- def _validate_recipients(chat_queue: List[Dict[str, Any]]) -> None:
45
- """
46
- Validate recipients exits and warn repetitive recipients.
47
- """
48
- receipts_set = set()
49
- for chat_info in chat_queue:
50
- assert "recipient" in chat_info, "recipient must be provided."
51
- receipts_set.add(chat_info["recipient"])
52
- if len(receipts_set) < len(chat_queue):
53
- warnings.warn(
54
- "Repetitive recipients detected: The chat history will be cleared by default if a recipient appears more than once. To retain the chat history, please set 'clear_history=False' in the configuration of the repeating agent.",
55
- UserWarning,
56
- )
57
-
58
-
59
- def __create_async_prerequisites(chat_queue: List[Dict[str, Any]]) -> List[Prerequisite]:
60
- """
61
- Create list of Prerequisite (prerequisite_chat_id, chat_id)
62
- """
63
- prerequisites = []
64
- for chat_info in chat_queue:
65
- if "chat_id" not in chat_info:
66
- raise ValueError("Each chat must have a unique id for async multi-chat execution.")
67
- chat_id = chat_info["chat_id"]
68
- pre_chats = chat_info.get("prerequisites", [])
69
- for pre_chat_id in pre_chats:
70
- if not isinstance(pre_chat_id, int):
71
- raise ValueError("Prerequisite chat id is not int.")
72
- prerequisites.append((chat_id, pre_chat_id))
73
- return prerequisites
74
-
75
-
76
- def __find_async_chat_order(chat_ids: Set[int], prerequisites: List[Prerequisite]) -> List[int]:
77
- """Find chat order for async execution based on the prerequisite chats
78
-
79
- args:
80
- num_chats: number of chats
81
- prerequisites: List of Prerequisite (prerequisite_chat_id, chat_id)
82
-
83
- returns:
84
- list: a list of chat_id in order.
85
- """
86
- edges = defaultdict(set)
87
- indegree = defaultdict(int)
88
- for pair in prerequisites:
89
- chat, pre = pair[0], pair[1]
90
- if chat not in edges[pre]:
91
- indegree[chat] += 1
92
- edges[pre].add(chat)
93
- bfs = [i for i in chat_ids if i not in indegree]
94
- chat_order = []
95
- steps = len(indegree)
96
- for _ in range(steps + 1):
97
- if not bfs:
98
- break
99
- chat_order.extend(bfs)
100
- nxt = []
101
- for node in bfs:
102
- if node in edges:
103
- for course in edges[node]:
104
- indegree[course] -= 1
105
- if indegree[course] == 0:
106
- nxt.append(course)
107
- indegree.pop(course)
108
- edges.pop(node)
109
- bfs = nxt
110
-
111
- if indegree:
112
- return []
113
- return chat_order
114
-
115
-
116
- def _post_process_carryover_item(carryover_item):
117
- if isinstance(carryover_item, str):
118
- return carryover_item
119
- elif isinstance(carryover_item, dict) and "content" in carryover_item:
120
- return str(carryover_item["content"])
121
- else:
122
- return str(carryover_item)
123
-
124
-
125
- def __post_carryover_processing(chat_info: Dict[str, Any]) -> None:
126
- iostream = IOStream.get_default()
127
-
128
- if "message" not in chat_info:
129
- warnings.warn(
130
- "message is not provided in a chat_queue entry. input() will be called to get the initial message.",
131
- UserWarning,
132
- )
133
- print_carryover = (
134
- ("\n").join([_post_process_carryover_item(t) for t in chat_info["carryover"]])
135
- if isinstance(chat_info["carryover"], list)
136
- else chat_info["carryover"]
137
- )
138
- message = chat_info.get("message")
139
- if isinstance(message, str):
140
- print_message = message
141
- elif callable(message):
142
- print_message = "Callable: " + message.__name__
143
- elif isinstance(message, dict):
144
- print_message = "Dict: " + str(message)
145
- elif message is None:
146
- print_message = "None"
147
- iostream.print(colored("\n" + "*" * 80, "blue"), flush=True, sep="")
148
- iostream.print(
149
- colored(
150
- "Starting a new chat....",
151
- "blue",
152
- ),
153
- flush=True,
154
- )
155
- if chat_info.get("verbose", False):
156
- iostream.print(colored("Message:\n" + print_message, "blue"), flush=True)
157
- iostream.print(colored("Carryover:\n" + print_carryover, "blue"), flush=True)
158
- iostream.print(colored("\n" + "*" * 80, "blue"), flush=True, sep="")
159
-
160
-
161
- def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]:
162
- """Initiate a list of chats.
163
- Args:
164
- chat_queue (List[Dict]): A list of dictionaries containing the information about the chats.
165
-
166
- Each dictionary should contain the input arguments for
167
- [`ConversableAgent.initiate_chat`](/docs/reference/agentchat/conversable_agent#initiate_chat).
168
- For example:
169
- - `"sender"` - the sender agent.
170
- - `"recipient"` - the recipient agent.
171
- - `"clear_history"` (bool) - whether to clear the chat history with the agent.
172
- Default is True.
173
- - `"silent"` (bool or None) - (Experimental) whether to print the messages in this
174
- conversation. Default is False.
175
- - `"cache"` (Cache or None) - the cache client to use for this conversation.
176
- Default is None.
177
- - `"max_turns"` (int or None) - maximum number of turns for the chat. If None, the chat
178
- will continue until a termination condition is met. Default is None.
179
- - `"summary_method"` (str or callable) - a string or callable specifying the method to get
180
- a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
181
- - `"summary_args"` (dict) - a dictionary of arguments to be passed to the summary_method.
182
- Default is {}.
183
- - `"message"` (str, callable or None) - if None, input() will be called to get the
184
- initial message.
185
- - `**context` - additional context information to be passed to the chat.
186
- - `"carryover"` - It can be used to specify the carryover information to be passed
187
- to this chat. If provided, we will combine this carryover with the "message" content when
188
- generating the initial chat message in `generate_init_message`.
189
- - `"finished_chat_indexes_to_exclude_from_carryover"` - It can be used by specifying a list of indexes of the finished_chats list,
190
- from which to exclude the summaries for carryover. If 'finished_chat_indexes_to_exclude_from_carryover' is not provided or an empty list,
191
- then summary from all the finished chats will be taken.
192
- Returns:
193
- (list): a list of ChatResult objects corresponding to the finished chats in the chat_queue.
194
- """
195
-
196
- consolidate_chat_info(chat_queue)
197
- _validate_recipients(chat_queue)
198
- current_chat_queue = chat_queue.copy()
199
- finished_chats = []
200
- while current_chat_queue:
201
- chat_info = current_chat_queue.pop(0)
202
- _chat_carryover = chat_info.get("carryover", [])
203
- finished_chat_indexes_to_exclude_from_carryover = chat_info.get(
204
- "finished_chat_indexes_to_exclude_from_carryover", []
205
- )
206
-
207
- if isinstance(_chat_carryover, str):
208
- _chat_carryover = [_chat_carryover]
209
- chat_info["carryover"] = _chat_carryover + [
210
- r.summary for i, r in enumerate(finished_chats) if i not in finished_chat_indexes_to_exclude_from_carryover
211
- ]
212
-
213
- if not chat_info.get("silent", False):
214
- __post_carryover_processing(chat_info)
215
-
216
- sender = chat_info["sender"]
217
- chat_res = sender.initiate_chat(**chat_info)
218
- finished_chats.append(chat_res)
219
- return finished_chats
220
-
221
-
222
- def __system_now_str():
223
- ct = datetime.datetime.now()
224
- return f" System time at {ct}. "
225
-
226
-
227
- def _on_chat_future_done(chat_future: asyncio.Future, chat_id: int):
228
- """
229
- Update ChatResult when async Task for Chat is completed.
230
- """
231
- logger.debug(f"Update chat {chat_id} result on task completion." + __system_now_str())
232
- chat_result = chat_future.result()
233
- chat_result.chat_id = chat_id
234
-
235
-
236
- async def _dependent_chat_future(
237
- chat_id: int, chat_info: Dict[str, Any], prerequisite_chat_futures: Dict[int, asyncio.Future]
238
- ) -> asyncio.Task:
239
- """
240
- Create an async Task for each chat.
241
- """
242
- logger.debug(f"Create Task for chat {chat_id}." + __system_now_str())
243
- _chat_carryover = chat_info.get("carryover", [])
244
- finished_chat_indexes_to_exclude_from_carryover = chat_info.get(
245
- "finished_chat_indexes_to_exclude_from_carryover", []
246
- )
247
- finished_chats = dict()
248
- for chat in prerequisite_chat_futures:
249
- chat_future = prerequisite_chat_futures[chat]
250
- if chat_future.cancelled():
251
- raise RuntimeError(f"Chat {chat} is cancelled.")
252
-
253
- # wait for prerequisite chat results for the new chat carryover
254
- finished_chats[chat] = await chat_future
255
-
256
- if isinstance(_chat_carryover, str):
257
- _chat_carryover = [_chat_carryover]
258
- data = [
259
- chat_result.summary
260
- for chat_id, chat_result in finished_chats.items()
261
- if chat_id not in finished_chat_indexes_to_exclude_from_carryover
262
- ]
263
- chat_info["carryover"] = _chat_carryover + data
264
- if not chat_info.get("silent", False):
265
- __post_carryover_processing(chat_info)
266
-
267
- sender = chat_info["sender"]
268
- chat_res_future = asyncio.create_task(sender.a_initiate_chat(**chat_info))
269
- call_back_with_args = partial(_on_chat_future_done, chat_id=chat_id)
270
- chat_res_future.add_done_callback(call_back_with_args)
271
- logger.debug(f"Task for chat {chat_id} created." + __system_now_str())
272
- return chat_res_future
273
-
274
-
275
- async def a_initiate_chats(chat_queue: List[Dict[str, Any]]) -> Dict[int, ChatResult]:
276
- """(async) Initiate a list of chats.
277
-
278
- args:
279
- - Please refer to `initiate_chats`.
280
-
281
-
282
- returns:
283
- - (Dict): a dict of ChatId: ChatResult corresponding to the finished chats in the chat_queue.
284
- """
285
- consolidate_chat_info(chat_queue)
286
- _validate_recipients(chat_queue)
287
- chat_book = {chat_info["chat_id"]: chat_info for chat_info in chat_queue}
288
- num_chats = chat_book.keys()
289
- prerequisites = __create_async_prerequisites(chat_queue)
290
- chat_order_by_id = __find_async_chat_order(num_chats, prerequisites)
291
- finished_chat_futures = dict()
292
- for chat_id in chat_order_by_id:
293
- chat_info = chat_book[chat_id]
294
- prerequisite_chat_ids = chat_info.get("prerequisites", [])
295
- pre_chat_futures = dict()
296
- for pre_chat_id in prerequisite_chat_ids:
297
- pre_chat_future = finished_chat_futures[pre_chat_id]
298
- pre_chat_futures[pre_chat_id] = pre_chat_future
299
- current_chat_future = await _dependent_chat_future(chat_id, chat_info, pre_chat_futures)
300
- finished_chat_futures[chat_id] = current_chat_future
301
- await asyncio.gather(*list(finished_chat_futures.values()))
302
- finished_chats = dict()
303
- for chat in finished_chat_futures:
304
- chat_result = finished_chat_futures[chat].result()
305
- finished_chats[chat] = chat_result
306
- return finished_chats
File without changes