https://github.com/microsoft/autogen
https://microsoft.github.io/autogen/docs/Getting-Started/
Microsoft์์ ๊ณต๊ฐํ Agent AutoGen
AutoGen์ Copilot์ memory๋ฅผ ์ถ๊ฐํ๋ค๊ณ ๋ณด๋ฉด๋ค. copilot์ code guide chatbot์ด๋ฉฐ ์ฝ๋๋ฅผ ํด์ํด์ฃผ๊ณ ์์ฑํด์ค๋ค. ์ฌ๊ธฐ์ AutoGen์ memory๋ฅผ ์ถ๊ฐํด ๋ด๊ฐ ์ํ๋ ์ต์ข ๋ชฉํ์ ๊ฒฐ๊ณผ๋ฌผ์ ๋๋ฌํ ์ ์๊ฒ ์ง๋ฌธ์ ํตํด ์ด์ ๋ถ์ฌ ๋ง๋ ๋ค.
AutoGen์ ์ฌ์ฉํ๋ฉด ์ต์ํ์ ๋
ธ๋ ฅ์ผ๋ก ๋ฉํฐ ์์ด์ ํธ ๋ํ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ฐจ์ธ๋ LLM ์ ํ๋ฆฌ์ผ์ด์
์ ๊ตฌ์ถํ ์ ์์ต๋๋ค. ๋ณต์กํ LLM ์ํฌํ๋ก์ฐ์ ์ค์ผ์คํธ๋ ์ด์
, ์๋ํ ๋ฐ ์ต์ ํ๋ฅผ ๊ฐ์ํํฉ๋๋ค. LLM ๋ชจ๋ธ์ ์ฑ๋ฅ์ ๊ทน๋ํํ๊ณ ์ฝ์ ์ ๊ทน๋ณตํฉ๋๋ค.
๋ณต์กํ ์ํฌํ๋ก์ฐ๋ฅผ ์ํ ๋ค์ํ ๋ํ ํจํด์ ์ง์ํฉ๋๋ค. ๊ฐ๋ฐ์๋ ์ปค์คํฐ๋ง์ด์ง์ด ๊ฐ๋ฅํ ๋ํํ ์์ด์ ํธ๋ฅผ ํตํด AutoGen์ ์ฌ์ฉํ์ฌ ๋ํ ์์จ์ฑ, ์์ด์ ํธ ์, ์์ด์ ํธ ๋ํ ํ ํด๋ก์ง์ ๊ด๋ จ๋ ๋ค์ํ ๋ํ ํจํด์ ๊ตฌ์ถํ ์ ์์ต๋๋ค.
๋ค์ํ ๋ณต์ก์ฑ์ ๊ฐ์ง ์์
์์คํ
๋ชจ์์ ์ ๊ณตํฉ๋๋ค. ์ด๋ฌํ ์์คํ
์ ๋ค์ํ ๋๋ฉ์ธ๊ณผ ๋ณต์ก์ฑ์ ๊ฐ์ง ๊ด๋ฒ์ํ ์ ํ๋ฆฌ์ผ์ด์
์ ๊ฑธ์ณ ์์ต๋๋ค. ์ด ์์คํ
๋ค์ AutoGen์ด ์ด๋ป๊ฒ ๋ค์ํ ๋ํ ํจํด์ ์ฝ๊ฒ ์ง์ํ ์ ์๋์ง ๋ณด์ฌ์ค๋๋ค.
AutoGen์ ํฅ์๋ ์ถ๋ก API๋ก์ openai.Completion ๋๋ openai.ChatCompletion์ ๋์ฒดํ ์ ์๋ ๋๋กญ์ธ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. ์ด๋ฅผ ํตํด ๊ฐํธํ ์ฑ๋ฅ ํ๋, API ํตํฉ ๋ฐ ์บ์ฑ๊ณผ ๊ฐ์ ์ ํธ๋ฆฌํฐ, ์ค๋ฅ ์ฒ๋ฆฌ, ๋ค์ค ๊ตฌ์ฑ ์ถ๋ก , ์ปจํ
์คํธ ํ๋ก๊ทธ๋๋ฐ ๋ฑ๊ณผ ๊ฐ์ ๊ณ ๊ธ ์ฌ์ฉ ํจํด์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
AutoGen์ Microsoft, ํ์ค๋ฒ ๋์ ์ฃผ๋ฆฝ๋ํ๊ต, ์์ฑํด ๋ํ๊ต์ ๊ณต๋ ์ฐ๊ตฌ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค.
์ฌ์ฉ๋ฒ
1) config List ์ ์ (์ฌ์ฉํ chatgpt ๋ชจ๋ธ๊ณผ API key setting)
* ํ๊ฒฝ ๋ณ์๋ก OPENAI_API_KEY๋ฅผ ๋ฏธ๋ฆฌ ๋ฑ๋กํด ๋์ผ๋ฉด ๋ฐ๋ก test๋ ์คํ ๊ฐ๋ฅ
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
# Load LLM inference endpoints from an env variable or a file
# See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints
# and OAI_CONFIG_LIST_sample.json
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
// Please modify the content, remove this comment and rename this file to OAI_CONFIG_LIST to run the sample code.
[
{
"model": "gpt-4",
"api_key": "<your OpenAI API key here>"
},
{
"model": "gpt-4",
"api_key": "<your Azure OpenAI API key here>",
"api_base": "<your Azure OpenAI API base here>",
"api_type": "azure",
"api_version": "2023-07-01-preview"
},
{
"model": "gpt-3.5-turbo",
"api_key": "<your Azure OpenAI API key here>",
"api_base": "<your Azure OpenAI API base here>",
"api_type": "azure",
"api_version": "2023-07-01-preview"
}
]
2) assistant (์ฌ์ฉ ๋ชจ๋ธ์ ๋ถ์ฌํ ํ), user_proxy (๋ชฉํ ํ ์คํฌ ์ ๋ฌ)
assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})
user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"})
user_proxy.initiate_chat(assistant, message="How do I make a Slack bot?")
# This initiates an automated chat between the two agents to solve the task
user_proxy (to assistant):
I want make a slack bot
--------------------------------------------------------------------------------
assistant (to user_proxy):
Alright, creating a Slack bot can be quite involved process but Python makes it a bit simpler. We would be using Python slack_sdk (previously called `slackclient`) to create the bot. Here's a simple script for you to set up a Slack bot.
First, you will need to create a bot on Slack. Here are the step-by-step procedure:
1. Visit your slack workspace (the URL would be something like: workspace-name.slack.com)
2. Click on "Apps" on the left menu next to the workspace name.
3. Click on "Build your own" on the top right of the Apps page and select "Make a Custom Integration".
4. You will be redirected to a new page. Click on "Bots".
5. Enter a username for your bot and click "Add Bot Integration".
6. Keep this page open as you will need the API Token listed here in the next steps.
SSH into your server and type following commands:
```sh
pip install slack_sdk
```
Let's create a simple bot that echoes back whatever message it receives.
```python
# filename: slack_bot.py
import slack_sdk
from slack_sdk.webhook import WebhookClient
SLACK_API_TOKEN = 'YOUR-SLACK-BOT-API-TOKEN'
def bot_send_message(channel_id, text):
client = slack_sdk.WebClient(token=SLACK_API_TOKEN)
client.chat_postMessage(channel=channel_id, text=text)
if __name__ == "__main__":
bot_send_message('CHANNEL-ID', 'Hello, World!')
```
Replace `'YOUR-SLACK-BOT-API-TOKEN'` with the API token of your bot, and replace `'CHANNEL-ID'` with the ID of the channel to which you want the bot to send the message. This bot will send 'Hello, World!' to the specified slack channel.
Note: you can find your channel ID in the URL when you click on the channel. It should be something like `https://app.slack.com/client/TXXXXXXXX/CXXXXXXXX/thread/CXXXXXXXX-XXXXXXXXX-XXXXXXXXX`. The `CXXXXXXXX` is your channel ID.
Just save this python file and run it, the bot will sent 'Hello, World!' to your channel.
```sh
python slack_bot.py
```
This is an introductory example on a Slack bot. With the API, you can achieve a lot more things such as automated responses, scheduled messages, and so on. Please carefully handle your API tokens since they are sensitive information.
I hope this helps. Let me know if you encounter any issues.
--------------------------------------------------------------------------------
Provide feedback to assistant. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:
*Provide feedback to assistant. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:
3) ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ assistant์๊ฒ feedback์ ์ ๋ฌํ๊ฑฐ๋ exit ์ข ๋ฃํ๋ค.
'๐ ๏ธ Tools > ๐ค ChatGPT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Function calling] ChatGPT custom Function ์ฌ์ฉํ๊ธฐ (feat. ์งํ์ฒ ํผ์ก๋) --- (1) (0) | 2023.12.11 |
---|---|
[GPT4V]OpenAI DevDay, Opening Keynote (0) | 2023.11.08 |
GPT-4 ์ํคํ ์ฒ, ์ธํ๋ผ, ํ๋ จ ๋ฐ์ดํฐ์ , ๋น์ฉ, ๋น์ , MoE (0) | 2023.07.18 |
[OpenAI-GPT] LangChain ํจ์จ์ ์ธ Token ๊ด๋ฆฌ (0) | 2023.05.21 |
[LLM] ChatGPT Prompt Engineering for Developers - Chatbot (0) | 2023.05.07 |