From 03c97b541db92d9606b678af4509897afc7d718a Mon Sep 17 00:00:00 2001 From: Gabriel Fior Date: Wed, 11 Dec 2024 16:59:24 -0300 Subject: [PATCH] Social agent using autogen 0.4 (#593) * Code compiling, tweet still not great * Using MagenticOne as group chat * Fixing CI --- poetry.lock | 180 +++++++++++------- .../agents/social_media_agent/social_agent.py | 124 ++++-------- pyproject.toml | 5 +- 3 files changed, 147 insertions(+), 162 deletions(-) diff --git a/poetry.lock b/poetry.lock index 624a6cf4..8b6fd932 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,19 @@ # This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. +[[package]] +name = "aioconsole" +version = "0.8.1" +description = "Asynchronous console and interfaces for asyncio" +optional = false +python-versions = ">=3.8" +files = [ + {file = "aioconsole-0.8.1-py3-none-any.whl", hash = "sha256:e1023685cde35dde909fbf00631ffb2ed1c67fe0b7058ebb0892afbde5f213e5"}, + {file = "aioconsole-0.8.1.tar.gz", hash = "sha256:0535ce743ba468fb21a1ba43c9563032c779534d4ecd923a46dbd350ad91d234"}, +] + +[package.extras] +dev = ["pytest", "pytest-asyncio", "pytest-cov", "pytest-repeat", "uvloop"] + [[package]] name = "aiohappyeyeballs" version = "2.4.4" @@ -326,33 +340,33 @@ tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} [[package]] name = "autogen-agentchat" -version = "0.4.0.dev8" +version = "0.4.0.dev11" description = "AutoGen agents and teams library" optional = false python-versions = ">=3.10" files = [ - {file = "autogen_agentchat-0.4.0.dev8-py3-none-any.whl", hash = "sha256:fca88e287d5bbd430e28ad35f3c28c206599664c06be0ca5c509ba1a1a157625"}, - {file = "autogen_agentchat-0.4.0.dev8.tar.gz", hash = "sha256:e7064ae437cd646b16f98fe268e38a851c86885856f291b7aa36c47a41a42632"}, + {file = "autogen_agentchat-0.4.0.dev11-py3-none-any.whl", hash = "sha256:f53d5226b8bd2fa069e48e6481a5e6fa9b1620daa5b60161f5f4423d4efa85d5"}, + {file = "autogen_agentchat-0.4.0.dev11.tar.gz", hash = "sha256:d19091afb9f19f8a3ae7b91b88e5269cea39c696a9dde3b7b95b85f70343f0f3"}, ] [package.dependencies] -autogen-core = "0.4.0.dev8" +autogen-core = "0.4.0.dev11" [[package]] name = "autogen-core" -version = "0.4.0.dev8" +version = "0.4.0.dev11" description = "Foundational interfaces and agent runtime implementation for AutoGen" optional = false python-versions = ">=3.10" files = [ - {file = "autogen_core-0.4.0.dev8-py3-none-any.whl", hash = "sha256:812097bbde0d51044b26c8a79c158efc7d74487785752e0b215912cecc591789"}, - {file = "autogen_core-0.4.0.dev8.tar.gz", hash = "sha256:b2ced3fff6094cd5bfbb4cd21948d18174cf811aad97ae36b46e40de34ef2efc"}, + {file = "autogen_core-0.4.0.dev11-py3-none-any.whl", hash = "sha256:47692b7e15424051cecdcea3e57d09b9c44c82d2661591aa24c7e54bc2df0fef"}, + {file = "autogen_core-0.4.0.dev11.tar.gz", hash = "sha256:d98d0cdb8bba0c01cd100b889a4616e0100e8bd8403e8087c6f1d7eb57608564"}, ] [package.dependencies] +aioconsole = "*" aiohttp = "*" asyncio-atexit = "*" -grpcio = ">=1.62.0,<1.63.0" jsonref = ">=1.1.0,<1.2.0" openai = ">=1.3" opentelemetry-api = ">=1.27.0,<1.28.0" @@ -365,6 +379,31 @@ typing-extensions = "*" [package.extras] grpc = ["grpcio (>=1.62.0,<1.63.0)"] +[[package]] +name = "autogen-ext" +version = "0.4.0.dev11" +description = "AutoGen extensions library" +optional = false +python-versions = ">=3.10" +files = [ + {file = "autogen_ext-0.4.0.dev11-py3-none-any.whl", hash = "sha256:b1d89e25356073c3adbb25aad5b05138176253288e682c0aac7b46883a2b8d30"}, + {file = "autogen_ext-0.4.0.dev11.tar.gz", hash = "sha256:518b7d011abaa491988eb6d170707efb19bed4c72b000833e13f279548e7ecd0"}, +] + +[package.dependencies] +autogen-core = "0.4.0.dev11" + +[package.extras] +azure = ["azure-core", "azure-identity"] +docker = ["docker (>=7.0,<8.0)"] +file-surfer = ["autogen-agentchat (==0.4.0.dev11)", "markitdown (>=0.0.1a2)"] +grpc = ["grpcio (>=1.62.0,<1.63.0)"] +langchain = ["langchain-core (>=0.3.3,<0.4.0)"] +magentic-one = ["autogen-agentchat (==0.4.0.dev11)", "markitdown (>=0.0.1a2)", "pillow (>=11.0.0)", "playwright (>=1.48.0)"] +openai = ["aiofiles", "openai (>=1.3)"] +video-surfer = ["autogen-agentchat (==0.4.0.dev11)", "ffmpeg-python", "openai-whisper", "opencv-python (>=4.5)"] +web-surfer = ["autogen-agentchat (==0.4.0.dev11)", "pillow (>=11.0.0)", "playwright (>=1.48.0)"] + [[package]] name = "backoff" version = "2.2.1" @@ -3176,69 +3215,70 @@ protobuf = ">=3.20.2,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4 [[package]] name = "grpcio" -version = "1.62.3" +version = "1.68.1" description = "HTTP/2-based RPC framework" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "grpcio-1.62.3-cp310-cp310-linux_armv7l.whl", hash = "sha256:13571a5b868dcc308a55d36669a2d17d9dcd6ec8335213f6c49cc68da7305abe"}, - {file = "grpcio-1.62.3-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:f5def814c5a4c90c8fe389c526ab881f4a28b7e239b23ed8e02dd02934dfaa1a"}, - {file = "grpcio-1.62.3-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:7349cd7445ac65fbe1b744dcab9cc1ec02dae2256941a2e67895926cbf7422b4"}, - {file = "grpcio-1.62.3-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:646c14e9f3356d3f34a65b58b0f8d08daa741ba1d4fcd4966b79407543332154"}, - {file = "grpcio-1.62.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:807176971c504c598976f5a9ea62363cffbbbb6c7509d9808c2342b020880fa2"}, - {file = "grpcio-1.62.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:43670a25b752b7ed960fcec3db50ae5886dc0df897269b3f5119cde9b731745f"}, - {file = "grpcio-1.62.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:668211f3699bbee4deaf1d6e6b8df59328bf63f077bf2dc9b8bfa4a17df4a279"}, - {file = "grpcio-1.62.3-cp310-cp310-win32.whl", hash = "sha256:216740723fc5971429550c374a0c039723b9d4dcaf7ba05227b7e0a500b06417"}, - {file = "grpcio-1.62.3-cp310-cp310-win_amd64.whl", hash = "sha256:b708401ede2c4cb8943e8a713988fcfe6cbea105b07cd7fa7c8a9f137c22bddb"}, - {file = "grpcio-1.62.3-cp311-cp311-linux_armv7l.whl", hash = "sha256:c8bb1a7aa82af6c7713cdf9dcb8f4ea1024ac7ce82bb0a0a82a49aea5237da34"}, - {file = "grpcio-1.62.3-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:57823dc7299c4f258ae9c32fd327d29f729d359c34d7612b36e48ed45b3ab8d0"}, - {file = "grpcio-1.62.3-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:1de3d04d9a4ec31ebe848ae1fe61e4cbc367fb9495cbf6c54368e60609a998d9"}, - {file = "grpcio-1.62.3-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:325c56ce94d738c31059cf91376f625d3effdff8f85c96660a5fd6395d5a707f"}, - {file = "grpcio-1.62.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c175b252d063af388523a397dbe8edbc4319761f5ee892a8a0f5890acc067362"}, - {file = "grpcio-1.62.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:25cd75dc73c5269932413e517be778640402f18cf9a81147e68645bd8af18ab0"}, - {file = "grpcio-1.62.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a1b85d35a7d9638c03321dfe466645b87e23c30df1266f9e04bbb5f44e7579a9"}, - {file = "grpcio-1.62.3-cp311-cp311-win32.whl", hash = "sha256:6be243f3954b0ca709f56f9cae926c84ac96e1cce19844711e647a1f1db88b99"}, - {file = "grpcio-1.62.3-cp311-cp311-win_amd64.whl", hash = "sha256:e9ffdb7bc9ccd56ec201aec3eab3432e1e820335b5a16ad2b37e094218dcd7a6"}, - {file = "grpcio-1.62.3-cp312-cp312-linux_armv7l.whl", hash = "sha256:4c9c1502c76cadbf2e145061b63af077b08d5677afcef91970d6db87b30e2f8b"}, - {file = "grpcio-1.62.3-cp312-cp312-macosx_10_10_universal2.whl", hash = "sha256:abfe64811177e681edc81d9d9d1bd23edc5f599bd9846650864769264ace30cd"}, - {file = "grpcio-1.62.3-cp312-cp312-manylinux_2_17_aarch64.whl", hash = "sha256:3737e5ef0aa0fcdfeaf3b4ecc1a6be78b494549b28aec4b7f61b5dc357f7d8be"}, - {file = "grpcio-1.62.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:940459d81685549afdfe13a6de102c52ea4cdda093477baa53056884aadf7c48"}, - {file = "grpcio-1.62.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac9783d5679c8da612465168c820fd0b916e70ec5496c840bddba0be7f2d124c"}, - {file = "grpcio-1.62.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:c95a0b76a44c548e6bd8c5f7dbecf89c77e2e16d3965be817b57769c4a30bea2"}, - {file = "grpcio-1.62.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:b097347441b86a8c3ad9579abaf5e5f7f82b1d74a898f47360433b2bca0e4536"}, - {file = "grpcio-1.62.3-cp312-cp312-win32.whl", hash = "sha256:3fb7d966a976d762a31346353a19fce4afcffbeda3027dd563bc8cb521fcf799"}, - {file = "grpcio-1.62.3-cp312-cp312-win_amd64.whl", hash = "sha256:454a6aed4ebd56198d37e1f3be6f1c70838e33dd62d1e2cea12f2bcb08efecc5"}, - {file = "grpcio-1.62.3-cp37-cp37m-linux_armv7l.whl", hash = "sha256:8257cc9e55fb0e2149a652d9dc14c023720f9e73c9145776e07c97e0a553922e"}, - {file = "grpcio-1.62.3-cp37-cp37m-macosx_10_10_universal2.whl", hash = "sha256:e202e3f963480ca067a261179b1ac610c0f0272cb4a7942d11b7e2b3fc99c3aa"}, - {file = "grpcio-1.62.3-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:9c4aae4e683776c319169d87e7891b67b75e3f1c0beeb877902ea148b0585164"}, - {file = "grpcio-1.62.3-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a82410d7620c07cb32624e38f2a106980564dfef9dbe78f5b295cda9ef217c03"}, - {file = "grpcio-1.62.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c118cfc80e2402a5595be36e9245ffd9b0e146f426cc40bdf60015bf183f8373"}, - {file = "grpcio-1.62.3-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:377babc817e8b4186aed7ed56e832867c513e4e9b6c3503565c344ffdef440d4"}, - {file = "grpcio-1.62.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:7b33c1807d4ac564a3027d06f21a2220c116ceacaaef614deb96b3341ee58896"}, - {file = "grpcio-1.62.3-cp37-cp37m-win_amd64.whl", hash = "sha256:1ac0944e9e3ee3e20825226d1e17985e9f88487055c475986cf0922a7d806d8a"}, - {file = "grpcio-1.62.3-cp38-cp38-linux_armv7l.whl", hash = "sha256:56757d3e4cf5d4b98a30f2c5456151607261c891fa2298a4554848dcbf83083d"}, - {file = "grpcio-1.62.3-cp38-cp38-macosx_10_10_universal2.whl", hash = "sha256:ea7ca66a58421411c6486fa5015fe7704e2816ff0b4ec4fb779ad5e1cbbdabf3"}, - {file = "grpcio-1.62.3-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:4dab8b64c438e19c763a6332b55e5efdbecfb7c55ae59a42c38c81ed27955fa5"}, - {file = "grpcio-1.62.3-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b033d50bd41e506e3b579775f54a30c16c222e0d88847ac8098d2eca2a7454cc"}, - {file = "grpcio-1.62.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75a4e9ac7ff185cad529f35934c5d711b88aca48b90c70e195f5657da50ce321"}, - {file = "grpcio-1.62.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:bd900e666bb68fff49703084be14407cd73b8a5752a7590cea98ec22de24fb5d"}, - {file = "grpcio-1.62.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:80a82fdee14dc27e9299248b7aabd5a8739a1cf6b76c78aa2b848158b44a99d5"}, - {file = "grpcio-1.62.3-cp38-cp38-win32.whl", hash = "sha256:8ae2e7a390b2cdd2a95d3bf3b3385245eeb48a5e853943cb46139666462c2d1a"}, - {file = "grpcio-1.62.3-cp38-cp38-win_amd64.whl", hash = "sha256:620165df24aae3d5b3e84cb8dd6b98f6ed49aed04126186bbf43061e301d6a21"}, - {file = "grpcio-1.62.3-cp39-cp39-linux_armv7l.whl", hash = "sha256:8a5f00b2508937952d23a1767739e95bbbe1120f8a66d10187d5e971d56bb55c"}, - {file = "grpcio-1.62.3-cp39-cp39-macosx_10_10_universal2.whl", hash = "sha256:059444f0ed5dba73ab7dd0ee7e8e6b606df4130d2b0a9f010f84da4ab9f6c2d8"}, - {file = "grpcio-1.62.3-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:114f2a865886ff33f85d70670e971fe0e3d252a1209656fefa5470286e3fcc76"}, - {file = "grpcio-1.62.3-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6da20a1ae010a988bc4ed47850f1122de0a88e18cd2f901fcf56007be1fc6c30"}, - {file = "grpcio-1.62.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2ff8ac447765e173842b554b31307b98b3bb1852710903ebb936e7efb7df6e5"}, - {file = "grpcio-1.62.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:81b7c121c4e52a0749bf0759185b8d5cfa48a786cd7d411cdab08269813e0aab"}, - {file = "grpcio-1.62.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9d5f8e0050a179b3bce9189b522dc91008d44f08c757a7c310e0fd06b4d3d147"}, - {file = "grpcio-1.62.3-cp39-cp39-win32.whl", hash = "sha256:74f3fc9b93290e58264844f5bc46df4c58a94c4287a277dbcf75344fc6c37ca4"}, - {file = "grpcio-1.62.3-cp39-cp39-win_amd64.whl", hash = "sha256:582bd03e9c3d1bd1162eb51fa0f1a35633d66e73f4f36702d3b8484a8b45eda7"}, - {file = "grpcio-1.62.3.tar.gz", hash = "sha256:4439bbd759636e37b66841117a66444b454937e27f0125205d2d117d7827c643"}, -] - -[package.extras] -protobuf = ["grpcio-tools (>=1.62.3)"] + {file = "grpcio-1.68.1-cp310-cp310-linux_armv7l.whl", hash = "sha256:d35740e3f45f60f3c37b1e6f2f4702c23867b9ce21c6410254c9c682237da68d"}, + {file = "grpcio-1.68.1-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:d99abcd61760ebb34bdff37e5a3ba333c5cc09feda8c1ad42547bea0416ada78"}, + {file = "grpcio-1.68.1-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:f8261fa2a5f679abeb2a0a93ad056d765cdca1c47745eda3f2d87f874ff4b8c9"}, + {file = "grpcio-1.68.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0feb02205a27caca128627bd1df4ee7212db051019a9afa76f4bb6a1a80ca95e"}, + {file = "grpcio-1.68.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:919d7f18f63bcad3a0f81146188e90274fde800a94e35d42ffe9eadf6a9a6330"}, + {file = "grpcio-1.68.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:963cc8d7d79b12c56008aabd8b457f400952dbea8997dd185f155e2f228db079"}, + {file = "grpcio-1.68.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ccf2ebd2de2d6661e2520dae293298a3803a98ebfc099275f113ce1f6c2a80f1"}, + {file = "grpcio-1.68.1-cp310-cp310-win32.whl", hash = "sha256:2cc1fd04af8399971bcd4f43bd98c22d01029ea2e56e69c34daf2bf8470e47f5"}, + {file = "grpcio-1.68.1-cp310-cp310-win_amd64.whl", hash = "sha256:ee2e743e51cb964b4975de572aa8fb95b633f496f9fcb5e257893df3be854746"}, + {file = "grpcio-1.68.1-cp311-cp311-linux_armv7l.whl", hash = "sha256:55857c71641064f01ff0541a1776bfe04a59db5558e82897d35a7793e525774c"}, + {file = "grpcio-1.68.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:4b177f5547f1b995826ef529d2eef89cca2f830dd8b2c99ffd5fde4da734ba73"}, + {file = "grpcio-1.68.1-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:3522c77d7e6606d6665ec8d50e867f13f946a4e00c7df46768f1c85089eae515"}, + {file = "grpcio-1.68.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9d1fae6bbf0816415b81db1e82fb3bf56f7857273c84dcbe68cbe046e58e1ccd"}, + {file = "grpcio-1.68.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:298ee7f80e26f9483f0b6f94cc0a046caf54400a11b644713bb5b3d8eb387600"}, + {file = "grpcio-1.68.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:cbb5780e2e740b6b4f2d208e90453591036ff80c02cc605fea1af8e6fc6b1bbe"}, + {file = "grpcio-1.68.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ddda1aa22495d8acd9dfbafff2866438d12faec4d024ebc2e656784d96328ad0"}, + {file = "grpcio-1.68.1-cp311-cp311-win32.whl", hash = "sha256:b33bd114fa5a83f03ec6b7b262ef9f5cac549d4126f1dc702078767b10c46ed9"}, + {file = "grpcio-1.68.1-cp311-cp311-win_amd64.whl", hash = "sha256:7f20ebec257af55694d8f993e162ddf0d36bd82d4e57f74b31c67b3c6d63d8b2"}, + {file = "grpcio-1.68.1-cp312-cp312-linux_armv7l.whl", hash = "sha256:8829924fffb25386995a31998ccbbeaa7367223e647e0122043dfc485a87c666"}, + {file = "grpcio-1.68.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:3aed6544e4d523cd6b3119b0916cef3d15ef2da51e088211e4d1eb91a6c7f4f1"}, + {file = "grpcio-1.68.1-cp312-cp312-manylinux_2_17_aarch64.whl", hash = "sha256:4efac5481c696d5cb124ff1c119a78bddbfdd13fc499e3bc0ca81e95fc573684"}, + {file = "grpcio-1.68.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ab2d912ca39c51f46baf2a0d92aa265aa96b2443266fc50d234fa88bf877d8e"}, + {file = "grpcio-1.68.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95c87ce2a97434dffe7327a4071839ab8e8bffd0054cc74cbe971fba98aedd60"}, + {file = "grpcio-1.68.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:e4842e4872ae4ae0f5497bf60a0498fa778c192cc7a9e87877abd2814aca9475"}, + {file = "grpcio-1.68.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:255b1635b0ed81e9f91da4fcc8d43b7ea5520090b9a9ad9340d147066d1d3613"}, + {file = "grpcio-1.68.1-cp312-cp312-win32.whl", hash = "sha256:7dfc914cc31c906297b30463dde0b9be48e36939575eaf2a0a22a8096e69afe5"}, + {file = "grpcio-1.68.1-cp312-cp312-win_amd64.whl", hash = "sha256:a0c8ddabef9c8f41617f213e527254c41e8b96ea9d387c632af878d05db9229c"}, + {file = "grpcio-1.68.1-cp313-cp313-linux_armv7l.whl", hash = "sha256:a47faedc9ea2e7a3b6569795c040aae5895a19dde0c728a48d3c5d7995fda385"}, + {file = "grpcio-1.68.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:390eee4225a661c5cd133c09f5da1ee3c84498dc265fd292a6912b65c421c78c"}, + {file = "grpcio-1.68.1-cp313-cp313-manylinux_2_17_aarch64.whl", hash = "sha256:66a24f3d45c33550703f0abb8b656515b0ab777970fa275693a2f6dc8e35f1c1"}, + {file = "grpcio-1.68.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c08079b4934b0bf0a8847f42c197b1d12cba6495a3d43febd7e99ecd1cdc8d54"}, + {file = "grpcio-1.68.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8720c25cd9ac25dd04ee02b69256d0ce35bf8a0f29e20577427355272230965a"}, + {file = "grpcio-1.68.1-cp313-cp313-musllinux_1_1_i686.whl", hash = "sha256:04cfd68bf4f38f5bb959ee2361a7546916bd9a50f78617a346b3aeb2b42e2161"}, + {file = "grpcio-1.68.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c28848761a6520c5c6071d2904a18d339a796ebe6b800adc8b3f474c5ce3c3ad"}, + {file = "grpcio-1.68.1-cp313-cp313-win32.whl", hash = "sha256:77d65165fc35cff6e954e7fd4229e05ec76102d4406d4576528d3a3635fc6172"}, + {file = "grpcio-1.68.1-cp313-cp313-win_amd64.whl", hash = "sha256:a8040f85dcb9830d8bbb033ae66d272614cec6faceee88d37a88a9bd1a7a704e"}, + {file = "grpcio-1.68.1-cp38-cp38-linux_armv7l.whl", hash = "sha256:eeb38ff04ab6e5756a2aef6ad8d94e89bb4a51ef96e20f45c44ba190fa0bcaad"}, + {file = "grpcio-1.68.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:8a3869a6661ec8f81d93f4597da50336718bde9eb13267a699ac7e0a1d6d0bea"}, + {file = "grpcio-1.68.1-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:2c4cec6177bf325eb6faa6bd834d2ff6aa8bb3b29012cceb4937b86f8b74323c"}, + {file = "grpcio-1.68.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:12941d533f3cd45d46f202e3667be8ebf6bcb3573629c7ec12c3e211d99cfccf"}, + {file = "grpcio-1.68.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80af6f1e69c5e68a2be529990684abdd31ed6622e988bf18850075c81bb1ad6e"}, + {file = "grpcio-1.68.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:e8dbe3e00771bfe3d04feed8210fc6617006d06d9a2679b74605b9fed3e8362c"}, + {file = "grpcio-1.68.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:83bbf5807dc3ee94ce1de2dfe8a356e1d74101e4b9d7aa8c720cc4818a34aded"}, + {file = "grpcio-1.68.1-cp38-cp38-win32.whl", hash = "sha256:8cb620037a2fd9eeee97b4531880e439ebfcd6d7d78f2e7dcc3726428ab5ef63"}, + {file = "grpcio-1.68.1-cp38-cp38-win_amd64.whl", hash = "sha256:52fbf85aa71263380d330f4fce9f013c0798242e31ede05fcee7fbe40ccfc20d"}, + {file = "grpcio-1.68.1-cp39-cp39-linux_armv7l.whl", hash = "sha256:cb400138e73969eb5e0535d1d06cae6a6f7a15f2cc74add320e2130b8179211a"}, + {file = "grpcio-1.68.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:a1b988b40f2fd9de5c820f3a701a43339d8dcf2cb2f1ca137e2c02671cc83ac1"}, + {file = "grpcio-1.68.1-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:96f473cdacfdd506008a5d7579c9f6a7ff245a9ade92c3c0265eb76cc591914f"}, + {file = "grpcio-1.68.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:37ea3be171f3cf3e7b7e412a98b77685eba9d4fd67421f4a34686a63a65d99f9"}, + {file = "grpcio-1.68.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ceb56c4285754e33bb3c2fa777d055e96e6932351a3082ce3559be47f8024f0"}, + {file = "grpcio-1.68.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:dffd29a2961f3263a16d73945b57cd44a8fd0b235740cb14056f0612329b345e"}, + {file = "grpcio-1.68.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:025f790c056815b3bf53da850dd70ebb849fd755a4b1ac822cb65cd631e37d43"}, + {file = "grpcio-1.68.1-cp39-cp39-win32.whl", hash = "sha256:1098f03dedc3b9810810568060dea4ac0822b4062f537b0f53aa015269be0a76"}, + {file = "grpcio-1.68.1-cp39-cp39-win_amd64.whl", hash = "sha256:334ab917792904245a028f10e803fcd5b6f36a7b2173a820c0b5b076555825e1"}, + {file = "grpcio-1.68.1.tar.gz", hash = "sha256:44a8502dd5de653ae6a73e2de50a401d84184f0331d0ac3daeb044e66d5c5054"}, +] + +[package.extras] +protobuf = ["grpcio-tools (>=1.68.1)"] [[package]] name = "grpcio-status" @@ -7294,7 +7334,6 @@ description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs optional = false python-versions = ">=3.8" files = [ - {file = "pyasn1-0.6.1-py3-none-any.whl", hash = "sha256:0d632f46f2ba09143da3a8afe9e33fb6f92fa2320ab7e886e2d0f7672af84629"}, {file = "pyasn1-0.6.1.tar.gz", hash = "sha256:6f580d2bdd84365380830acf45550f2511469f673cb4a5ae3857a3170128b034"}, ] @@ -7305,7 +7344,6 @@ description = "A collection of ASN.1-based protocols modules" optional = false python-versions = ">=3.8" files = [ - {file = "pyasn1_modules-0.4.1-py3-none-any.whl", hash = "sha256:49bfa96b45a292b711e986f222502c1c9a5e1f4e568fc30e2574a6c7d07838fd"}, {file = "pyasn1_modules-0.4.1.tar.gz", hash = "sha256:c28e2dbf9c06ad61c71a075c7e0f9fd0f1b0bb2d2ad4377f240d33ac2ab60a7c"}, ] @@ -10835,4 +10873,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "~3.10.0" -content-hash = "0eac82433fc087ed5b699aded89a5ed57f9acd4e7b65c5cb86c91c0403a6e541" +content-hash = "b5220756d0885951964a598c1aa3e055237ad061a3927f07cd38a87a6bd9a57f" diff --git a/prediction_market_agent/agents/social_media_agent/social_agent.py b/prediction_market_agent/agents/social_media_agent/social_agent.py index 0b63f068..ef45cdac 100644 --- a/prediction_market_agent/agents/social_media_agent/social_agent.py +++ b/prediction_market_agent/agents/social_media_agent/social_agent.py @@ -1,10 +1,14 @@ +import asyncio from enum import Enum from string import Template -from typing import Any, Dict, Optional -import autogen -from autogen import AssistantAgent, UserProxyAgent -from autogen.cache import Cache +from autogen_agentchat.agents import AssistantAgent +from autogen_agentchat.teams import BaseGroupChat, MagenticOneGroupChat +from autogen_agentchat.teams._group_chat._magentic_one._prompts import ( + ORCHESTRATOR_FINAL_ANSWER_PROMPT, +) +from autogen_agentchat.ui import Console +from autogen_ext.models.openai import OpenAIChatCompletionClient from prediction_market_agent_tooling.markets.data_models import Bet from prediction_market_agent_tooling.tools.langfuse_ import observe from prediction_market_agent_tooling.tools.utils import DatetimeUTC @@ -14,7 +18,6 @@ SimpleMemoryThinkThoroughly, ) from prediction_market_agent.agents.social_media_agent.prompts import ( - CRITIC_PROMPT, INFLUENCER_PROMPT, POST_MAX_LENGTH, REASONING_PROMPT, @@ -54,63 +57,36 @@ class AutogenAgentType(str, Enum): USER = "user" -def reflection_message( - recipient: UserProxyAgent, - messages: list[Dict[Any, Any]], - sender: AssistantAgent, - config: Optional[Any] = None, -) -> str: - reflect_prompt = Template(CRITIC_PROMPT).substitute( - TWEET=recipient.chat_messages_for_summary(sender)[-1]["content"] +def build_team(model: str) -> BaseGroupChat: + model_client = OpenAIChatCompletionClient( + model=model, api_key=APIKeys().openai_api_key.get_secret_value() ) - return reflect_prompt - - -def build_llm_config(model: str) -> Dict[str, Any]: - keys = APIKeys() - return { - "config_list": [ - {"model": model, "api_key": keys.openai_api_key.get_secret_value()} - ], - } - - -def build_agents(model: str) -> Dict[AutogenAgentType, autogen.ConversableAgent]: - llm_config = build_llm_config(model) - - user_proxy = autogen.UserProxyAgent( - name="User", - human_input_mode="NEVER", - is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, - code_execution_config={ - "last_n_messages": 1, - "work_dir": "tasks", - "use_docker": False, - }, + + primary_agent = AssistantAgent( + "primary", + model_client=model_client, + description="Generate a tweet for the user. Make sure the feedback given by the critic is being addressed.", + system_message="""You are a professional influencer, known for your insightful and engaging tweets. You transform complex concepts into compelling narratives. You should improve the quality of the content based on the feedback from the user. You must always return only the tweet.""", ) - writer = autogen.AssistantAgent( - name="Writer", - llm_config=llm_config, - system_message="""You are a professional influencer, known for your insightful and engaging tweets. You - transform complex concepts into compelling narratives. You should improve the quality of the content based on - the feedback from the user. You must always return only the tweet. """, + critic_agent = AssistantAgent( + "critic", + model_client=model_client, + description="Critique the tweet and provide feedback.", + system_message=f""" You are a critic, known for your thoroughness and commitment to standards. Your task is to scrutinize content for any harmful elements or regulatory violations, ensuring all materials align with required guidelines. You should also always remind everyone that the limit for any posts being created is {POST_MAX_LENGTH} characters. References to betting and gambling are allowed.""", ) - critic = autogen.AssistantAgent( - name="Critic", - llm_config=llm_config, - system_message=f""" You are a critic, known for your thoroughness and commitment to standards. Your task is - to scrutinize content for any harmful elements or regulatory violations, ensuring all materials align with - required guidelines. You should also always remind everyone that the limit for any posts being created is -{POST_MAX_LENGTH} characters. References to betting and gambling are allowed.""", + final_prompt = ( + ORCHESTRATOR_FINAL_ANSWER_PROMPT + + "\n Output only the final version of the tweet and nothing else." ) - return { - AutogenAgentType.CRITIC: critic, - AutogenAgentType.WRITER: writer, - AutogenAgentType.USER: user_proxy, - } + magentic_team = MagenticOneGroupChat( + [primary_agent, critic_agent], + model_client=model_client, + final_answer_prompt=final_prompt, + ) + return magentic_team @observe() @@ -184,38 +160,8 @@ def build_reply_tweet( def build_tweet(model: str, task: str) -> str: - agents = build_agents(model) - user_proxy, writer, critic = ( - agents[AutogenAgentType.USER], - agents[AutogenAgentType.WRITER], - agents[AutogenAgentType.CRITIC], - ) - user_proxy.register_nested_chats( - [ - { - "recipient": critic, - "message": reflection_message, - "summary_method": "last_msg", - "max_turns": 1, - } - ], - trigger=writer, - ) - - # in case we trigger repeated runs, Cache makes it faster. - with Cache.disk(cache_seed=42) as cache: - # max_turns = the maximum number of turns for the chat between the two agents. One turn means one conversation round trip. - res = user_proxy.initiate_chat( - recipient=writer, - message=task, - max_turns=2, - summary_method=SummaryMethod.REFLECTION_WITH_LLM, - cache=cache, - ) - # We extract the last message since the revised tweet is contained in the last response - # from the writer. - reply_tweet = res.chat_history[-1]["content"] + team = build_team(model) - return str( - reply_tweet - ) # Casting needed as summary is of type any and no Pydantic support + task_result = asyncio.run(Console(team.run_stream(task=task))) + reply_tweet = task_result.messages[-1].content # Last message is critic's approval + return str(reply_tweet) diff --git a/pyproject.toml b/pyproject.toml index 57c47df0..a6ecc612 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ langchain-experimental = "*" langchain-community = "*" langchain-openai = "*" numexpr = "*" -pyautogen = "^0.3.1" flaml = "^2.2.0,<2.3.0" # Bug in newer version, because they started importing xgboost, without requiring it as a dependency. beautifulsoup4 = "*" google-search-results = "*" @@ -54,7 +53,9 @@ plotly = "^5.22.0" prediction-prophet = { git = "https://github.com/agentcoinorg/predictionprophet.git", branch = "bump-autogen" } transformers = "^4.43.3" openfactverification-kongzii = "^0.2.0" -autogen-agentchat = "0.4.0.dev8" +autogen-agentchat = "0.4.0.dev11" +autogen-core = "0.4.0.dev11" +autogen-ext = "0.4.0.dev11" dune-spice = "^0.2.5" [tool.poetry.group.dev.dependencies]