Guides
Multiple Instances
Getting Started
Guides
Settings
Language Models
- Introduction
- Hosted Providers
- Local Providers
- Custom Models
- Settings
Code Execution
Protocols
Troubleshooting
Telemetry
Guides
Multiple Instances
To create multiple instances, use the base class, OpenInterpreter
:
from interpreter import OpenInterpreter
agent_1 = OpenInterpreter()
agent_1.system_message = "This is a separate instance."
agent_2 = OpenInterpreter()
agent_2.system_message = "This is yet another instance."
For fun, you could make these instances talk to eachother:
def swap_roles(messages):
for message in messages:
if message['role'] == 'user':
message['role'] = 'assistant'
elif message['role'] == 'assistant':
message['role'] = 'user'
return messages
agents = [agent_1, agent_2]
# Kick off the conversation
messages = [{"role": "user", "message": "Hello!"}]
while True:
for agent in agents:
messages = agent.chat(messages)
messages = swap_roles(messages)