-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.py
More file actions
51 lines (42 loc) · 1.36 KB
/
basic.py
File metadata and controls
51 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
This script provides a basic setup for an AutoGen chat environment.
It demonstrates how to create a simple conversation between an assistant and a user proxy.
The script does the following:
1. Configures an AssistantAgent with specific LLM settings.
2. Sets up a UserProxyAgent with code execution capabilities.
3. Initiates a chat with a specific task related to stock price charting.
Dependencies:
- autogen
- os
- dotenv
- openai
Environment Variables:
- OPENAI_API_KEY: Your OpenAI API key
Output:
- Initiates a chat session to plot a chart of specified stock prices.
"""
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
import os
from dotenv import load_dotenv
import openai
load_dotenv()
# Import the openai api key
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
openai.api_key = os.getenv("OPENAI_API_KEY")
# Create assistant agent
assistant = AssistantAgent(
name="assistant",
llm_config={
"seed": 42,
"config_list": config_list,
"temperature": 0
}
)
# Create user proxy agent
user_proxy = UserProxyAgent(
name="user_proxy",
code_execution_config={"work_dir": "coding",
"use_docker": True})
# Start the conversation
user_proxy.initiate_chat(
assistant, message="Plot a chart of NVDA, AAPL and TESLA stock price change YTD.")