ag2 0.9.1a1__py3-none-any.whl → 0.9.1.post0__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 (357) hide show
  1. {ag2-0.9.1a1.dist-info → ag2-0.9.1.post0.dist-info}/METADATA +264 -73
  2. ag2-0.9.1.post0.dist-info/RECORD +392 -0
  3. {ag2-0.9.1a1.dist-info → ag2-0.9.1.post0.dist-info}/WHEEL +1 -2
  4. autogen/__init__.py +89 -0
  5. autogen/_website/__init__.py +3 -0
  6. autogen/_website/generate_api_references.py +427 -0
  7. autogen/_website/generate_mkdocs.py +1174 -0
  8. autogen/_website/notebook_processor.py +476 -0
  9. autogen/_website/process_notebooks.py +656 -0
  10. autogen/_website/utils.py +412 -0
  11. autogen/agentchat/__init__.py +44 -0
  12. autogen/agentchat/agent.py +182 -0
  13. autogen/agentchat/assistant_agent.py +85 -0
  14. autogen/agentchat/chat.py +309 -0
  15. autogen/agentchat/contrib/__init__.py +5 -0
  16. autogen/agentchat/contrib/agent_eval/README.md +7 -0
  17. autogen/agentchat/contrib/agent_eval/agent_eval.py +108 -0
  18. autogen/agentchat/contrib/agent_eval/criterion.py +43 -0
  19. autogen/agentchat/contrib/agent_eval/critic_agent.py +44 -0
  20. autogen/agentchat/contrib/agent_eval/quantifier_agent.py +39 -0
  21. autogen/agentchat/contrib/agent_eval/subcritic_agent.py +45 -0
  22. autogen/agentchat/contrib/agent_eval/task.py +42 -0
  23. autogen/agentchat/contrib/agent_optimizer.py +429 -0
  24. autogen/agentchat/contrib/capabilities/__init__.py +5 -0
  25. autogen/agentchat/contrib/capabilities/agent_capability.py +20 -0
  26. autogen/agentchat/contrib/capabilities/generate_images.py +301 -0
  27. autogen/agentchat/contrib/capabilities/teachability.py +393 -0
  28. autogen/agentchat/contrib/capabilities/text_compressors.py +66 -0
  29. autogen/agentchat/contrib/capabilities/tools_capability.py +22 -0
  30. autogen/agentchat/contrib/capabilities/transform_messages.py +93 -0
  31. autogen/agentchat/contrib/capabilities/transforms.py +566 -0
  32. autogen/agentchat/contrib/capabilities/transforms_util.py +122 -0
  33. autogen/agentchat/contrib/capabilities/vision_capability.py +214 -0
  34. autogen/agentchat/contrib/captainagent/__init__.py +9 -0
  35. autogen/agentchat/contrib/captainagent/agent_builder.py +790 -0
  36. autogen/agentchat/contrib/captainagent/captainagent.py +512 -0
  37. autogen/agentchat/contrib/captainagent/tool_retriever.py +335 -0
  38. autogen/agentchat/contrib/captainagent/tools/README.md +44 -0
  39. autogen/agentchat/contrib/captainagent/tools/__init__.py +5 -0
  40. autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_correlation.py +40 -0
  41. autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_skewness_and_kurtosis.py +28 -0
  42. autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_iqr.py +28 -0
  43. autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_zscore.py +28 -0
  44. autogen/agentchat/contrib/captainagent/tools/data_analysis/explore_csv.py +21 -0
  45. autogen/agentchat/contrib/captainagent/tools/data_analysis/shapiro_wilk_test.py +30 -0
  46. autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py +27 -0
  47. autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py +53 -0
  48. autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_image.py +53 -0
  49. autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_text.py +38 -0
  50. autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_wikipedia_text.py +21 -0
  51. autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_youtube_caption.py +34 -0
  52. autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py +60 -0
  53. autogen/agentchat/contrib/captainagent/tools/information_retrieval/optical_character_recognition.py +61 -0
  54. autogen/agentchat/contrib/captainagent/tools/information_retrieval/perform_web_search.py +47 -0
  55. autogen/agentchat/contrib/captainagent/tools/information_retrieval/scrape_wikipedia_tables.py +33 -0
  56. autogen/agentchat/contrib/captainagent/tools/information_retrieval/transcribe_audio_file.py +21 -0
  57. autogen/agentchat/contrib/captainagent/tools/information_retrieval/youtube_download.py +35 -0
  58. autogen/agentchat/contrib/captainagent/tools/math/calculate_circle_area_from_diameter.py +21 -0
  59. autogen/agentchat/contrib/captainagent/tools/math/calculate_day_of_the_week.py +18 -0
  60. autogen/agentchat/contrib/captainagent/tools/math/calculate_fraction_sum.py +28 -0
  61. autogen/agentchat/contrib/captainagent/tools/math/calculate_matrix_power.py +31 -0
  62. autogen/agentchat/contrib/captainagent/tools/math/calculate_reflected_point.py +16 -0
  63. autogen/agentchat/contrib/captainagent/tools/math/complex_numbers_product.py +25 -0
  64. autogen/agentchat/contrib/captainagent/tools/math/compute_currency_conversion.py +23 -0
  65. autogen/agentchat/contrib/captainagent/tools/math/count_distinct_permutations.py +27 -0
  66. autogen/agentchat/contrib/captainagent/tools/math/evaluate_expression.py +28 -0
  67. autogen/agentchat/contrib/captainagent/tools/math/find_continuity_point.py +34 -0
  68. autogen/agentchat/contrib/captainagent/tools/math/fraction_to_mixed_numbers.py +39 -0
  69. autogen/agentchat/contrib/captainagent/tools/math/modular_inverse_sum.py +23 -0
  70. autogen/agentchat/contrib/captainagent/tools/math/simplify_mixed_numbers.py +36 -0
  71. autogen/agentchat/contrib/captainagent/tools/math/sum_of_digit_factorials.py +15 -0
  72. autogen/agentchat/contrib/captainagent/tools/math/sum_of_primes_below.py +15 -0
  73. autogen/agentchat/contrib/captainagent/tools/requirements.txt +10 -0
  74. autogen/agentchat/contrib/captainagent/tools/tool_description.tsv +34 -0
  75. autogen/agentchat/contrib/gpt_assistant_agent.py +526 -0
  76. autogen/agentchat/contrib/graph_rag/__init__.py +9 -0
  77. autogen/agentchat/contrib/graph_rag/document.py +29 -0
  78. autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +170 -0
  79. autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +103 -0
  80. autogen/agentchat/contrib/graph_rag/graph_query_engine.py +53 -0
  81. autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +63 -0
  82. autogen/agentchat/contrib/graph_rag/neo4j_graph_query_engine.py +268 -0
  83. autogen/agentchat/contrib/graph_rag/neo4j_graph_rag_capability.py +83 -0
  84. autogen/agentchat/contrib/graph_rag/neo4j_native_graph_query_engine.py +210 -0
  85. autogen/agentchat/contrib/graph_rag/neo4j_native_graph_rag_capability.py +93 -0
  86. autogen/agentchat/contrib/img_utils.py +397 -0
  87. autogen/agentchat/contrib/llamaindex_conversable_agent.py +117 -0
  88. autogen/agentchat/contrib/llava_agent.py +187 -0
  89. autogen/agentchat/contrib/math_user_proxy_agent.py +464 -0
  90. autogen/agentchat/contrib/multimodal_conversable_agent.py +125 -0
  91. autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +324 -0
  92. autogen/agentchat/contrib/rag/__init__.py +10 -0
  93. autogen/agentchat/contrib/rag/chromadb_query_engine.py +272 -0
  94. autogen/agentchat/contrib/rag/llamaindex_query_engine.py +198 -0
  95. autogen/agentchat/contrib/rag/mongodb_query_engine.py +329 -0
  96. autogen/agentchat/contrib/rag/query_engine.py +74 -0
  97. autogen/agentchat/contrib/retrieve_assistant_agent.py +56 -0
  98. autogen/agentchat/contrib/retrieve_user_proxy_agent.py +703 -0
  99. autogen/agentchat/contrib/society_of_mind_agent.py +199 -0
  100. autogen/agentchat/contrib/swarm_agent.py +1425 -0
  101. autogen/agentchat/contrib/text_analyzer_agent.py +79 -0
  102. autogen/agentchat/contrib/vectordb/__init__.py +5 -0
  103. autogen/agentchat/contrib/vectordb/base.py +232 -0
  104. autogen/agentchat/contrib/vectordb/chromadb.py +315 -0
  105. autogen/agentchat/contrib/vectordb/couchbase.py +407 -0
  106. autogen/agentchat/contrib/vectordb/mongodb.py +550 -0
  107. autogen/agentchat/contrib/vectordb/pgvectordb.py +928 -0
  108. autogen/agentchat/contrib/vectordb/qdrant.py +320 -0
  109. autogen/agentchat/contrib/vectordb/utils.py +126 -0
  110. autogen/agentchat/contrib/web_surfer.py +303 -0
  111. autogen/agentchat/conversable_agent.py +4020 -0
  112. autogen/agentchat/group/__init__.py +64 -0
  113. autogen/agentchat/group/available_condition.py +91 -0
  114. autogen/agentchat/group/context_condition.py +77 -0
  115. autogen/agentchat/group/context_expression.py +238 -0
  116. autogen/agentchat/group/context_str.py +41 -0
  117. autogen/agentchat/group/context_variables.py +192 -0
  118. autogen/agentchat/group/group_tool_executor.py +202 -0
  119. autogen/agentchat/group/group_utils.py +591 -0
  120. autogen/agentchat/group/handoffs.py +244 -0
  121. autogen/agentchat/group/llm_condition.py +93 -0
  122. autogen/agentchat/group/multi_agent_chat.py +237 -0
  123. autogen/agentchat/group/on_condition.py +58 -0
  124. autogen/agentchat/group/on_context_condition.py +54 -0
  125. autogen/agentchat/group/patterns/__init__.py +18 -0
  126. autogen/agentchat/group/patterns/auto.py +159 -0
  127. autogen/agentchat/group/patterns/manual.py +176 -0
  128. autogen/agentchat/group/patterns/pattern.py +288 -0
  129. autogen/agentchat/group/patterns/random.py +106 -0
  130. autogen/agentchat/group/patterns/round_robin.py +117 -0
  131. autogen/agentchat/group/reply_result.py +26 -0
  132. autogen/agentchat/group/speaker_selection_result.py +41 -0
  133. autogen/agentchat/group/targets/__init__.py +4 -0
  134. autogen/agentchat/group/targets/group_chat_target.py +132 -0
  135. autogen/agentchat/group/targets/group_manager_target.py +151 -0
  136. autogen/agentchat/group/targets/transition_target.py +413 -0
  137. autogen/agentchat/group/targets/transition_utils.py +6 -0
  138. autogen/agentchat/groupchat.py +1694 -0
  139. autogen/agentchat/realtime/__init__.py +3 -0
  140. autogen/agentchat/realtime/experimental/__init__.py +20 -0
  141. autogen/agentchat/realtime/experimental/audio_adapters/__init__.py +8 -0
  142. autogen/agentchat/realtime/experimental/audio_adapters/twilio_audio_adapter.py +148 -0
  143. autogen/agentchat/realtime/experimental/audio_adapters/websocket_audio_adapter.py +139 -0
  144. autogen/agentchat/realtime/experimental/audio_observer.py +42 -0
  145. autogen/agentchat/realtime/experimental/clients/__init__.py +15 -0
  146. autogen/agentchat/realtime/experimental/clients/gemini/__init__.py +7 -0
  147. autogen/agentchat/realtime/experimental/clients/gemini/client.py +274 -0
  148. autogen/agentchat/realtime/experimental/clients/oai/__init__.py +8 -0
  149. autogen/agentchat/realtime/experimental/clients/oai/base_client.py +220 -0
  150. autogen/agentchat/realtime/experimental/clients/oai/rtc_client.py +243 -0
  151. autogen/agentchat/realtime/experimental/clients/oai/utils.py +48 -0
  152. autogen/agentchat/realtime/experimental/clients/realtime_client.py +190 -0
  153. autogen/agentchat/realtime/experimental/function_observer.py +85 -0
  154. autogen/agentchat/realtime/experimental/realtime_agent.py +158 -0
  155. autogen/agentchat/realtime/experimental/realtime_events.py +42 -0
  156. autogen/agentchat/realtime/experimental/realtime_observer.py +100 -0
  157. autogen/agentchat/realtime/experimental/realtime_swarm.py +475 -0
  158. autogen/agentchat/realtime/experimental/websockets.py +21 -0
  159. autogen/agentchat/realtime_agent/__init__.py +21 -0
  160. autogen/agentchat/user_proxy_agent.py +111 -0
  161. autogen/agentchat/utils.py +206 -0
  162. autogen/agents/__init__.py +3 -0
  163. autogen/agents/contrib/__init__.py +10 -0
  164. autogen/agents/contrib/time/__init__.py +8 -0
  165. autogen/agents/contrib/time/time_reply_agent.py +73 -0
  166. autogen/agents/contrib/time/time_tool_agent.py +51 -0
  167. autogen/agents/experimental/__init__.py +27 -0
  168. autogen/agents/experimental/deep_research/__init__.py +7 -0
  169. autogen/agents/experimental/deep_research/deep_research.py +52 -0
  170. autogen/agents/experimental/discord/__init__.py +7 -0
  171. autogen/agents/experimental/discord/discord.py +66 -0
  172. autogen/agents/experimental/document_agent/__init__.py +19 -0
  173. autogen/agents/experimental/document_agent/chroma_query_engine.py +316 -0
  174. autogen/agents/experimental/document_agent/docling_doc_ingest_agent.py +118 -0
  175. autogen/agents/experimental/document_agent/document_agent.py +461 -0
  176. autogen/agents/experimental/document_agent/document_conditions.py +50 -0
  177. autogen/agents/experimental/document_agent/document_utils.py +380 -0
  178. autogen/agents/experimental/document_agent/inmemory_query_engine.py +220 -0
  179. autogen/agents/experimental/document_agent/parser_utils.py +130 -0
  180. autogen/agents/experimental/document_agent/url_utils.py +426 -0
  181. autogen/agents/experimental/reasoning/__init__.py +7 -0
  182. autogen/agents/experimental/reasoning/reasoning_agent.py +1178 -0
  183. autogen/agents/experimental/slack/__init__.py +7 -0
  184. autogen/agents/experimental/slack/slack.py +73 -0
  185. autogen/agents/experimental/telegram/__init__.py +7 -0
  186. autogen/agents/experimental/telegram/telegram.py +77 -0
  187. autogen/agents/experimental/websurfer/__init__.py +7 -0
  188. autogen/agents/experimental/websurfer/websurfer.py +62 -0
  189. autogen/agents/experimental/wikipedia/__init__.py +7 -0
  190. autogen/agents/experimental/wikipedia/wikipedia.py +90 -0
  191. autogen/browser_utils.py +309 -0
  192. autogen/cache/__init__.py +10 -0
  193. autogen/cache/abstract_cache_base.py +75 -0
  194. autogen/cache/cache.py +203 -0
  195. autogen/cache/cache_factory.py +88 -0
  196. autogen/cache/cosmos_db_cache.py +144 -0
  197. autogen/cache/disk_cache.py +102 -0
  198. autogen/cache/in_memory_cache.py +58 -0
  199. autogen/cache/redis_cache.py +123 -0
  200. autogen/code_utils.py +596 -0
  201. autogen/coding/__init__.py +22 -0
  202. autogen/coding/base.py +119 -0
  203. autogen/coding/docker_commandline_code_executor.py +268 -0
  204. autogen/coding/factory.py +47 -0
  205. autogen/coding/func_with_reqs.py +202 -0
  206. autogen/coding/jupyter/__init__.py +23 -0
  207. autogen/coding/jupyter/base.py +36 -0
  208. autogen/coding/jupyter/docker_jupyter_server.py +167 -0
  209. autogen/coding/jupyter/embedded_ipython_code_executor.py +182 -0
  210. autogen/coding/jupyter/import_utils.py +82 -0
  211. autogen/coding/jupyter/jupyter_client.py +231 -0
  212. autogen/coding/jupyter/jupyter_code_executor.py +160 -0
  213. autogen/coding/jupyter/local_jupyter_server.py +172 -0
  214. autogen/coding/local_commandline_code_executor.py +405 -0
  215. autogen/coding/markdown_code_extractor.py +45 -0
  216. autogen/coding/utils.py +56 -0
  217. autogen/doc_utils.py +34 -0
  218. autogen/events/__init__.py +7 -0
  219. autogen/events/agent_events.py +1010 -0
  220. autogen/events/base_event.py +99 -0
  221. autogen/events/client_events.py +167 -0
  222. autogen/events/helpers.py +36 -0
  223. autogen/events/print_event.py +46 -0
  224. autogen/exception_utils.py +73 -0
  225. autogen/extensions/__init__.py +5 -0
  226. autogen/fast_depends/__init__.py +16 -0
  227. autogen/fast_depends/_compat.py +80 -0
  228. autogen/fast_depends/core/__init__.py +14 -0
  229. autogen/fast_depends/core/build.py +225 -0
  230. autogen/fast_depends/core/model.py +576 -0
  231. autogen/fast_depends/dependencies/__init__.py +15 -0
  232. autogen/fast_depends/dependencies/model.py +29 -0
  233. autogen/fast_depends/dependencies/provider.py +39 -0
  234. autogen/fast_depends/library/__init__.py +10 -0
  235. autogen/fast_depends/library/model.py +46 -0
  236. autogen/fast_depends/py.typed +6 -0
  237. autogen/fast_depends/schema.py +66 -0
  238. autogen/fast_depends/use.py +280 -0
  239. autogen/fast_depends/utils.py +187 -0
  240. autogen/formatting_utils.py +83 -0
  241. autogen/function_utils.py +13 -0
  242. autogen/graph_utils.py +178 -0
  243. autogen/import_utils.py +526 -0
  244. autogen/interop/__init__.py +22 -0
  245. autogen/interop/crewai/__init__.py +7 -0
  246. autogen/interop/crewai/crewai.py +88 -0
  247. autogen/interop/interoperability.py +71 -0
  248. autogen/interop/interoperable.py +46 -0
  249. autogen/interop/langchain/__init__.py +8 -0
  250. autogen/interop/langchain/langchain_chat_model_factory.py +155 -0
  251. autogen/interop/langchain/langchain_tool.py +82 -0
  252. autogen/interop/litellm/__init__.py +7 -0
  253. autogen/interop/litellm/litellm_config_factory.py +113 -0
  254. autogen/interop/pydantic_ai/__init__.py +7 -0
  255. autogen/interop/pydantic_ai/pydantic_ai.py +168 -0
  256. autogen/interop/registry.py +69 -0
  257. autogen/io/__init__.py +15 -0
  258. autogen/io/base.py +151 -0
  259. autogen/io/console.py +56 -0
  260. autogen/io/processors/__init__.py +12 -0
  261. autogen/io/processors/base.py +21 -0
  262. autogen/io/processors/console_event_processor.py +56 -0
  263. autogen/io/run_response.py +293 -0
  264. autogen/io/thread_io_stream.py +63 -0
  265. autogen/io/websockets.py +213 -0
  266. autogen/json_utils.py +43 -0
  267. autogen/llm_config.py +379 -0
  268. autogen/logger/__init__.py +11 -0
  269. autogen/logger/base_logger.py +128 -0
  270. autogen/logger/file_logger.py +261 -0
  271. autogen/logger/logger_factory.py +42 -0
  272. autogen/logger/logger_utils.py +57 -0
  273. autogen/logger/sqlite_logger.py +523 -0
  274. autogen/math_utils.py +339 -0
  275. autogen/mcp/__init__.py +7 -0
  276. autogen/mcp/mcp_client.py +208 -0
  277. autogen/messages/__init__.py +7 -0
  278. autogen/messages/agent_messages.py +948 -0
  279. autogen/messages/base_message.py +107 -0
  280. autogen/messages/client_messages.py +171 -0
  281. autogen/messages/print_message.py +49 -0
  282. autogen/oai/__init__.py +53 -0
  283. autogen/oai/anthropic.py +714 -0
  284. autogen/oai/bedrock.py +628 -0
  285. autogen/oai/cerebras.py +299 -0
  286. autogen/oai/client.py +1435 -0
  287. autogen/oai/client_utils.py +169 -0
  288. autogen/oai/cohere.py +479 -0
  289. autogen/oai/gemini.py +990 -0
  290. autogen/oai/gemini_types.py +129 -0
  291. autogen/oai/groq.py +305 -0
  292. autogen/oai/mistral.py +303 -0
  293. autogen/oai/oai_models/__init__.py +11 -0
  294. autogen/oai/oai_models/_models.py +16 -0
  295. autogen/oai/oai_models/chat_completion.py +87 -0
  296. autogen/oai/oai_models/chat_completion_audio.py +32 -0
  297. autogen/oai/oai_models/chat_completion_message.py +86 -0
  298. autogen/oai/oai_models/chat_completion_message_tool_call.py +37 -0
  299. autogen/oai/oai_models/chat_completion_token_logprob.py +63 -0
  300. autogen/oai/oai_models/completion_usage.py +60 -0
  301. autogen/oai/ollama.py +643 -0
  302. autogen/oai/openai_utils.py +881 -0
  303. autogen/oai/together.py +370 -0
  304. autogen/retrieve_utils.py +491 -0
  305. autogen/runtime_logging.py +160 -0
  306. autogen/token_count_utils.py +267 -0
  307. autogen/tools/__init__.py +20 -0
  308. autogen/tools/contrib/__init__.py +9 -0
  309. autogen/tools/contrib/time/__init__.py +7 -0
  310. autogen/tools/contrib/time/time.py +41 -0
  311. autogen/tools/dependency_injection.py +254 -0
  312. autogen/tools/experimental/__init__.py +43 -0
  313. autogen/tools/experimental/browser_use/__init__.py +7 -0
  314. autogen/tools/experimental/browser_use/browser_use.py +161 -0
  315. autogen/tools/experimental/crawl4ai/__init__.py +7 -0
  316. autogen/tools/experimental/crawl4ai/crawl4ai.py +153 -0
  317. autogen/tools/experimental/deep_research/__init__.py +7 -0
  318. autogen/tools/experimental/deep_research/deep_research.py +328 -0
  319. autogen/tools/experimental/duckduckgo/__init__.py +7 -0
  320. autogen/tools/experimental/duckduckgo/duckduckgo_search.py +109 -0
  321. autogen/tools/experimental/google/__init__.py +14 -0
  322. autogen/tools/experimental/google/authentication/__init__.py +11 -0
  323. autogen/tools/experimental/google/authentication/credentials_hosted_provider.py +43 -0
  324. autogen/tools/experimental/google/authentication/credentials_local_provider.py +91 -0
  325. autogen/tools/experimental/google/authentication/credentials_provider.py +35 -0
  326. autogen/tools/experimental/google/drive/__init__.py +9 -0
  327. autogen/tools/experimental/google/drive/drive_functions.py +124 -0
  328. autogen/tools/experimental/google/drive/toolkit.py +88 -0
  329. autogen/tools/experimental/google/model.py +17 -0
  330. autogen/tools/experimental/google/toolkit_protocol.py +19 -0
  331. autogen/tools/experimental/google_search/__init__.py +8 -0
  332. autogen/tools/experimental/google_search/google_search.py +93 -0
  333. autogen/tools/experimental/google_search/youtube_search.py +181 -0
  334. autogen/tools/experimental/messageplatform/__init__.py +17 -0
  335. autogen/tools/experimental/messageplatform/discord/__init__.py +7 -0
  336. autogen/tools/experimental/messageplatform/discord/discord.py +288 -0
  337. autogen/tools/experimental/messageplatform/slack/__init__.py +7 -0
  338. autogen/tools/experimental/messageplatform/slack/slack.py +391 -0
  339. autogen/tools/experimental/messageplatform/telegram/__init__.py +7 -0
  340. autogen/tools/experimental/messageplatform/telegram/telegram.py +275 -0
  341. autogen/tools/experimental/perplexity/__init__.py +7 -0
  342. autogen/tools/experimental/perplexity/perplexity_search.py +260 -0
  343. autogen/tools/experimental/tavily/__init__.py +7 -0
  344. autogen/tools/experimental/tavily/tavily_search.py +183 -0
  345. autogen/tools/experimental/web_search_preview/__init__.py +7 -0
  346. autogen/tools/experimental/web_search_preview/web_search_preview.py +114 -0
  347. autogen/tools/experimental/wikipedia/__init__.py +7 -0
  348. autogen/tools/experimental/wikipedia/wikipedia.py +287 -0
  349. autogen/tools/function_utils.py +411 -0
  350. autogen/tools/tool.py +187 -0
  351. autogen/tools/toolkit.py +86 -0
  352. autogen/types.py +29 -0
  353. autogen/version.py +7 -0
  354. ag2-0.9.1a1.dist-info/RECORD +0 -6
  355. ag2-0.9.1a1.dist-info/top_level.txt +0 -1
  356. {ag2-0.9.1a1.dist-info → ag2-0.9.1.post0.dist-info/licenses}/LICENSE +0 -0
  357. {ag2-0.9.1a1.dist-info → ag2-0.9.1.post0.dist-info/licenses}/NOTICE.md +0 -0
@@ -0,0 +1,335 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
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 contextlib
8
+ import functools
9
+ import importlib.util
10
+ import inspect
11
+ import io
12
+ import os
13
+ import traceback
14
+ from hashlib import md5
15
+ from pathlib import Path
16
+ from textwrap import dedent, indent
17
+ from typing import Optional, Union
18
+
19
+ from .... import AssistantAgent, UserProxyAgent
20
+ from ....coding import CodeExecutor, CodeExtractor, LocalCommandLineCodeExecutor, MarkdownCodeExtractor
21
+ from ....coding.base import CodeBlock, CodeResult
22
+ from ....doc_utils import export_module
23
+ from ....import_utils import optional_import_block, require_optional_import
24
+ from ....tools import Tool, get_function_schema, load_basemodels_if_needed
25
+
26
+ with optional_import_block():
27
+ import pandas as pd
28
+ from sentence_transformers import SentenceTransformer, util
29
+
30
+
31
+ @require_optional_import(["pandas", "sentence_transformers"], "retrievechat")
32
+ @export_module("autogen.agentchat.contrib.captainagent")
33
+ class ToolBuilder:
34
+ TOOL_PROMPT_DEFAULT = """\n## Functions
35
+ You have access to the following functions. They can be accessed from the module called 'functions' by their function names.
36
+ For example, if there is a function called `foo` you could import it by writing `from functions import foo`
37
+ {functions}
38
+ """
39
+ TOOL_PROMPT_USER_DEFINED = """\n## Functions
40
+ You have access to the following functions. You can write python code to call these functions directly without importing them.
41
+ {functions}
42
+ """
43
+
44
+ def __init__(self, corpus_root, retriever="all-mpnet-base-v2", type="default"):
45
+ if type == "default":
46
+ corpus_path = os.path.join(corpus_root, "tool_description.tsv")
47
+ self.df = pd.read_csv(corpus_path, sep="\t")
48
+ document_list = self.df["document_content"].tolist()
49
+ self.TOOL_PROMPT = self.TOOL_PROMPT_DEFAULT
50
+ else:
51
+ self.TOOL_PROMPT = self.TOOL_PROMPT_USER_DEFINED
52
+ # user defined tools, retrieve is actually not needed, just for consistency
53
+ document_list = []
54
+ for tool in corpus_root:
55
+ document_list.append(tool.description)
56
+
57
+ self.model = SentenceTransformer(retriever)
58
+ self.embeddings = self.model.encode(document_list)
59
+ self.type = type
60
+
61
+ def retrieve(self, query, top_k=3):
62
+ # Encode the query using the Sentence Transformer model
63
+ query_embedding = self.model.encode([query])
64
+
65
+ hits = util.semantic_search(query_embedding, self.embeddings, top_k=top_k)
66
+
67
+ results = []
68
+ for hit in hits[0]:
69
+ results.append(self.df.iloc[hit["corpus_id"], 1])
70
+ return results
71
+
72
+ def bind(self, agent: AssistantAgent, functions: str):
73
+ """Binds the function to the agent so that agent is aware of it."""
74
+ sys_message = agent.system_message
75
+ sys_message += self.TOOL_PROMPT.format(functions=functions)
76
+ agent.update_system_message(sys_message)
77
+ return
78
+
79
+ def bind_user_proxy(self, agent: UserProxyAgent, tool_root: Union[str, list]):
80
+ """Updates user proxy agent with a executor so that code executor can successfully execute function-related code.
81
+ Returns an updated user proxy.
82
+ """
83
+ if isinstance(tool_root, str):
84
+ # Find all the functions in the tool root
85
+ functions = find_callables(tool_root)
86
+
87
+ code_execution_config = agent._code_execution_config
88
+ executor = LocalCommandLineCodeExecutor(
89
+ timeout=code_execution_config.get("timeout", 180),
90
+ work_dir=code_execution_config.get("work_dir", "coding"),
91
+ functions=functions,
92
+ )
93
+ code_execution_config = {
94
+ "executor": executor,
95
+ "last_n_messages": code_execution_config.get("last_n_messages", 1),
96
+ }
97
+ updated_user_proxy = UserProxyAgent(
98
+ name=agent.name,
99
+ is_termination_msg=agent._is_termination_msg,
100
+ code_execution_config=code_execution_config,
101
+ human_input_mode="NEVER",
102
+ default_auto_reply=agent._default_auto_reply,
103
+ )
104
+ return updated_user_proxy
105
+ else:
106
+ # second case: user defined tools
107
+ code_execution_config = agent._code_execution_config
108
+ executor = LocalExecutorWithTools(
109
+ tools=tool_root,
110
+ work_dir=code_execution_config.get("work_dir", "coding"),
111
+ )
112
+ code_execution_config = {
113
+ "executor": executor,
114
+ "last_n_messages": code_execution_config.get("last_n_messages", 1),
115
+ }
116
+ updated_user_proxy = UserProxyAgent(
117
+ name=agent.name,
118
+ is_termination_msg=agent._is_termination_msg,
119
+ code_execution_config=code_execution_config,
120
+ human_input_mode="NEVER",
121
+ default_auto_reply=agent._default_auto_reply,
122
+ )
123
+ return updated_user_proxy
124
+
125
+
126
+ class LocalExecutorWithTools(CodeExecutor):
127
+ """An executor that executes code blocks with injected tools. In this executor, the func within the tools can be called directly without declaring in the code block.
128
+
129
+ For example, for a tool converted from langchain, the relevant functions can be called directly.
130
+ ```python
131
+ from langchain_community.tools import WikipediaQueryRun
132
+ from langchain_community.utilities import WikipediaAPIWrapper
133
+ from autogen.interop import Interoperability
134
+
135
+ api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=3000)
136
+ langchain_tool = WikipediaQueryRun(api_wrapper=api_wrapper)
137
+ interop = Interoperability()
138
+ ag2_tool = interop.convert_tool(tool=langchain_tool, type="langchain")
139
+
140
+ # `ag2_tool.name` is wikipedia
141
+ local_executor = LocalExecutorWithTools(tools=[ag2_tool], work_dir="./")
142
+
143
+ code = '''
144
+ result = wikipedia(tool_input={"query":"Christmas"})
145
+ print(result)
146
+ '''
147
+ print(
148
+ local_executor.execute_code_blocks(
149
+ code_blocks=[
150
+ CodeBlock(language="python", code=code),
151
+ ]
152
+ )
153
+ )
154
+ ```
155
+ In this case, the `wikipedia` function can be called directly in the code block. This hides the complexity of the tool.
156
+
157
+ Args:
158
+ tools: The tools to inject into the code execution environment. Default is an empty list.
159
+ work_dir: The working directory for the code execution. Default is the current directory.
160
+ """
161
+
162
+ @property
163
+ def code_extractor(self) -> CodeExtractor:
164
+ """(Experimental) Export a code extractor that can be used by an agent."""
165
+ return MarkdownCodeExtractor()
166
+
167
+ def __init__(self, tools: Optional[list[Tool]] = None, work_dir: Union[Path, str] = Path()):
168
+ self.tools = tools if tools is not None else []
169
+ self.work_dir = work_dir
170
+ if not os.path.exists(work_dir):
171
+ os.makedirs(work_dir, exist_ok=True)
172
+
173
+ def execute_code_blocks(self, code_blocks: list[CodeBlock]) -> CodeResult:
174
+ """Execute code blocks and return the result.
175
+
176
+ Args:
177
+ code_blocks (List[CodeBlock]): The code blocks to execute.
178
+
179
+ Returns:
180
+ CodeResult: The result of the code execution.
181
+ """
182
+ logs_all = ""
183
+ exit_code = 0 # Success code
184
+ code_file = None # Path to the first saved codeblock content
185
+
186
+ for idx, code_block in enumerate(code_blocks):
187
+ code = code_block.code
188
+ code_hash = md5(code.encode()).hexdigest()
189
+ filename = f"tmp_code_{code_hash}.py"
190
+ filepath = os.path.join(self.work_dir, filename)
191
+ # Save code content to file
192
+ with open(filepath, "w", encoding="utf-8") as f:
193
+ f.write(code)
194
+
195
+ if idx == 0:
196
+ code_file = filepath
197
+
198
+ # Create a new execution environment
199
+ execution_env = {}
200
+ # Inject the tools
201
+ for tool in self.tools:
202
+ execution_env[tool.name] = _wrap_function(tool.func)
203
+
204
+ # Prepare to capture stdout and stderr
205
+ stdout = io.StringIO()
206
+ stderr = io.StringIO()
207
+
208
+ # Execute the code block
209
+ try:
210
+ # Redirect stdout and stderr
211
+ with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
212
+ # Exec the code in the execution environment
213
+ exec(code, execution_env)
214
+ except Exception:
215
+ # Capture exception traceback
216
+ tb = traceback.format_exc()
217
+ stderr.write(tb)
218
+ exit_code = 1 # Non-zero exit code indicates failure
219
+
220
+ # Collect outputs
221
+ stdout_content = stdout.getvalue()
222
+ stderr_content = stderr.getvalue()
223
+ logs_all += stdout_content + stderr_content
224
+
225
+ return CodeResult(exit_code=exit_code, output=logs_all, code_file=code_file)
226
+
227
+ def restart(self):
228
+ """Restart the code executor. Since this executor is stateless, no action is needed."""
229
+ pass
230
+
231
+
232
+ @export_module("autogen.agentchat.contrib.captainagent")
233
+ def format_ag2_tool(tool: Tool):
234
+ # get the args first
235
+ schema = get_function_schema(tool.func, description=tool.description)
236
+
237
+ arg_name = list(inspect.signature(tool.func).parameters.keys())[0]
238
+ arg_info = schema["function"]["parameters"]["properties"][arg_name]["properties"]
239
+
240
+ content = f'def {tool.name}({arg_name}):\n """\n'
241
+ content += indent(tool.description, " ") + "\n"
242
+ content += (
243
+ indent(
244
+ f"You must format all the arguments into a dictionary and pass them as **kwargs to {arg_name}. You should use print function to get the results.",
245
+ " ",
246
+ )
247
+ + "\n"
248
+ + indent(f"For example:\n\tresult = {tool.name}({arg_name}={{'arg1': 'value1' }})", " ")
249
+ + "\n"
250
+ )
251
+ content += indent(f"Arguments passed in {arg_name}:\n", " ")
252
+ for arg, info in arg_info.items():
253
+ content += indent(f"{arg} ({info['type']}): {info['description']}\n", " " * 2)
254
+ content += ' """\n'
255
+ return content
256
+
257
+
258
+ def _wrap_function(func):
259
+ """Wrap the function to dump the return value to json.
260
+
261
+ Handles both sync and async functions.
262
+
263
+ Args:
264
+ func: the function to be wrapped.
265
+
266
+ Returns:
267
+ The wrapped function.
268
+ """
269
+
270
+ @load_basemodels_if_needed
271
+ @functools.wraps(func)
272
+ def _wrapped_func(*args, **kwargs):
273
+ return func(*args, **kwargs)
274
+
275
+ return _wrapped_func
276
+
277
+
278
+ @export_module("autogen.agentchat.contrib.captainagent")
279
+ def get_full_tool_description(py_file):
280
+ """Retrieves the function signature for a given Python file."""
281
+ with open(py_file) as f:
282
+ code = f.read()
283
+ exec(code)
284
+ function_name = os.path.splitext(os.path.basename(py_file))[0]
285
+ if function_name in locals():
286
+ func = locals()[function_name]
287
+ content = f"def {func.__name__}{inspect.signature(func)}:\n"
288
+ docstring = func.__doc__
289
+
290
+ if docstring:
291
+ docstring = dedent(docstring)
292
+ docstring = '"""' + docstring + '"""'
293
+ docstring = indent(docstring, " ")
294
+ content += docstring + "\n"
295
+ return content
296
+ else:
297
+ raise ValueError(f"Function {function_name} not found in {py_file}")
298
+
299
+
300
+ def _wrap_function(func):
301
+ """Wrap the function to dump the return value to json.
302
+
303
+ Handles both sync and async functions.
304
+
305
+ Args:
306
+ func: the function to be wrapped.
307
+
308
+ Returns:
309
+ The wrapped function.
310
+ """
311
+
312
+ @load_basemodels_if_needed
313
+ @functools.wraps(func)
314
+ def _wrapped_func(*args, **kwargs):
315
+ return func(*args, **kwargs)
316
+
317
+ return _wrapped_func
318
+
319
+
320
+ def find_callables(directory):
321
+ """Find all callable objects defined in Python files within the specified directory."""
322
+ callables = []
323
+ for root, dirs, files in os.walk(directory):
324
+ for file in files:
325
+ if file.endswith(".py"):
326
+ module_name = os.path.splitext(file)[0]
327
+ module_path = os.path.join(root, file)
328
+ spec = importlib.util.spec_from_file_location(module_name, module_path)
329
+ module = importlib.util.module_from_spec(spec)
330
+ spec.loader.exec_module(module)
331
+ for name, value in module.__dict__.items():
332
+ if callable(value) and name == module_name:
333
+ callables.append(value)
334
+ break
335
+ return callables
@@ -0,0 +1,44 @@
1
+ # Introduction
2
+
3
+ This directory contains a library of manually created python tools. These tools have three categories: math, data_analysis and information_retrieval.
4
+
5
+ # Directory Layout
6
+ ```
7
+ tools
8
+ ├── README.md
9
+ ├── data_analysis
10
+ │ ├── calculate_correlation.py
11
+ │ └── ...
12
+ ├── information_retrieval
13
+ │ ├── arxiv_download.py
14
+ │ ├── arxiv_search.py
15
+ │ └── ...
16
+ ├── math
17
+ │ ├── calculate_circle_area_from_diameter.py
18
+ │ └── ...
19
+ └── tool_description.tsv
20
+ ```
21
+
22
+ Tools can be imported from `tools/{category}/{tool_name}.py` with exactly the same function name.
23
+
24
+ `tool_description.tsv` contains descriptions of tools for retrieval.
25
+
26
+ # How to use
27
+ Some tools require Bing Search API key and RapidAPI key. For Bing API, you can read more about how to get an API on the [Bing Web Search API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api) page. For RapidAPI, you can [sign up](https://rapidapi.com/auth/sign-up) and subscribe to these two links([link1](https://rapidapi.com/solid-api-solid-api-default/api/youtube-transcript3), [link2](https://rapidapi.com/420vijay47/api/youtube-mp3-downloader2)). These apis have free billing options and there is no need to worry about extra costs.
28
+
29
+ To install the requirements for running tools, use pip install.
30
+ ```bash
31
+ pip install -r autogen/agentchat/contrib/captainagent/tools/requirements.txt
32
+ ```
33
+
34
+ Whenever you run the tool-related code, remember to export the api keys to system variables.
35
+ ```bash
36
+ export BING_API_KEY=""
37
+ export RAPID_API_KEY=""
38
+ ```
39
+ or
40
+ ```python
41
+ import os
42
+ os.environ["BING_API_KEY"] = ""
43
+ os.environ["RAPID_API_KEY"] = ""
44
+ ```
@@ -0,0 +1,5 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ __all__: list[str] = []
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ def calculate_correlation(csv_path: str, column1: str, column2: str, method: str = "pearson") -> float:
5
+ """Calculate the correlation between two columns in a CSV file.
6
+
7
+ Args:
8
+ csv_path (str): The path to the CSV file.
9
+ column1 (str): The name of the first column.
10
+ column2 (str): The name of the second column.
11
+ method (str or callable, optional): The method used to calculate the correlation.
12
+ - 'pearson' (default): Pearson correlation coefficient.
13
+ - 'kendall': Kendall Tau correlation coefficient.
14
+ - 'spearman': Spearman rank correlation coefficient.
15
+ - callable: A custom correlation function that takes two arrays and returns a scalar.
16
+
17
+ Returns:
18
+ float: The correlation coefficient between the two columns.
19
+ """
20
+ import pandas as pd
21
+
22
+ # Read the CSV file into a pandas DataFrame
23
+ df = pd.read_csv(csv_path)
24
+
25
+ # Select the specified columns
26
+ selected_columns = df[[column1, column2]]
27
+
28
+ # Calculate the correlation based on the specified method
29
+ if method == "pearson":
30
+ correlation = selected_columns.corr().iloc[0, 1]
31
+ elif method == "kendall":
32
+ correlation = selected_columns.corr(method="kendall").iloc[0, 1]
33
+ elif method == "spearman":
34
+ correlation = selected_columns.corr(method="spearman").iloc[0, 1]
35
+ elif callable(method):
36
+ correlation = selected_columns.corr(method=method).iloc[0, 1]
37
+ else:
38
+ raise ValueError("Invalid correlation method. Please choose 'pearson', 'kendall', 'spearman', or a callable.")
39
+
40
+ return correlation
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ def calculate_skewness_and_kurtosis(csv_file: str, column_name: str) -> tuple:
5
+ """Calculate the skewness and kurtosis of a specified column in a CSV file. The kurtosis is calculated using the Fisher definition.
6
+ The two metrics are computed using scipy.stats functions.
7
+
8
+ Args:
9
+ csv_file (str): The path to the CSV file.
10
+ column_name (str): The name of the column to calculate skewness and kurtosis for.
11
+
12
+ Returns:
13
+ tuple: (skewness, kurtosis)
14
+ """
15
+ import pandas as pd
16
+ from scipy.stats import kurtosis, skew
17
+
18
+ # Read the CSV file into a pandas DataFrame
19
+ df = pd.read_csv(csv_file)
20
+
21
+ # Extract the specified column
22
+ column = df[column_name]
23
+
24
+ # Calculate the skewness and kurtosis
25
+ skewness = skew(column)
26
+ kurt = kurtosis(column)
27
+
28
+ return skewness, kurt
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ def detect_outlier_iqr(csv_file: str, column_name: str):
5
+ """Detect outliers in a specified column of a CSV file using the IQR method.
6
+
7
+ Args:
8
+ csv_file (str): The path to the CSV file.
9
+ column_name (str): The name of the column to detect outliers in.
10
+
11
+ Returns:
12
+ list: A list of row indices that correspond to the outliers.
13
+ """
14
+ import pandas as pd
15
+
16
+ # Read the CSV file into a pandas DataFrame
17
+ df = pd.read_csv(csv_file)
18
+
19
+ # Calculate the quartiles and IQR for the specified column
20
+ q1 = df[column_name].quantile(0.25)
21
+ q3 = df[column_name].quantile(0.75)
22
+ iqr = q3 - q1
23
+
24
+ # Find the outliers based on the defined criteria
25
+ outliers = df[(df[column_name] < q1 - 1.5 * iqr) | (df[column_name] > q3 + 1.5 * iqr)]
26
+
27
+ # Return the row indices of the outliers
28
+ return outliers.index.tolist()
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ def detect_outlier_zscore(csv_file, column_name, threshold=3):
5
+ """Detect outliers in a CSV file based on a specified column. The outliers are determined by calculating the z-score of the data points in the column.
6
+
7
+ Args:
8
+ csv_file (str): The path to the CSV file.
9
+ column_name (str): The name of the column to calculate z-scores for.
10
+ threshold (float, optional): The threshold value for determining outliers. By default set to 3.
11
+
12
+ Returns:
13
+ list: A list of row indices where the z-score is above the threshold.
14
+ """
15
+ import numpy as np
16
+ import pandas as pd
17
+
18
+ # Read the CSV file into a pandas DataFrame
19
+ df = pd.read_csv(csv_file)
20
+
21
+ # Calculate the z-score for the specified column
22
+ z_scores = np.abs((df[column_name] - df[column_name].mean()) / df[column_name].std())
23
+
24
+ # Find the row indices where the z-score is above the threshold
25
+ outlier_indices = np.where(z_scores > threshold)[0]
26
+
27
+ # Return the row indices of the outliers
28
+ return outlier_indices
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ def explore_csv(file_path, num_lines=5):
5
+ """Reads a CSV file and prints the column names, shape, data types, and the first few lines of data.
6
+
7
+ Args:
8
+ file_path (str): The path to the CSV file.
9
+ num_lines (int, optional): The number of lines to print. Defaults to 5.
10
+ """
11
+ import pandas as pd
12
+
13
+ df = pd.read_csv(file_path)
14
+ header = df.columns
15
+ print("Columns:")
16
+ print(", ".join(header))
17
+ print("Shape:", df.shape)
18
+ print("Data Types:")
19
+ print(df.dtypes)
20
+ print("First", num_lines, "lines:")
21
+ print(df.head(num_lines))
@@ -0,0 +1,30 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ from autogen.coding.func_with_reqs import with_requirements
5
+
6
+
7
+ @with_requirements(["pandas", "scipy"])
8
+ def shapiro_wilk_test(csv_file, column_name):
9
+ """Perform the Shapiro-Wilk test on a specified column of a CSV file.
10
+
11
+ Args:
12
+ csv_file (str): The path to the CSV file.
13
+ column_name (str): The name of the column to perform the test on.
14
+
15
+ Returns:
16
+ float: The p-value resulting from the Shapiro-Wilk test.
17
+ """
18
+ import pandas as pd
19
+ from scipy.stats import shapiro
20
+
21
+ # Read the CSV file into a pandas DataFrame
22
+ df = pd.read_csv(csv_file)
23
+
24
+ # Extract the specified column as a numpy array
25
+ column_data = df[column_name].values
26
+
27
+ # Perform the Shapiro-Wilk test
28
+ _, p_value = shapiro(column_data)
29
+
30
+ return p_value
@@ -0,0 +1,27 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+
6
+ from autogen.coding.func_with_reqs import with_requirements
7
+
8
+
9
+ @with_requirements(["arxiv"])
10
+ def arxiv_download(id_list: list[str], download_dir="./") -> list[str]:
11
+ """Downloads PDF files from ArXiv based on a list of arxiv paper IDs.
12
+
13
+ Args:
14
+ id_list (list): A list of paper IDs to download. e.g. [2302.00006v1]
15
+ download_dir (str, optional): The directory to save the downloaded PDF files. Defaults to './'.
16
+
17
+ Returns:
18
+ list: A list of paths to the downloaded PDF files.
19
+ """
20
+ import arxiv
21
+
22
+ paths = []
23
+ for paper in arxiv.Client().results(arxiv.Search(id_list=id_list)):
24
+ path = paper.download_pdf(download_dir, filename=paper.get_short_id() + ".pdf")
25
+ paths.append(path)
26
+ print("Paper id:", paper.get_short_id(), "Downloaded to:", path)
27
+ return paths
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2023 - 2025, AG2ai, Inc., AG2ai open-source projects maintainers and core contributors
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+
6
+ from autogen.coding.func_with_reqs import with_requirements
7
+
8
+
9
+ @with_requirements(["arxiv"])
10
+ def arxiv_search(query, max_results=10, sortby="relevance"):
11
+ """Search for articles on arXiv based on the given query.
12
+
13
+ Args:
14
+ query (str): The search query.
15
+ max_results (int, optional): The maximum number of results to retrieve. Defaults to 10.
16
+ sortby (str, optional): The sorting criterion for the search results. Can be 'relevance' or 'submittedDate'. Defaults to 'relevance'.
17
+
18
+ Returns:
19
+ list: A list of dictionaries containing information about the search results. Each dictionary contains the following keys:
20
+ - 'title': The title of the article.
21
+ - 'authors': The authors of the article.
22
+ - 'summary': The summary of the article.
23
+ - 'entry_id': The entry ID of the article.
24
+ - 'doi': The DOI of the article (If applicable).
25
+ - 'published': The publication date of the article in the format 'Y-M'.
26
+ """
27
+ import arxiv
28
+
29
+ def get_author(r):
30
+ return ", ".join(a.name for a in r.authors)
31
+
32
+ criterion = {"relevance": arxiv.SortCriterion.Relevance, "submittedDate": arxiv.SortCriterion.SubmittedDate}[sortby]
33
+
34
+ client = arxiv.Client()
35
+ search = arxiv.Search(query=query, max_results=max_results, sort_by=criterion)
36
+ res = []
37
+ results = client.results(search)
38
+ for r in results:
39
+ print("Entry id:", r.entry_id)
40
+ print("Title:", r.title)
41
+ print("Authors:", get_author(r))
42
+ print("DOI:", r.doi)
43
+ print("Published:", r.published.strftime("%Y-%m"))
44
+ # print("Summary:", r.summary)
45
+ res.append({
46
+ "title": r.title,
47
+ "authors": get_author(r),
48
+ "summary": r.summary,
49
+ "entry_id": r.entry_id,
50
+ "doi": r.doi,
51
+ "published": r.published.strftime("%Y-%m"),
52
+ })
53
+ return res