Skip to content

Commit 1b2d586

Browse files
feat: add OpenAI example for autogen integration
1 parent 8925e89 commit 1b2d586

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
import autogen
3+
from langtrace_python_sdk import langtrace
4+
5+
# Initialize Langtrace
6+
langtrace.init(
7+
api_key='967b06c4d1858a7e64e58de44708d89e84f8c96a69b20f7276bcb34a7ce495af',
8+
api_host="http://localhost:3000/api/trace"
9+
)
10+
11+
# Set OpenAI API key
12+
os.environ["OPENAI_API_KEY"] = "sk-proj-dv2lt1rbQKs3qUL0Yp6VT3BlbkFJ36T4v1wH0tNmhkjQiXSe"
13+
14+
# Configure OpenAI for autogen
15+
config_list = [
16+
{
17+
"model": "gpt-3.5-turbo",
18+
"api_key": os.environ["OPENAI_API_KEY"]
19+
}
20+
]
21+
22+
# Create assistant and user agents
23+
assistant = autogen.AssistantAgent(
24+
name="Assistant",
25+
llm_config={"config_list": config_list},
26+
system_message="You are a helpful AI assistant."
27+
)
28+
29+
user_proxy = autogen.UserProxyAgent(
30+
name="User",
31+
human_input_mode="NEVER",
32+
max_consecutive_auto_reply=1,
33+
llm_config={"config_list": config_list},
34+
)
35+
36+
# Start the conversation
37+
user_proxy.initiate_chat(
38+
assistant,
39+
message="Write a Python function to calculate the first n terms of the Fibonacci sequence."
40+
)

0 commit comments

Comments
 (0)