1. ์์ด์ ํธ๋
1.1 ์์ด์ ํธ์ ๊ตฌ์ฑ์์
โ ์์ด์ ํธ
โช๏ธ ์ฃผ๋ณ ํ๊ฒฝ์ ๊ฐ๊ฐ์ ํตํด ์ธ์ํ๊ณ , ์์ฌ๊ฒฐ์ ์ ๋ด๋ ค, ํ๋ํ๋ ์ธ๊ณต์ ์ธ ๊ฐ์ฒด
โช๏ธ ์ฃผ์ด์ง ์ผ์ ์ค์ค๋ก ์ธ๋ถํํ๊ณ ๋จ๊ณ๋ณ๋ก ํ์ํ ์์ ๋ค์ ์ํํ์ฌ ์ฌ์ฉ์์ ์์ฒญ์ ์์ํ๋ค.
โ ์ธ ๊ฐ์ง ๊ตฌ์ฑ์์

โช๏ธ 1) ๊ฐ๊ฐ : ์ธ๋ถํ๊ฒฝ๊ณผ ์ฌ์ฉ์์ ์์ฒญ์ ์ธ์
โช๏ธ 2) ๋๋ : ์ง์์ด๋ ๊ธฐ์ต์ ํ์ธํ์ฌ ๊ณํ์ ์ธ์ฐ๊ฑฐ๋ ์ถ๋ก ์ ํตํด ๋ค์ ํ๋์ ์ฌ๋ถ ๋ฑ ์์ฌ๊ฒฐ์ ์ ๋ด๋ฆผ
โช๏ธ 3) ํ๋ : ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์ทจํ ์ ์๋ ์ ์ ํ ๋๊ตฌ๋ฅผ ์ ํํด ํ๋
1.2 ์์ด์ ํธ์ ๋๋
โ ์์ด์ ํธ์ ๋๋
โช๏ธ ๋๋์ญํ ์ ํ๋ ๊ธฐ์ : Symbolic AI, ๊ฐํํ์ต, meta learning (์ ์ดํ์ต์ ์ผ์ข ), LLM
โช๏ธ LLM์ ๋ฐํ์ผ๋ก ํ ์์ด์ ํธ๊ฐ ํ๋ฐํ ๊ฐ๋ฐ๋๊ณ ์๋ค.

โช๏ธ ์ฃผ๋ณ ํ๊ฒฝ๊ณผ ์ฌ์ฉ์์ ์์ฒญ์ ์ธ์ํ์ฌ > ๊ทธ๋ฅผ ์ดํดํ๊ณ > ๋ชฉํ๋ฌ์ฑ์ ์ํด ์ด๋ค ํ๋์ ์ทจํ ๊ฒ์ธ์ง ๊ฒฐ์ ํ๋ค.
โช๏ธ ์ง๊ธ๊น์ง ์ํํ ์ฌ์ฉ์์์ ๋ํ๋ ํ๋์ ์ ์ฅํ ๊ธฐ์ต์ ํ์ธํ๊ณ , ์ํฉ์ ์ดํดํ๋๋ฐ ํ์ํ ์ง์์ ๊ฒ์ํด ํ์ฉํ๋ค. ๋ณด๊ฐํ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก ์์ ์ ์ธ๋ถํํ๋ ๊ณํ ์ธ์ฐ๊ธฐ ๋จ๊ณ๋ฅผ ๊ฑฐ์น๊ณ ๋ค์์ ์ด๋ค ํ๋์ด ํ์ํ์ง ๊ฒฐ์ ํด ํ๋ ๋จ๊ณ๋ก ๋์ด๊ฐ๋ค.
๐ LLM์ ์ด ๋ชจ๋ ๊ณผ์ ์ ํ์ํ ๋ฅ๋ ฅ์ ๊ฐ์ง๊ณ ์๋ค : RAG (ํ์ํ ์ง์์ ๊ฒ์ํ๊ณ ํ์ฉ), ์ถ๋ก ๋ฅ๋ ฅ, ์ผ๋ฐํ ๋ฅ๋ ฅ, ์์ฝ ๊ธฐ๋ฅ
1.3 ์์ด์ ํธ์ ๊ฐ๊ฐ
โ ์์ด์ ํธ์ ๊ฐ๊ฐ
โช๏ธ ํ
์คํธ, ์ด๋ฏธ์ง, ์์ฑ(e.g. OpenAI์ Whisper) ๋ฑ LLM์ด ํ์ฉํ ์ ์๋ ๋ฐ์ดํฐ ์ ํ์ด ๋ง์์ง์๋ก ํ๋ถํ ์ ๋ณด๋ฅผ ์ฒ๋ฆฌํ๊ณ ๋ค์ํ ์ํฉ์ ๋์ํ ์ ์๋ค.

โช๏ธ LLaVA (์ด๋ฏธ์ง์ ํ ์คํธ ๋ฉํฐ๋ชจ๋ฌ ๋ชจ๋ธ), Video-LLaMA (๋น๋์ค์ ํ ์คํธ ๋ฉํฐ๋ชจ๋ฌ ๋ชจ๋ธ), GPT-4V, GPT-4o
โช๏ธ ์ด๋ฏธ์ง์ ์์ฑ ๋ฐ์ดํฐ ์ธ์๋, ์ด๊ฐ ์ผ์๋ ํ๊ฐ ์ผ์๋ฅผ ์ฌ์ฉํด ์ด๊ฐ ์ ๋ณด๋ ๋์ ์ ๋ณด๋ฅผ LLM์ ์ ๋ฌํ๊ฑฐ๋, GPS์ ๊ฐ์ ์์น์ ๋ณด, 3D ๊ณต๊ฐ ์ ๋ณด ๋ฑ์ ํ์ฉํด LLM์ ํ๋ถํ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์๋ค.
1.4 ์์ด์ ํธ์ ํ๋
โ ์์ด์ ํธ์ ํ๋
โช๏ธ LLM์ ํ ์คํธ๋ง ์์ฑํ ์ ์์ผ๋ฏ๋ก, ์ธ๋ถ์ ์ํฅ์ ๋ฏธ์น๋ ํ๋์ ํ๊ธฐ ์ํด์๋ LLM์ด ์ฌ์ฉํ ์ ์๋ ๋๊ตฌ๋ฅผ ์ ๊ณตํด์ผ ํ๋ค. ์ด๋จ ๋ ์ฌ์ฉํ๊ณ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง (ํ์ํ ํ๋ผ๋ฏธํฐ) ์ค๋ช ์ ์ ๊ณตํ๋ฉด, LLM์ ์ํฉ์ ๋ง์ถฐ ํ์ํ ๋๊ตฌ๋ฅผ ์ ํํ ์ ์๋ค.
โช๏ธ ๊ฐ๋ น, ๋ด์ผ ๋ ์จ๋ฅผ ํ์ธํ๊ณ ์ ํ ๋, ๊ตฌ๊ธ ๊ฒ์ ๊ธฐ๋ฅ๊ณผ ๊ณ์ฐ๊ธฐ ๋๊ตฌ ๋ชฉ๋ก์ LLM์๊ฒ ์ ๊ณตํ๊ณ , ํ์ํ ํ๋์ ์ ํํ๋๋ก ํ๋ฉด ๊ตฌ๊ธ ๊ฒ์ ๊ธฐ๋ฅ์ ๋๊ตฌ๋ก ์ฌ์ฉํ๊ณ , '๋ด์ผ ๋ ์จ'๋ฅผ ๊ฒ์ ์ฟผ๋ฆฌ๋ก ์ ๋ ฅํ๋ฉด ๋๋ค๋ ๊ฒฐ๊ณผ๋ฅผ ์ ์์ฑํ๋ค. ์ด๋ฆ๋ง์ผ๋ก ํ์ ํ๊ธฐ ์ด๋ ค์ด ๊ธฐ๋ฅ์ด๋ผ๋ฉด, ์ด๋ค ์ํฉ์์ ์ฌ์ฉํ๋์ง ์๋๋ฆฌ์ค๋ฅผ ํจ๊ป ์ ๊ณตํด๋ ์ข๋ค.
โ ๋๊ตฌ
โช๏ธ ๋ํ์ ์ธ ๋๊ตฌ๋ก๋ ๊ฒ์ API (์ธํฐ๋ท ์ ๋ณด ํ์ฉ), ์ฝ๋ ์คํ, ์ด๋ฏธ์ง(Dall-E, Stable Diffusion)/์์ฑ(TTS) ์์ฑ, ๋ฌผ๋ฆฌ์ ํ๋, ๋ฒ์ญ/์์ฝ ๋ฑ์ด ์๋ค.
2. ์์ด์ ํธ ์์คํ ์ ํํ
2.1 ๋จ์ผ ์์ด์ ํธ
โ AutoGPT


โช๏ธ GPT-4 LLM์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌ์ถ๋ AI Agent ๋ฅผ ์ฌ์ฉํด ์ฌ๋ฌ ๋จ๊ณ์ ํ๋ก์ ํธ์ ๋ณต์กํ ์ํฌํ๋ก๋ฅผ ์๋ํ ํ ์ ์๋ ์คํ์์ค AI ํ๋ซํผ (์คํ์์ค AI Agent)
โช๏ธ AutoGPT๋ ์ ๋ ฅ๋ฐ๋ 'ํ๋กฌํํธ' ๋ฅผ ํตํด ๋ชจ๋ ๊ฒฐ์ ์ ๋ด๋ฆฐ๋ค.
โ ํ๋กฌํํธ๊ตฌ์ฑ
โช๏ธ 1) ์์ด์ ํธ์ ์ด๋ฆ๊ณผ ์ญํ : ์ผ๋ฐ์ ์ผ๋ก ๊ตฌ์ฒด์ ์ธ ์ญํ ์ ์ง์ ํ์์ ๋ ๊ด๋ จ ๊ธฐ๋ฅ์ ๋ ์ ์ํํ๋ ๊ฒ์ผ๋ก ์๋ ค์ ธ ์๋ค.
โช๏ธ 2) ๋ชฉํ : ex. ๊ฝ์ ๋ํ ์งง์ ์ด์ผ๊ธฐ๋ฅผ ์ฐ๊ธฐ
โช๏ธ 3) ์ ์ฝ์ฌํญ (Constraints) : ์์ด์ ํธ๊ฐ ์๋ํ๋ ๋์ ์ง์ผ์ผ ํ๋ ์ ์ฝ์ฌํญ
โช๏ธ 4) ๋๊ตฌ (Commands) : ๊ตฌ๊ธ๊ฒ์, ์น์ฌ์ดํธ ์กฐํ, ์์ ์ข ๋ฃ ๋ฑ์ ์ ํํ ์ ์๋ค. ๊ฐ๋ น LLM์ด ํ๋จํ์ ๋ ๊ตฌ๊ธ ๊ฒ์์ด ํ์ํ๋ฉด 'google' ๋ผ๋ ๋๊ตฌ ์ด๋ฆ๊ณผ ํจ๊ป ์ธ์๋ก ํ์ํ ๊ฒ์์ด๋ฅผ ๋ฐํํ๋ค.
โช๏ธ 5) ์ฑ๋ฅํ๊ฐ : ์์ด์ ํธ๊ฐ ์ง์์ ์ผ๋ก ๋ชฉํ๋ฅผ ๋ฌ์ฑํ๋๋ฐ ์ด์ ์ ๋ง์ถ๊ณ ์์์ ํจ์จ์ ์ผ๋ก ์ฌ์ฉํ๋๋ก ๋ช ๋ น
โช๏ธ 6) ์ํํ ํ๋๊ณผ ๊ฒฐ์ ์ ํ๊ณ ํ๊ณ ๋ถํ์ํ ํ๋์ผ๋ก ๋ญ๋น๋ ๋น์ฉ์ ๊ฒํ ํ๋ค. ๋ง์ง๋ง์ผ๋ก ๋ต๋ณ ํํ๋ฅผ JSON ํํ๋ก ์ ๊ณตํ๋๋ก ํ์ฌ ์ดํ์ ๋๊ตฌ๋ฅผ ์คํํ ๋ ํ๋ก๊ทธ๋๋ฐ ๋ฐฉ์์ผ๋ก ์ฝ๊ฒ ํ์ฉํ ์ ์๋๋ก ํ๋ค.
โ ๋จ์ผ ์์ด์ ํธ์ ์ฅ๋จ์
โช๏ธ ์ฅ์ : ๋ชจ๋ ๊ณผ์ ์ ์ค์ค๋ก ์ฒ๋ฆฌํ์ฌ ๋งค์ฐ ํธ๋ฆฌํ๊ณ , ๋ฒ์ฉ์ ์ธ ์์ ์ ์ฒ๋ฆฌํ ์ ์๋ ํ๋กฌํํธ๋ก ๋์ํ๋ฏ๋ก ๋ค์ํ ์์ ์ ํ์ฉ์ด ๊ฐ๋ฅ
โช๏ธ ๋จ์ : ๋ฒ์ฉ์ ์ด๊ธฐ ๋๋ฌธ์ ์์ ์ ์ํํ๋ ๊ณผ์ ์์ ๊ธธ์ ์์ ๊ฐ๋ฅ์ฑ์ด ํฌ๊ณ , LLM์ ์ฑ๋ฅ์ ํฌ๊ฒ ์ข์ฐ๋๋ค.
โช๏ธ ๋ชฉํ๊ฐ ๋ช ํํ๊ณ ์์ ์ ํฌ๊ธฐ๊ฐ ์์ ๊ฒฝ์ฐ์๋ง ์ ํ์ ์ผ๋ก ์ฌ์ฉํ๋๊ฒ ์ข๋ค.
2.2 ์ฌ์ฉ์์ ์์ด์ ํธ์ ์ํธ์์ฉ
โ ์ฌ์ฉ์์ ๊ฐ์ ์ด ํ์ํ ์์ ๊ณผ์

โช๏ธ ํน์ ๋๋ฉ์ธ์์ LLM์ ์ ๋ฌธ์ฑ์ด ์ฌ๋์ ๋นํด ๋จ์ด์ง๋ ๊ฒฝ์ฐ, ์ฌ์ฉ์๊ฐ ๋ฌธ์ ํด๊ฒฐ ๊ณผ์ ์ ์ง์ ๊ฐ์ ํ๋ ๊ฒ์ด ์ค์ํ๋ค. ์ฌ์ฉ์๊ฐ ๋ช ํํ ๋ช ๋ น๊ณผ ํผ๋๋ฐฑ์ผ๋ก ์์ด์ ํธ์ ์์ ๋ฐฉํฅ์ ์ค์ ํ๊ณ , ์์ด์ ํธ๋ ์์ ์์ ์ ์๋ ์ํํ์ฌ ์ฌ์ฉ์๊ฐ ๋น ๋ฅด๊ณ ํธํ๊ฒ ์์ ์ ์งํํ๋๋ก ์ง์ํ๋ค.
โช๏ธ ๋ฐ๋์ด๋ ์ฒด์ค์ฒ๋ผ AI ๋ชจ๋ธ์ด ์ฌ๋๊ณผ ์ ์ฌํ๊ฑฐ๋ ๋ ๋ฐ์ด๋ ์์ค์ ์ด๋ฅธ ์์ ์ ์ฌ๋๊ณผ ๋๋ฑํ ์ง์์์ ํ๋ ์ด ํ ์ ์๋ค.
2.3 ๋ฉํฐ ์์ด์ ํธ
โ ๋ฉํฐ์์ด์ ํธ
โช๏ธ ์ฌ๋ฌ ์์ด์ ํธ์ ํ๋ ฅ์ ํตํด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ์
โช๏ธ ๊ฐ ์์ด์ ํธ๋ง๋ค ์๋ก ๋ค๋ฅธ ํ๋กํ์ ์ฃผ๊ณ ์์ ์ ์ํํ๋ค. ๊ตฌ์ฒด์ ์ธ ํ๋กํ์ LLM์ ๋ถ์ฌํ๋ ๊ฒ๋ง์ผ๋ก๋ ์์ ์ ์ ๋ฌธ์ฑ์ ๋์ฌ ํ์ง์ ๋์ผ ์ ์๋ค.
โช๏ธ AutoGen, MetaGPT, CrewAI ๋ฑ ๋ค์ํ ๋ฉํฐ ์์ด์ ํธ ๊ตฌํ ํ๋ ์์ํฌ๊ฐ ์๋ค.
โ AutoGen

โช๏ธ ๋ง์ดํฌ๋ก์ํํธ์ ๋ฉํฐ ์์ด์ ํธ ํ๋ ์์ํฌ
โช๏ธ ๋ชจ๋ ์์ ์ ํ๋์ ์์ด์ ํธ๊ฐ ์ํํ๋ ๊ฒ๋ณด๋ค, ๋ง์ถคํ ์์ด์ ํธ๋ฅผ ์ฌ๋ฌ๊ฐ ๋ง๋ค์ด ์์ ์ ์ํํ ๋ ๋ฌธ์ ํด๊ฒฐ ํ๋ฅ ์ ๋ ๋์ผ ์ ์๋ค.
โช๏ธ ์์ด์ ํธ๋ผ๋ฆฌ๋ '๋ํ'๋ฅผ ํตํด ์งํ์ํฉ๊ณผ ์์ ๊ฒฐ๊ณผ๋ฅผ ๊ณต์ ํ๋ค. ๋ชจ๋ ํจ๊ป ๋ํ๋ฅผ ๋๋๋ ์ํํ(joint chat) ๋ํ์ ๋ํ๋ฅผ ์ฃผ๋ํ๋ ๋งค๋์ ๊ฐ ์ํฉ์ ๋ฐ๋ผ ์์ ํ ์์ด์ ํธ๋ฅผ ์ ํํ๊ณ ๋ํ๊ฐ ์งํ๋๋ ์๊ณํ(hierarchical chat) ๋ํ๊ฐ ์๋ค.
โ AutoGen Studio

โช๏ธ AutoGen ์คํ๋์ค๋ฅผ ์ฌ์ฉํ๋ฉด, UI์์์ ์์ฑํ ์์ด์ ํธ์ ๋ํ๋ฅผ ํ ์ ์๊ณ ํ๋ก๊ทธ๋๋ฐ์ ํ์ง ์๊ณ ๋ ์์ด์ ํธ๋ ๋๊ตฌ, ์์ด์ ํธ์ ์์ ํ๋ฆ์ ์ ์ํ๋ ์ํฌํ๋ก๋ฅผ ์์ฑํ ์ ์๋ค.
3. ์์ด์ ํธ ํ๊ฐํ๊ธฐ
โ ์ฑ๋ฅํ๊ฐ
โช๏ธ LLM์ ํ์ฉํ ์์ด์ ํธ๋ (2023๋ ๊ธฐ์ค) ์์ง ์ด๊ธฐ ๋จ๊ณ ๊ธฐ์ ์ด๊ธฐ ๋๋ฌธ์ ์์ด์ ํธ๋ฅผ ํ๊ฐํ๋ ๋ฐฉ๋ฒ๋ ์ ๋ฆฝ๋์ง๋ ์์๋ค.
โ ์ฃผ๊ด์ ์ธ ๋ฐฉ์
โช๏ธ ์์ด์ ํธ ๊ฒฐ๊ณผ๋ฅผ ์ฌ๋์ด ์ง์ ํ๊ฐํ๋ ๋ฐฉ์์ด ์๊ณ , ์ฌ๋์ ๊ฒฐ๊ณผ์ ๋น๊ตํด์ ์์ด์ ํธ๊ฐ ์์ฑํ ๊ฒ๊ณผ ์ฌ๋์ด ์์ฑํ ๊ฒ์ ๊ตฌ๋ถํ ์ ์๋์ง ํ์ธํ๋ (ํ๋งํ ์คํธ) ๋ฐฉ์์ด ์๋ค. LLM์ ํ๊ฐํ ๋์ ๋ง์ฐฌ๊ฐ์ง๋ก ํ๊ฐ์ LLM์ ํ์ฉํด ํ๊ฐํ๋ ๋ฐฉ์๋ ์ฐ๊ตฌ๋๊ณ ์๋ค.
โ ๊ฐ๊ด์ ์ธ ๋ฐฉ์
โช๏ธ ๋ฒค์น๋งํฌ ๋ฐ์ดํฐ์ ์ ์ด์ฉํด ๊ฐ๊ด์ ์ผ๋ก ํ๊ฐํ๋ ๋ฐฉ์์ด ์๋ค. Agent๋ LLM์ ํ๋์ ์ํ ๋๊ตฌ๋ ๊ธฐ์ต๊ณผ ์ง์๊ฒ์์ ์ํ ๊ฒ์์ฆ๊ฐ์์ฑ(RAG)๋ฅผ ์ถ๊ฐ๋ก ํ์ฉํ๋ฏ๋ก ์์ด์ ํธ๋ฅผ ํ๊ฐํ๋ ๋ฌธ์ ๋ ํจ์ฌ ๋ ์ด๋ ต๋ค.
โ ๊ฐ๊ด์ ์ธ ๋ฐฉ์ : ์์ด์ ํธ๋ฅผ ํ๊ฐํ๋ ๊ธฐ์ค 4๊ฐ์ง
โช๏ธ 1) ์ ์ฉ์ฑ : ์์ ์ฑ๊ณต๋ฅ ๊ฐ์ ๊ธฐ์ค์ผ๋ก ์ ์ฉ์ฑ ํ๊ฐ
โช๏ธ 2) ์ฌํ์ฑ : ์ธ์ด์ ์ธ ์ํธ์์ฉ ์ธก๋ฉด์์, ์ธ์ด๋ฅผ ์ผ๋ง๋ ์๋ จ๋๊ฒ ์ฐ๋์ง, ํ๋ ฅ์ด๋ ํ์์ด ํ์ํ ๊ฒฝ์ฐ ์ผ๋ง๋ ๋ฐ์ด๋์ง, ์ญํ ์ ๋ถ์ฌํ ๊ฒฝ์ฐ ๊ทธ์ ์ผ๋ง๋ ๋ถํฉํ๊ฒ ํ๋ํ๋์ง ๋ฑ์ ํ๊ฐ
โช๏ธ 3) ๊ฐ์น๊ด : ๊ฑฐ์ง์์ด ์ ๋ขฐํ ์ ์๋ ์ ํํ ์ ๋ณด๋ฅผ ์ ๋ฌํ๋์ง, ํธํฅ๋๊ฑฐ๋ ์ฐจ๋ณ์ ์ธ๊ฒ ์๋์ง, ์ฌํ์ ํด๊ฐ๋๋ ์ ๋ณด๋ฅผ ์ ๋ฌํ๋์ง ํ๊ฐ
โช๏ธ 4) ์งํ๋ฅ๋ ฅ : ๋ณํํ๋ ํ๊ฒฝ์ ๋ง์ถฐ ์ค์ค๋ก ๋ฐ์ ํ ์ ์๋์ง์ ๋ํ ํ๊ฐ๋ก, ์ง์์ ์ธ ํ์ต, ์ค์ค๋ก ๋ชฉํ๋ฅผ ์ค์ ํ๊ณ ๋ฌ์ฑํ๋ ํ์ต๋ฅ๋ ฅ, ํ๊ฒฝ์ ์ ์ํ๋ ๋ฅ๋ ฅ ๋ฑ์ผ๋ก ํ๊ฐํ ์ ์๋ค.
โ ๊ฐ๊ด์ ์ธ ๋ฐฉ์ : AgentBench

โช๏ธ ์นญํ๋์ Xiao Liu์ Hao Yu๋ 8๊ฐ์ ์์ ์์ LLM Agent๋ฅผ ํ๊ฐํ ์ ์๋ ํ๊ฐ์ฉ ๋ฐ์ดํฐ์ ์ธ AgentBench๋ฅผ ๊ตฌ์ถํ๋ค. ํ๋์ ์์ ์ผ๋ก ํ๊ฐํ๋ ๊ฒ์ด ์๋๋ผ, 8๊ฐ์ ์์ ์ผ๋ก ํ๊ฐํ๋ฏ๋ก ์ผ๋ฐํ์ฑ๋ฅ์ ํ์ธํ ์ ์๋ค๋ ์ฅ์ ์ด ์๋ค.
โช๏ธ ์ค์ ์์ด์ ํธ๊ฐ ํ์ฉ๋ ๊ฐ๋ฅ์ฑ์ด ๋์ 8๊ฐ ํ๊ฒฝ์ ์ ํํ๋ค : ํฐ๋ฏธ๋์ ํตํด ์ด์์ฒด์ ๋ฅผ ๋ค๋ฃจ๋ ์์ , DB๋ฅผ ๋ค๋ฃจ๊ธฐ ์ํ SQL ์์ฑ ์์ , ์ง์๊ทธ๋ํ๋ฅผ ๋ค๋ฃจ๋ ์์ , ๊ฒ์๊ด๋ จ ์์ , ์นํ๋ ๊ด๋ จ ์์ ๋ฑ

โช๏ธ ๊ตฌ์ถํ 8๊ฐ ๋ฐ์ดํฐ์ ์ ๋ฐํ์ผ๋ก ๋ค์ํ API ๊ธฐ๋ฐ ์์ฉ LLM๊ณผ ์คํ์์ค LLM์ ๋น๊ตํ ๊ฒฐ๊ณผ, ์คํ์์ค๋ณด๋ค ์์ฉ LLM์ด ๋ ์ฐ์ํ๋ค.
โช๏ธ ๋์ ์ ์๋ฅผ ๋ฐ์ ๋ชจ๋ธ์ ์ฃผ๋ก ์ฝ๋ ๋ฐ์ดํฐ๋ก ํ์ตํ๊ฑฐ๋, ๊ณ ํ์ง์ ์ ๋ ฌ ๋ฐ์ดํฐ์ (alignment dataset : ์ฌ์ฉ์์ ์์ฒญ์ ๋ง์ถฐ ์๋ตํ๋๋ก ๊ตฌ์ถํ ๋ฐ์ดํฐ์ )์ผ๋ก ์ง๋ ๋ฏธ์ธ์กฐ์ ์ ํ ๊ฒฝ์ฐ์๋ค. ๋ฎ์ ์ ์๋ฅผ ๋ฐ์ ๊ฒฝ์ฐ๋ ์ฃผ๋ก ๋ํ๊ฐ ์ฌ๋ฌ ํด์ ๊ฑธ์ณ ์งํ๋๋ฉฐ ์ถ๋ก ๋ฐ ์์ฌ๊ฒฐ์ ๋ฅ๋ ฅ์ด ๋จ์ด์ง๋ ๊ฒฝ์ฐ์ ์์ฒญํ ์ถ๋ ฅ ํ์์ผ๋ก ์๋ตํ์ง ์์ ๊ฒฝ์ฐ๊ฐ ๋ง์๋ค.
4. ์ค์ต : ์์ด์ ํธ ๊ตฌํ
4.1 AutoGen ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
โ OpenAI API key ์ค์
import json
openai_api_key = "์์ ์ API ํค ์
๋ ฅ"
with open('OAI_CONFIG_LIST.json', 'w') as f:
config_list = [
{
"model": "gpt-4-turbo-preview",
"api_key": openai_api_key
},
{
"model": "gpt-4o",
"api_key": openai_api_key,
},
{
"model": "dall-e-3",
"api_key": openai_api_key,
}
]
json.dump(config_list, f)
โช๏ธ gpt-4-turbo (์ธ์ด๋ชจ๋ธ), gpt-4o (๋ฉํฐ๋ชจ๋ฌ๋ชจ๋ธ), dall-e-3 (ํ ์คํธ๋ฅผ ํตํด ์ด๋ฏธ์ง ์์ฑ) ์ธ ๊ฐ ๋ชจ๋ธ์ ์ฌ์ฉํ๋๋ฐ ๋ชจ๋ OpenAI ๋ชจ๋ธ์ด๋ฏ๋ก API ํค๋ ๋์ผํ ๊ฐ์ผ๋ก ์ ๋ ฅํ๋ค.
โ ์์ด์ ํธ์ ์ฌ์ฉํ ์ค์ ๋ถ๋ฌ์ค๊ธฐ
import autogen
config_list = autogen.config_list_from_json(
"OAI_CONFIG_LIST.json",
file_location=".",
filter_dict={
"model": ["gpt-4-turbo-preview"],
},
)
llm_config = {
"config_list": config_list,
"temperature": 0,
}
โช๏ธ config_list_from_json ๋ฉ์๋๋ก ๋ชจ๋ธ๊ณผ API ํค ์ค์ ํ์ผ์ ๋ถ๋ฌ์ค๋ฉด์ gpt-4-turbo preview ๋ชจ๋ธ์ ํค๋ง ๋ถ๋ฌ์ค๋๋ก ํ๊ณ , ๋ชจ๋ธ๊ณผ ํค๋ฅผ ์ ์ฅํ config_list ๋ณ์๋ฅผ OpenAI API๋ฅผ ํธ์ถํ ๋ ์ฌ์ฉํ llm_config ๋ณ์์ ์ ์ฅํ๋ค.
โ UserProxyAgent, Assistant Agent
โช๏ธ Autogen์๋ ํฌ๊ฒ ๋ ์ข ๋ฅ์ ์์ด์ ํธ๊ฐ ์๋ค. ์ฌ์ฉ์์ ์ญํ ์ ๋์ ํ๋ UserProxyAgent๊ฐ ์๊ณ , ์ฌ์ฉ์์ ์์ฒญ์ ์ฒ๋ฆฌํ๋ AssistantAgent๊ฐ ์๋ค.
from autogen import AssistantAgent, UserProxyAgent
# ์ฌ์ฉ์์ ์์ฒญ์ ์ฒ๋ฆฌํ assistant
assistant = AssistantAgent("assistant", llm_config=llm_config)
# ์ฌ์ฉ์ ์ญํ ์ agent
user_proxy = UserProxyAgent("user_proxy",
is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),
human_input_mode="NEVER",
code_execution_config={"work_dir": "coding", "use_docker": False})
## human_input_mode : ์ฌ์ฉ์์ ์
๋ ฅ์ ์ถ๊ฐ๋ก ๋ฐ์์ง ์ค์ ํ๋ ์ธ์๋ก, NEVER๋ฅผ ์ค์ ํ๊ธฐ ๋๋ฌธ์ ์ฌ์ฉ์์ ์ถ๊ฐ์ ์ธ ์๊ฒฌ์ ๋ฌป์ง ์๊ณ ์ต์ข
๊ฒฐ๊ณผ๊ฐ ๋ฐํ๋ ๋๊น์ง ์์์ ์คํ
## is_termination_msg : ์์ด์ ํธ์๋ต์ ์ข
๋ฃ ์ ํธ (TERMINATE) ๊ฐ ํฌํจ๋์๋์ง ํ์ธํ๊ธฐ ์ํด ์ค์
โช๏ธ AutoGen์ ์์ด์ ํธ๊ฐ ์์ฑํ ํ์ด์ฌ ์ฝ๋๋ฅผ ๋ด๋ถ์ ์ผ๋ก ์คํํ๋ฉฐ ๋ชฉํ๋ฅผ ๋ฌ์ฑํ๋์ง ํ์ธํ๋๋ฐ, ์ด๋ ํ์ด์ฌ์ Docker ๋ด๋ถ์์ ์คํํ ์ง ๊ฒฐ์ ํ ์ ์๋ค. AutoGen์ ๋์ปค์์ ์คํํ๋ ๊ฒ์ ๊ถ์ฅํ๊ณ ๊ธฐ๋ณธ๊ฐ์ด์ง๋ง, ์ค์ต ํธ์๋ฅผ ์ํด use_docker ๋ฅผ false๋ก ์ค์ ํ๋ค.
โ๏ธ Docker

์์ด์ ํธ๊ฐ ์์ฑํ ํ์ด์ฌ ์ฝ๋๋ฅผ ์คํํ ๋ ์ผ๋ฐ์ ์ธ ์ปดํจํฐ ํ๊ฒฝ์ด ์๋, ๋์ปค(Docker) ์ปจํ ์ด๋๋ผ๋ ๊ฒฉ๋ฆฌ๋ ํ๊ฒฝ ์์์ ์คํํ๋ค๋ ์๋ฏธ. ๋์ปค๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ๊ทธ ์คํ์ ํ์ํ ๋ชจ๋ ๊ฒ(์ฝ๋, ๋ฐํ์, ์์คํ ๋๊ตฌ, ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฑ)์ ์ปจํ ์ด๋๋ผ๋ ํ์คํ๋ ๋จ์๋ก ๋ฌถ์ด์ฃผ๋ ํ๋ซํผ์ผ๋ก ์ด๋ค ํ๊ฒฝ์ด๋ ๋์ผํ๊ฒ ์คํ๋ ์ ์๋๋ก ๊ฒฉ๋ฆฌ๋ ํ๊ฒฝ์ ์ ๊ณตํ๋ค.
โ ์ผ์ฑ์ ์ 3๊ฐ์ ์ฃผ์ ๊ฐ๊ฒฉ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ๋ ์์ ์คํ
user_proxy.initiate_chat(assistant, message="""
์ผ์ฑ์ ์์ ์ง๋ 3๊ฐ์ ์ฃผ์ ๊ฐ๊ฒฉ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ ค์ samsung_stock_price.png ํ์ผ๋ก ์ ์ฅํด์ค.
plotly ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๊ณ ๊ทธ๋ํ ์๋๋ฅผ ํฌ๋ช
ํ ๋
น์์ผ๋ก ์ฑ์์ค.
๊ฐ์ ์ ํ์ธํ ์ ์๋๋ก y์ถ์ ๊ตฌ๊ฐ ์ต์๊ฐ์์ ์์ํ๋๋ก ํด์ค.
์ด๋ฏธ์ง ๋น์จ์ ๋ณด๊ธฐ ์ข๊ฒ ์ ์ ํ ์ค์ ํด์ค.
""")
โช๏ธ ์ฌ์ฉ์ ์ญํ ์ ์ํํ๋ user_proxy์ initiate_chat ๋ฉ์๋์ ์์ ์ ์ํํ ์์ด์ ํธ์ธ assistant๋ฅผ ์ ๋ฌํ๊ณ , ์ํํ ์์ ์ message ์ธ์์ ๋ฌธ์์ด๋ก ์ ๋ฌํ๋ค.

โช๏ธ ์ฌ์ฉ์ ์ญํ ์ ์์ด์ ํธ๊ฐ ๋ช ๋ น์ ์ด์์คํดํธ ์์ด์ ํธ์ ์ ๋ฌํ๊ณ , ์ด์์คํดํธ๋ ๋ชฉํ๋ฅผ ๋ฌ์ฑํ ์ ์๋ ์ฝ๋๋ฅผ ์์ฑํ๊ณ ์ฝ๋๋ฅผ ์คํํ๋ผ๊ณ ์๋ตํ๋ค. ์ฌ์ฉ์ ์ญํ ์ ์์ด์ ํธ๋ ์ ๋ฌ๋ฐ์ ์ฝ๋๋ฅผ ์คํํ๊ณ ์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด ๊ทธ ๋ด์ฉ์ ๋ค์ ์ ๋ฌํ๋ค. ์ด์์คํดํธ ์์ด์ ํธ๋ ์๋ฌ๋ฅผ ํด๊ฒฐํ ์ ์๋๋ก ์ฝ๋๋ฅผ ์์ ํ๋ค. ์ด ๊ณผ์ ์ ๋ฐ๋ณตํ๋ฉฐ ์ฝ๋๋ฅผ ์์ฑํ๋ค.
โช๏ธ ์์ด์ ํธ ์คํ์ด ์ฑ๊ณต์ ์ผ๋ก ๋๋๋ฉด, coding ํด๋๋ผ๋ ๊ณณ์ ์คํํ ํ์ด์ฌ ์ฝ๋์ ์ด๋ฏธ์ง๊ฐ ์ ์ฅ๋๋ค.
4.2 RAG Agent
โ RAG Agent class๋ฅผ ์ฌ์ฉํ ์์ ์คํ
โช๏ธ ์์ด์ ํธ๋ LLM์ ํ์ฉํ๋ฏ๋ก ๊ด๋ จ๋ ์ ๋ณด๊ฐ ํ๋กฌํํธ์ ์ถ๊ฐ๋์๋์ง ์ฌ๋ถ์ ๋ฐ๋ผ ์ฑ๋ฅ์ด ํฌ๊ฒ ๋ฌ๋ผ์ง๋ค.
import autogen
from autogen.agentchat.contrib.retrieve_assistant_agent import RetrieveAssistantAgent
from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent
assistant = RetrieveAssistantAgent(
name="assistant",
system_message="You are a helpful assistant.",
llm_config=llm_config,
)
ragproxyagent = RetrieveUserProxyAgent(
name="ragproxyagent",
retrieve_config={
"task": "qa",
"docs_path": "https://raw.githubusercontent.com/microsoft/autogen/main/README.md",
"collection_name": "default-sentence-transformers"
},
)
assistant.reset()
ragproxyagent.initiate_chat(assistant, problem="AutoGen์ด ๋ญ์ผ?")
# assistant (to ragproxyagent):
# AutoGen์ ์ฌ๋ฌ ์์ด์ ํธ๊ฐ ์ํธ ๋ํํ์ฌ ์์
์ ํด๊ฒฐํ ์ ์๋ LLM(Large Language Model) ์ ํ๋ฆฌ์ผ์ด์
๊ฐ๋ฐ์ ๊ฐ๋ฅํ๊ฒ ํ๋ ํ๋ ์์ํฌ์
๋๋ค.
# AutoGen ์์ด์ ํธ๋ ์ฌ์ฉ์ ์ ์ ๊ฐ๋ฅํ๋ฉฐ, ๋ํ ๊ฐ๋ฅํ๊ณ , ์ธ๊ฐ ์ฐธ์ฌ๋ฅผ ์ํํ๊ฒ ํ์ฉํฉ๋๋ค. LLM, ์ธ๊ฐ ์
๋ ฅ, ๋๊ตฌ์ ์กฐํฉ์ ์ฌ์ฉํ๋ ๋ค์ํ ๋ชจ๋์์ ์๋ํ ์ ์์ต๋๋ค.
โช๏ธ RetrieveAssistantAgent, RetrieveUserProxyAgent : RAG ์์ด์ ํธ๋ฅผ ๊ตฌํํ๊ธฐ ์ํ ์์ด์ ํธ ํด๋์ค
โช๏ธ ragproxyagent : ์ฌ์ฉ์ ์ญํ ์์ด์ ํธ๋ฅผ ์ ์ํ๋ฉด์, AutoGen ๊นํ๋ธ ๋ฉ์ธ ํ์ด์ง ์ฃผ์๋ฅผ RAG์ ํ์ฉํ๋๋ก docs_path ํค๋ก ์ ๋ ฅํด์ค๋ค. initiate_chat์ AutoGen ์ ๋ํ ์ง๋ฌธ์ ์คํํ๋ฉด, ์๋ ์ฃผ์๋ด์ฉ์ฒ๋ผ AutoGen์ ๋ํ ์ค๋ช ์ด ์ ๋์จ ๊ฒ์ ํ์ธํ ์ ์๋ค.
โ OpenAI ์๋ฒ ๋ฉ ๋ชจ๋ธ์ ์ฌ์ฉํ๋๋ก ์ค์ ํ๊ธฐ
from chromadb.utils import embedding_functions
openai_ef = embedding_functions.OpenAIEmbeddingFunction(
api_key=openai_api_key,
model_name="text-embedding-3-small"
)
ragproxyagent = RetrieveUserProxyAgent(
name="ragproxyagent",
is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),
human_input_mode="NEVER",
retrieve_config={
"task": "qa",
"docs_path": "https://raw.githubusercontent.com/microsoft/autogen/main/README.md",
"embedding_function": openai_ef,
"collection_name": "openai-embedding-3",
},
)
assistant.reset()
ragproxyagent.initiate_chat(assistant, problem="Autogen์ด ๋ญ์ผ?")
# assistant (to ragproxyagent):
# AutoGen์ ์ฌ๋ฌ ์์ด์ ํธ๊ฐ ์ํธ ๋ํํ์ฌ ์์
์ ํด๊ฒฐํ ์ ์๋ LLM(Large Language Model) ์ ํ๋ฆฌ์ผ์ด์
๊ฐ๋ฐ์ ๊ฐ๋ฅํ๊ฒ ํ
โช๏ธ AutoGen์์ RAG๋ฅผ ๊ตฌํํ ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ ์คํธ ์๋ฒ ๋ฉ ๋ชจ๋ธ๋ก๋ Sentence-Transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๊ณ , ๋ฒกํฐ DB๋ก๋ Chroma๋ฅผ ์ฌ์ฉํ๋ค.
โช๏ธ ๊ฐ ์์๋ ์ํ๋๋๋ก ๋ณ๊ฒฝ์ด ๊ฐ๋ฅํ๋ค. ์์ ์ฝ๋ ์์ ๋ embedding_functions ํจ์์ ์ํ๋ ํ ์คํธ ์๋ฒ ๋ฉ ๋ชจ๋ธ๋ก ๋ณ๊ฒฝ(text-embedding-3-small) ํ๋ ์์์ด๋ค.
โ 3๊ฐ ์ด์์ ์์ด์ ํธ๊ฐ ํ์
ํ๋ ๊ทธ๋ฃน์ฑ ๋ง๋ค๊ธฐ
def termination_msg(x):
return isinstance(x, dict) and "TERMINATE" == str(x.get("content", ""))[-9:].upper()
# RAG๋ฅผ ์ฌ์ฉํ์ง ์๋ ์ฌ์ฉ์ ์ญํ ์์ด์ ํธ
user = autogen.UserProxyAgent(
name="Admin",
is_termination_msg=termination_msg,
human_input_mode="NEVER",
system_message="The boss who ask questions and give tasks.",
code_execution_config=False,
default_auto_reply="Reply `TERMINATE` if the task is done.",
)
# RAG๋ฅผ ์ฌ์ฉํ๋ ์ฌ์ฉ์ ์ญํ ์์ด์ ํธ
user_rag = RetrieveUserProxyAgent(
name="Admin_RAG",
is_termination_msg=termination_msg,
system_message="Assistant who has extra content retrieval power for solving difficult problems.",
human_input_mode="NEVER",
max_consecutive_auto_reply=3,
code_execution_config=False,
retrieve_config={
"task": "code",
"docs_path": "https://raw.githubusercontent.com/microsoft/autogen/main/samples/apps/autogen-studio/README.md",
"chunk_token_size": 1000,
"collection_name": "groupchat-rag",
}
)
# ํ๋ก๊ทธ๋๋จธ ์ญํ ์ ์์ด์ ํธ
coder = AssistantAgent(
name="Senior_Python_Engineer",
is_termination_msg=termination_msg,
system_message="You are a senior python engineer. Reply `TERMINATE` in the end when everything is done.",
llm_config=llm_config,
)
# ํ๋ก๋ํธ ๋งค๋์ ์ญํ ์ ์์ด์ ํธ
pm = autogen.AssistantAgent(
name="Product_Manager",
is_termination_msg=termination_msg,
system_message="You are a product manager. Reply `TERMINATE` in the end when everything is done.",
llm_config=llm_config,
)
PROBLEM = "AutoGen Studio๋ ๋ฌด์์ด๊ณ AutoGen Studio๋ก ์ด๋ค ์ ํ์ ๋ง๋ค ์ ์์๊น?"
โช๏ธ ์ด 4๊ฐ์ ์์ด์ ํธ ์ ์ (RAG๋ฏธ์ฌ์ฉ ์์ด์ ํธ, RAG์ฌ์ฉ ์์ด์ ํธ-autogen๊นํ๋งํฌ์ ๋ฌ, ํ์ด์ฌ ํ๋ก๊ทธ๋๋จธ ์ญํ ์ ์์ด์ ํธ coder, ํ๋ก๋ํธ ๋งค๋์ ์ญํ ์ ์์ด์ ํธ pm)
โช๏ธ PROBLEM ์ง๋ฌธ์ ๋ต๋ณํ๊ธฐ ์ํด ํ๋ ฅ์ ์งํํจ
def _reset_agents():
user.reset()
user_rag.reset()
coder.reset()
pm.reset()
def rag_chat():
_reset_agents()
groupchat = autogen.GroupChat(
agents=[user_rag, coder, pm],
messages=[], max_round=12, speaker_selection_method="round_robin"
)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
user_rag.initiate_chat(
manager,
problem=PROBLEM,
)
def norag_chat():
_reset_agents()
groupchat = autogen.GroupChat(
agents=[user, coder, pm],
messages=[],
max_round=12,
speaker_selection_method="auto",
allow_repeat_speaker=False,
)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
user.initiate_chat(
manager,
message=PROBLEM,
)
โช๏ธ rag_chat : RAG๋ฅผ ์ฌ์ฉํ๋ user_rag, coder, pm์ด ๋ํ๋ฅผ ๋๋
โช๏ธ norag_chat : RAG๋ฅผ ์ฌ์ฉํ์ง ์๋ user, coder, pm์ด ๋ํ๋ฅผ ๋๋
โช๏ธ autogen.GroupChat : ํด๋น ํด๋์ค๋ก ๋๊ฐ ๋ํ์ ์ฐธ์ฌํ๋์ง, ๋ฐํ์๋ ์ด๋ป๊ฒ ์ ์ ํ ์ง (speaker_selection_method), ์ต๋ ๋ช๋ฒ์ ๋ํ๋ฅผ ์งํํ ์ง (max_round) ๋ฑ ์ธ์๋ฅผ ์ค์ ํ๋ค.
โช๏ธ autogen.GroupChatManager : ๊ทธ๋ฃน์ฑ ๋ํ๋ฅผ ๊ด๋ฆฌํ๋ ๋งค๋์ ๋ฅผ ์ง์ ํ๋ ๊ณผ์ ์ผ๋ก, ์์ ์ ์ํ ๊ทธ๋ฃน์ฑ์ ์ ๋ฌํ๋ฉด ๋๋ค. initate_chat ๋ฉ์๋๋ฅผ ํตํด ๋ํ๋ฅผ ์์ํ๋ฉด ๋๋ค.

โช๏ธ ์คํ ๊ฒฐ๊ณผ, norag_chat ์์๋ AutoGen ์คํ๋์ค์ ๋ํด ์ ์์ง ๋ชปํ์ฌ AutoGen์ด ์๋ํ๋ ์ฝ๋ ์์ฑ ๋๊ตฌ๋ผ๊ณ ์๊ฐํ๊ณ ์๋ ๊ฒ์ ์ ์ ์๋ค. RAG๋ฅผ ์ฌ์ฉํ rag_chat ๊ฒฐ๊ณผ๋ ์ ์ค๋ช ํ๊ณ ์์์ ๋ณผ ์ ์๋ค.
4.3 ๋ฉํฐ๋ชจ๋ฌ ์์ด์ ํธ
โ ๋ฉํฐ๋ชจ๋ฌ Agent ๊ตฌํ
import os
import re
import time
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
import matplotlib.pyplot as plt
import PIL
import requests
from openai import OpenAI
from PIL import Image
from autogen import Agent, AssistantAgent, ConversableAgent, UserProxyAgent
from autogen.agentchat.contrib.img_utils import _to_pil, get_image_data
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
config_list_4o = autogen.config_list_from_json(
"OAI_CONFIG_LIST.json",
filter_dict={
"model": ["gpt-4o"],
},
)
config_list_dalle = autogen.config_list_from_json(
"OAI_CONFIG_LIST.json",
filter_dict={
"model": ["dall-e-3"],
},
)
โช๏ธ ๋ฉํฐ๋ชจ๋ฌ๋ชจ๋ธ์ ํ์ฉํ๋ฉด ํ ์คํธ์ ์ด๋ฏธ์ง ์ ๋ ฅ์ ํจ๊ป ์ฒ๋ฆฌํ๋ ์์ด์ ํธ ๊ตฌํ์ด ๊ฐ๋ฅ : gpt-4o์ dall-e3๋ชจ๋ธ๋ก ํ ์คํธ๋ฅผ ์ ๋ ฅํ์ ๋ ํ ์คํธ์ ๋ง๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๊ณ ์ด๋ฏธ์ง๋ฅผ ์ ๋ ฅํ๋ฉด ์ด๋ฏธ์ง์ ์ ์ฌํ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ๋ฉํฐ๋ชจ๋ฌ์์ด์ ํธ ๋ง๋ค๊ธฐ ์ค์ต ์งํ
def dalle_call(client, prompt, model="dall-e-3", size="1024x1024", quality="standard", n=1) -> str:
response = client.images.generate(
model=model,
prompt=prompt,
size=size,
quality=quality,
n=n,
)
image_url = response.data[0].url
img_data = get_image_data(image_url)
return img_data
class DALLEAgent(ConversableAgent):
def __init__(self, name, llm_config: dict, **kwargs):
super().__init__(name, llm_config=llm_config, **kwargs)
try:
config_list = llm_config["config_list"]
api_key = config_list[0]["api_key"]
except Exception as e:
print("Unable to fetch API Key, because", e)
api_key = os.getenv("OPENAI_API_KEY")
self.client = OpenAI(api_key=api_key)
self.register_reply([Agent, None], DALLEAgent.generate_dalle_reply)
def generate_dalle_reply(self, messages, sender, config):
client = self.client if config is None else config
if client is None:
return False, None
if messages is None:
messages = self._oai_messages[sender]
prompt = messages[-1]["content"]
img_data = dalle_call(client=self.client, prompt=prompt)
plt.imshow(_to_pil(img_data))
plt.axis("off")
plt.show()
return True, 'result.jpg'
โช๏ธ DALLEAgent์ ๋ชจ๋ธ API์์ฒญ์ ์ฌ์ฉํ๋ dalle_call ํจ์ ์ ์
โช๏ธ dalle_call : ์ ๋ ฅ ํ๋กฌํํธ๋ฅผ OpenAI์ DALL-E API์ ์ ๋ฌํด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ค. get_image_data ํจ์๋ฅผ ํตํด ๋ด๋ ค๋ฐ์ img_data ๋ณ์์ ์ ์ฅํ๊ณ ๋ฐํ
โช๏ธ DALLEAgent ๋ OpenAI ํด๋ผ์ด์ธํธ๋ฅผ ๊ด๋ฆฌํ๊ณ generate_dalle_reply ๋ฉ์๋๋ฅผ ํตํด ๋ํ ๋ฉ์์ง๋ก ๋ฐ์ ํ๋กฌํํธ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑ
painter = DALLEAgent(name="Painter", llm_config={"config_list": config_list_dalle})
user_proxy = UserProxyAgent(
name="User_proxy", system_message="A human admin.", human_input_mode="NEVER", max_consecutive_auto_reply=0
)
# ์ด๋ฏธ์ง ์์ฑ ์์
์คํํ๊ธฐ
user_proxy.initiate_chat(
painter,
message="๊ฐ์์ ํธ์ ๊ฐ์ง ๊ท์ฌ์ด ๊ฐ์์ง๋ฅผ ๊ทธ๋ ค์ค",
)
โช๏ธ painter ๋ณ์์ ์ด๋ฏธ์ง ์์ฑ ์์ด์ ํธ๋ฅผ ์ธ์คํด์คํํ๊ณ ์ฌ์ฉ์ ์ญํ ์์ด์ ํธ๋ฅผ ํตํด ์์ฒญ์ ์ ๋ฌํ๋ค.

โ ์ด๋ฏธ์ง๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ๋ GPT-4o ์์ด์ ํธ ์์ฑ
โช๏ธ DALLEAgent๋ ํ ์คํธ๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์๋ค. ์ด๋ฏธ์ง๋ ์ ๋ ฅ์ผ๋ก ๋ฃ์์ ์๋ GPT-4o ์์ด์ ํธ
image_agent = MultimodalConversableAgent(
name="image-explainer",
system_message="Explane input image for painter to create similar image.",
max_consecutive_auto_reply=10,
llm_config={"config_list": config_list_4o, "temperature": 0.5, "max_tokens": 1500},
)
user_proxy = autogen.UserProxyAgent(
name="User_proxy",
system_message="A human admin.",
human_input_mode="NEVER",
max_consecutive_auto_reply=0,
code_execution_config=False
)
groupchat = autogen.GroupChat(agents=[user_proxy, image_agent, painter], messages=[], max_round=12)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
user_proxy.initiate_chat(
manager,
message=f"""์๋ ์ด๋ฏธ์ง๋ ๋น์ทํ ์ด๋ฏธ์ง๋ฅผ ๋ง๋ค์ด์ค.
<img https://th.bing.com/th/id/R.422068ce8af4e15b0634fe2540adea7a?rik=y4OcXBE%2fqutDOw&pid=ImgRaw&r=0>.""",
)
user_proxy.initiate_chat(
manager,
message="๊ฐ์์ ํธ์ ๊ฐ์ง ๊ท์ฌ์ด ๊ฐ์์ง๋ฅผ ๊ทธ๋ ค์ค",
)
โช๏ธ MultimodalConversableAgent ํด๋์ค๋ฅผ ์ฌ์ฉํ์ฌ, ์์ด์ ํธ๋ฅผ ์์ฑํ๋ค.
โช๏ธ image_agent (gpt4o)๋ ์ ๋ ฅ๋ ์ด๋ฏธ์ง๋ฅผ ์ค๋ช ํ๋ ํ ์คํธ๋ฅผ ์์ฑํ๋ ์ญํ ์ ํ๋ค.
โช๏ธ system_message๋ก painter (DALLEAgent)๊ฐ ์ ๋ ฅ๋ ์ด๋ฏธ์ง์ ์ ์ฌํ ๊ทธ๋ฆผ์ ๊ทธ๋ฆด ์ ์๋๋ก ์ ๋ ฅ ์ด๋ฏธ์ง๋ฅผ ์ค๋ช ํ๋ผ๊ณ ์ง์ํจ. ๊ทธ๋ฃน์ฑ ๊ธฐ๋ฅ์ ํตํด ์ฌ์ฉ์ ์ญํ ์์ด์ ํธ์ image_agent, painter๊ฐ ํจ๊ป ๋ํ๋ฅผ ๋๋๋๋ก ํ๋ค.
โช๏ธ ์ ๋ฌํ ์ด๋ฏธ์ง์ ๋น์ทํ ์ด๋ฏธ์ง ์ฌ์ง์ ๊ทธ๋ ค๋ฌ๋ผ๊ณ ํ๋ฉด ์ ์ฌํ ์ด๋ฏธ์ง๋ฅผ ๊ทธ๋ ค์ค๋ค. ์ด๋, image-explainer ๊ฐ ๊ทธ๋ฆผ์ ๋ํด ์ค๋ช ํด์ฃผ๋ ๋ด์ฉ๋ ํ์ธํ ์ ์๋ค.
'1๏ธโฃ AIโขDS > ๐ LLM' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| 14. ๋ฉํฐ๋ชจ๋ฌLLM (0) | 2025.11.12 |
|---|---|
| 13. LLM ์ด์ํ๊ธฐ (0) | 2025.10.27 |
| 12. ๋ฒกํฐ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ก ํ์ฅํ๊ธฐ : RAG ๊ตฌํํ๊ธฐ (0) | 2025.10.22 |
| 11. ์์ ์ ๋ฐ์ดํฐ์ ๋ง์ถ ์๋ฒ ๋ฉ ๋ชจ๋ธ ๋ง๋ค๊ธฐ : RAG ๊ฐ์ ํ๊ธฐ (0) | 2025.10.19 |
| [์ฑ ์คํฐ๋] 10-(2). ์ค์ต : ์๋ฏธ๊ฒ์ ๊ตฌํํ๊ธฐ (0) | 2025.09.19 |
๋๊ธ