forked from ComposioHQ/composio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenai_demo.py
More file actions
33 lines (26 loc) · 796 Bytes
/
Copy pathopenai_demo.py
File metadata and controls
33 lines (26 loc) · 796 Bytes
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
"""
OpenAI demo.
"""
from composio_openai import OpenAIProvider
from openai import OpenAI
from composio import Composio
# Initialize tools.
openai_client = OpenAI()
composio = Composio(provider=OpenAIProvider())
# Define task.
task = "Star a repo composiohq/composio on GitHub"
# Get GitHub tools that are pre-configured
tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])
# Get response from the LLM
response = openai_client.chat.completions.create(
model="gpt-4o-mini",
tools=tools,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": task},
],
)
print(response)
# Execute the function calls.
result = composio.provider.handle_tool_calls(response=response, user_id="default")
print(result)