# ISOPro: Pro Tools for Intelligent Simulation Orchestration for Large Language Models
ISOPRO is a powerful and flexible Python package designed for creating, managing, and analyzing simulations involving Large Language Models (LLMs). It provides a comprehensive suite of tools for reinforcement learning, conversation simulations, adversarial testing, custom environment creation, and advanced orchestration of multi-agent systems.
## Features
- **Custom Environment Creation**: Easily create and manage custom simulation environments for LLMs
- **Conversation Simulation**: Simulate and analyze conversations with AI agents using various user personas
- **Adversarial Testing**: Conduct adversarial simulations to test the robustness of LLM-based systems
- **Reinforcement Learning**: Implement and experiment with RL algorithms in LLM contexts
- **Workflow Automation**: Learn and replicate UI workflows from video demonstrations
- **Car Environment Simulation**: Train and evaluate RL agents in driving scenarios
- **Utility Functions**: Analyze simulation results, calculate LLM metrics, and more
- **Flexible Integration**: Works with popular LLM platforms like OpenAI's GPT models, Claude (Anthropic), and Hugging Face models
- **Orchestration Simulation**: Manage and execute complex multi-agent simulations with different execution modes
## Installation
You can install isopro using pip:
```bash
pip install isopro
```
For workflow simulation features, ensure you have the required dependencies:
```bash
pip install opencv-python numpy torch stable-baselines3 gymnasium tqdm
```
If you plan to use Claude capabilities:
```bash
export ANTHROPIC_API_KEY=your_api_key_here
```
## Usage
### Adversarial Simulation
Test the robustness of AI models against adversarial attacks.
```python
from isopro.adversarial_simulation import AdversarialSimulator, AdversarialEnvironment
from isopro.agents.ai_agent import AI_Agent
import anthropic
class ClaudeAgent(AI_Agent):
def __init__(self, name):
super().__init__(name)
self.client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
def run(self, input_data):
response = self.client.messages.create(
model="claude-3-opus-20240229",
max_tokens=100,
messages=[{"role": "user", "content": input_data['text']}]
)
return response.content[0].text
# Create the AdversarialEnvironment
adv_env = AdversarialEnvironment(
agent_wrapper=ClaudeAgent("Claude Agent"),
num_adversarial_agents=2,
attack_types=["textbugger", "deepwordbug"],
attack_targets=["input", "output"]
)
# Set up the adversarial simulator
simulator = AdversarialSimulator(adv_env)
# Run the simulation
input_data = ["What is the capital of France?", "How does photosynthesis work?"]
simulation_results = simulator.run_simulation(input_data, num_steps=1)
```
### Conversation Simulation
Simulate conversations between an AI assistant and various user personas.
```python
from isopro.conversation_simulation.conversation_simulator import ConversationSimulator
# Initialize the ConversationSimulator
simulator = ConversationSimulator(
ai_prompt="You are an AI assistant created to be helpful, harmless, and honest. You are a customer service agent for a tech company. Respond politely and professionally."
)
# Run a simulation with a predefined persona
conversation_history = simulator.run_simulation("upset", num_turns=3)
# Run a simulation with a custom persona
custom_persona = {
"name": "Techie Customer",
"characteristics": ["tech-savvy", "impatient", "detail-oriented"],
"message_templates": [
"I've tried rebooting my device, but the error persists. Can you help?",
"What's the latest update on the cloud service outage?",
"I need specifics on the API rate limits for the enterprise plan."
]
}
custom_conversation = simulator.run_custom_simulation(**custom_persona, num_turns=3)
```
### Workflow Simulation
Automate UI workflows by learning from video demonstrations.
```python
from isopro.workflow_simulation import WorkflowAutomation, AgentConfig
# Basic workflow automation
automation = WorkflowAutomation(
video="path/to/workflow.mp4",
config="config.json",
output="output_dir",
logs="logs_dir"
)
automation.run()
# Advanced configuration
agent_config = AgentConfig(
learning_rate=3e-4,
pretrain_epochs=10,
use_demonstration=True,
use_reasoning=True
)
simulator = WorkflowSimulator(
video_path="path/to/video.mp4",
agent_config=agent_config,
viz_config=visualization_config,
validation_config=validation_config,
output_dir="output"
)
training_results = simulator.train_agents()
evaluation_results = simulator.evaluate_agents()
```
### Car Reinforcement Learning
Train and evaluate RL agents in driving scenarios.
```python
from isopro.car_simulation import CarRLEnvironment, LLMCarRLWrapper, CarVisualization
# Create the car environment with LLM integration
env = CarRLEnvironment()
llm_env = LLMCarRLWrapper(env)
# Initialize visualization
viz = CarVisualization(env)
# Train and visualize
observation = llm_env.reset()
for step in range(1000):
action = llm_env.get_action(observation)
observation, reward, done, info = llm_env.step(action)
viz.render(observation)
if done:
observation = llm_env.reset()
```
### Reinforcement Learning with LLM
Integrate Large Language Models with reinforcement learning environments.
```python
import gymnasium as gym
from isopro.rl.rl_agent import RLAgent
from isopro.rl.rl_environment import LLMRLEnvironment
from stable_baselines3 import PPO
from isopro.rl.llm_cartpole_wrapper import LLMCartPoleWrapper
agent_prompt = """You are an AI trained to play the CartPole game.
Your goal is to balance a pole on a moving cart for as long as possible.
You will receive observations about the cart's position, velocity, pole angle, and angular velocity.
Based on these, you should decide whether to move the cart left or right."""
env = LLMCartPoleWrapper(agent_prompt, llm_call_limit=100, api_key=os.getenv("ANTHROPIC_API_KEY"))
rl_agent = RLAgent("LLM_CartPole_Agent", env, algorithm='PPO')
# Train the model
model.learn(total_timesteps=2)
# Test the model
obs, _ = env.reset()
for _ in range(1000):
action, _ = model.predict(obs, deterministic=True)
obs, reward, done, _, _ = env.step(action)
if done:
obs, _ = env.reset()
```
### AI Orchestration
Orchestrate multiple AI agents to work together on complex tasks.
```python
from isopro.orchestration_simulation import OrchestrationEnv
from isopro.orchestration_simulation.components import LLaMAAgent, AnalysisAgent, WritingAgent
from isopro.orchestration_simulation.evaluator import Evaluator
# Create the orchestration environment
env = OrchestrationEnv()
# Add agents to the environment
env.add_component(LLaMAAgent("Research", "conduct thorough research on the impact of artificial intelligence on job markets"))
env.add_component(AnalysisAgent("Analysis"))
env.add_component(WritingAgent("Writing"))
# Define the task
task = "Prepare a comprehensive report on the impact of artificial intelligence on job markets in the next decade."
# Run simulations in different modes
modes = ['parallel', 'sequence', 'node']
results = {}
for mode in modes:
result = env.run_simulation(mode=mode, input_data={'task': task, 'run_order': 'first'})
results[mode] = result
# Evaluate the results
evaluator = Evaluator()
best_mode = evaluator.evaluate(results)
print(f"The best execution mode for this task was: {best_mode}")
```
## Documentation
For more detailed information on each module and its usage, please refer to the [full documentation](https://isopro.readthedocs.io).
## Examples
The [isopro examples](https://github.com/iso-ai/isopro_examples) repository contains Jupyter notebooks with detailed examples:
- `adversarial_example.ipynb`: Demonstrates adversarial testing of language models
- `conversation_simulation_example.ipynb`: Shows how to simulate conversations with various user personas
- `workflow_automation_example.ipynb`: Illustrates automated UI workflow learning
- `car_rl_example.ipynb`: Demonstrates car environment training scenarios
- `run_cartpole_example.ipynb`: Illustrates the integration of LLMs with reinforcement learning
- `orchestrator_example.ipynb`: Provides a tutorial on using the AI orchestration capabilities
## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
If you encounter any problems or have any questions, please [open an issue](https://github.com/iso-ai/isopro/issues) on our GitHub repository.
## Citation
If you use ISOPRO in your research, please cite it as follows:
```
@software{isopro2024,
author = {Jazmia Henry},
title = {ISOPRO: Intelligent Simulation Orchestration for Large Language Models},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/iso-ai/isopro}}
}
```
## Contact
For questions or support, please open an issue on our [GitHub issue tracker](https://github.com/iso-ai/isopro/issues).
Raw data
{
"_id": null,
"home_page": "https://github.com/iso-ai/isopro",
"name": "isopro",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "LLM, AI, simulation, reinforcement-learning, adversarial-attacks, NLP, workflow-automation, computer-vision",
"author": "Jazmia Henry",
"author_email": "Jazmia Henry <isojaz@isoai.co>",
"download_url": "https://files.pythonhosted.org/packages/d5/6d/181b3a5e80e39418f34e4602b6245e16bdc1134dc9dfaeca3c72ee75b1b7/isopro-0.1.6.tar.gz",
"platform": null,
"description": "# ISOPro: Pro Tools for Intelligent Simulation Orchestration for Large Language Models\n\nISOPRO is a powerful and flexible Python package designed for creating, managing, and analyzing simulations involving Large Language Models (LLMs). It provides a comprehensive suite of tools for reinforcement learning, conversation simulations, adversarial testing, custom environment creation, and advanced orchestration of multi-agent systems.\n\n## Features\n\n- **Custom Environment Creation**: Easily create and manage custom simulation environments for LLMs\n- **Conversation Simulation**: Simulate and analyze conversations with AI agents using various user personas\n- **Adversarial Testing**: Conduct adversarial simulations to test the robustness of LLM-based systems\n- **Reinforcement Learning**: Implement and experiment with RL algorithms in LLM contexts\n- **Workflow Automation**: Learn and replicate UI workflows from video demonstrations\n- **Car Environment Simulation**: Train and evaluate RL agents in driving scenarios\n- **Utility Functions**: Analyze simulation results, calculate LLM metrics, and more\n- **Flexible Integration**: Works with popular LLM platforms like OpenAI's GPT models, Claude (Anthropic), and Hugging Face models\n- **Orchestration Simulation**: Manage and execute complex multi-agent simulations with different execution modes\n\n## Installation\n\nYou can install isopro using pip:\n\n```bash\npip install isopro\n```\n\nFor workflow simulation features, ensure you have the required dependencies:\n\n```bash\npip install opencv-python numpy torch stable-baselines3 gymnasium tqdm\n```\n\nIf you plan to use Claude capabilities:\n\n```bash\nexport ANTHROPIC_API_KEY=your_api_key_here\n```\n\n## Usage\n\n### Adversarial Simulation\n\nTest the robustness of AI models against adversarial attacks.\n\n```python\nfrom isopro.adversarial_simulation import AdversarialSimulator, AdversarialEnvironment\nfrom isopro.agents.ai_agent import AI_Agent\nimport anthropic\n\nclass ClaudeAgent(AI_Agent):\n def __init__(self, name):\n super().__init__(name)\n self.client = anthropic.Anthropic(api_key=os.getenv(\"ANTHROPIC_API_KEY\"))\n\n def run(self, input_data):\n response = self.client.messages.create(\n model=\"claude-3-opus-20240229\",\n max_tokens=100,\n messages=[{\"role\": \"user\", \"content\": input_data['text']}]\n )\n return response.content[0].text\n\n# Create the AdversarialEnvironment\nadv_env = AdversarialEnvironment(\n agent_wrapper=ClaudeAgent(\"Claude Agent\"),\n num_adversarial_agents=2,\n attack_types=[\"textbugger\", \"deepwordbug\"],\n attack_targets=[\"input\", \"output\"]\n)\n\n# Set up the adversarial simulator\nsimulator = AdversarialSimulator(adv_env)\n\n# Run the simulation\ninput_data = [\"What is the capital of France?\", \"How does photosynthesis work?\"]\nsimulation_results = simulator.run_simulation(input_data, num_steps=1)\n```\n\n### Conversation Simulation\n\nSimulate conversations between an AI assistant and various user personas.\n\n```python\nfrom isopro.conversation_simulation.conversation_simulator import ConversationSimulator\n\n# Initialize the ConversationSimulator\nsimulator = ConversationSimulator(\n ai_prompt=\"You are an AI assistant created to be helpful, harmless, and honest. You are a customer service agent for a tech company. Respond politely and professionally.\"\n)\n\n# Run a simulation with a predefined persona\nconversation_history = simulator.run_simulation(\"upset\", num_turns=3)\n\n# Run a simulation with a custom persona\ncustom_persona = {\n \"name\": \"Techie Customer\",\n \"characteristics\": [\"tech-savvy\", \"impatient\", \"detail-oriented\"],\n \"message_templates\": [\n \"I've tried rebooting my device, but the error persists. Can you help?\",\n \"What's the latest update on the cloud service outage?\",\n \"I need specifics on the API rate limits for the enterprise plan.\"\n ]\n}\n\ncustom_conversation = simulator.run_custom_simulation(**custom_persona, num_turns=3)\n```\n\n### Workflow Simulation\n\nAutomate UI workflows by learning from video demonstrations.\n\n```python\nfrom isopro.workflow_simulation import WorkflowAutomation, AgentConfig\n\n# Basic workflow automation\nautomation = WorkflowAutomation(\n video=\"path/to/workflow.mp4\",\n config=\"config.json\",\n output=\"output_dir\",\n logs=\"logs_dir\"\n)\nautomation.run()\n\n# Advanced configuration\nagent_config = AgentConfig(\n learning_rate=3e-4,\n pretrain_epochs=10,\n use_demonstration=True,\n use_reasoning=True\n)\n\nsimulator = WorkflowSimulator(\n video_path=\"path/to/video.mp4\",\n agent_config=agent_config,\n viz_config=visualization_config,\n validation_config=validation_config,\n output_dir=\"output\"\n)\n\ntraining_results = simulator.train_agents()\nevaluation_results = simulator.evaluate_agents()\n```\n\n### Car Reinforcement Learning\n\nTrain and evaluate RL agents in driving scenarios.\n\n```python\nfrom isopro.car_simulation import CarRLEnvironment, LLMCarRLWrapper, CarVisualization\n\n# Create the car environment with LLM integration\nenv = CarRLEnvironment()\nllm_env = LLMCarRLWrapper(env)\n\n# Initialize visualization\nviz = CarVisualization(env)\n\n# Train and visualize\nobservation = llm_env.reset()\nfor step in range(1000):\n action = llm_env.get_action(observation)\n observation, reward, done, info = llm_env.step(action)\n viz.render(observation)\n \n if done:\n observation = llm_env.reset()\n```\n\n### Reinforcement Learning with LLM\n\nIntegrate Large Language Models with reinforcement learning environments.\n\n```python\nimport gymnasium as gym\nfrom isopro.rl.rl_agent import RLAgent\nfrom isopro.rl.rl_environment import LLMRLEnvironment\nfrom stable_baselines3 import PPO\nfrom isopro.rl.llm_cartpole_wrapper import LLMCartPoleWrapper\n\nagent_prompt = \"\"\"You are an AI trained to play the CartPole game. \nYour goal is to balance a pole on a moving cart for as long as possible. \nYou will receive observations about the cart's position, velocity, pole angle, and angular velocity. \nBased on these, you should decide whether to move the cart left or right.\"\"\"\n\nenv = LLMCartPoleWrapper(agent_prompt, llm_call_limit=100, api_key=os.getenv(\"ANTHROPIC_API_KEY\"))\nrl_agent = RLAgent(\"LLM_CartPole_Agent\", env, algorithm='PPO')\n\n# Train the model\nmodel.learn(total_timesteps=2)\n\n# Test the model\nobs, _ = env.reset()\nfor _ in range(1000):\n action, _ = model.predict(obs, deterministic=True)\n obs, reward, done, _, _ = env.step(action)\n if done:\n obs, _ = env.reset()\n```\n\n### AI Orchestration\n\nOrchestrate multiple AI agents to work together on complex tasks.\n\n```python\nfrom isopro.orchestration_simulation import OrchestrationEnv\nfrom isopro.orchestration_simulation.components import LLaMAAgent, AnalysisAgent, WritingAgent\nfrom isopro.orchestration_simulation.evaluator import Evaluator\n\n# Create the orchestration environment\nenv = OrchestrationEnv()\n\n# Add agents to the environment\nenv.add_component(LLaMAAgent(\"Research\", \"conduct thorough research on the impact of artificial intelligence on job markets\"))\nenv.add_component(AnalysisAgent(\"Analysis\"))\nenv.add_component(WritingAgent(\"Writing\"))\n\n# Define the task\ntask = \"Prepare a comprehensive report on the impact of artificial intelligence on job markets in the next decade.\"\n\n# Run simulations in different modes\nmodes = ['parallel', 'sequence', 'node']\nresults = {}\n\nfor mode in modes:\n result = env.run_simulation(mode=mode, input_data={'task': task, 'run_order': 'first'})\n results[mode] = result\n\n# Evaluate the results\nevaluator = Evaluator()\nbest_mode = evaluator.evaluate(results)\nprint(f\"The best execution mode for this task was: {best_mode}\")\n```\n\n## Documentation\n\nFor more detailed information on each module and its usage, please refer to the [full documentation](https://isopro.readthedocs.io).\n\n## Examples\n\nThe [isopro examples](https://github.com/iso-ai/isopro_examples) repository contains Jupyter notebooks with detailed examples:\n\n- `adversarial_example.ipynb`: Demonstrates adversarial testing of language models\n- `conversation_simulation_example.ipynb`: Shows how to simulate conversations with various user personas\n- `workflow_automation_example.ipynb`: Illustrates automated UI workflow learning\n- `car_rl_example.ipynb`: Demonstrates car environment training scenarios\n- `run_cartpole_example.ipynb`: Illustrates the integration of LLMs with reinforcement learning\n- `orchestrator_example.ipynb`: Provides a tutorial on using the AI orchestration capabilities\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you encounter any problems or have any questions, please [open an issue](https://github.com/iso-ai/isopro/issues) on our GitHub repository.\n\n## Citation\n\nIf you use ISOPRO in your research, please cite it as follows:\n\n```\n@software{isopro2024,\n author = {Jazmia Henry},\n title = {ISOPRO: Intelligent Simulation Orchestration for Large Language Models},\n year = {2024},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/iso-ai/isopro}}\n}\n```\n\n## Contact\n\nFor questions or support, please open an issue on our [GitHub issue tracker](https://github.com/iso-ai/isopro/issues).\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Intelligent Simulation Orchestration for Large Language Models",
"version": "0.1.6",
"project_urls": {
"Bug Tracker": "https://github.com/iso-ai/isopro/tree/main/.github/ISSUE_TEMPLATE.md",
"Documentation": "https://github.com/yourusername/isopro/wiki",
"Examples": "https://github.com/iso-ai/isopro_examples/tree/main/examples",
"Homepage": "https://github.com/iso-ai/isopro"
},
"split_keywords": [
"llm",
" ai",
" simulation",
" reinforcement-learning",
" adversarial-attacks",
" nlp",
" workflow-automation",
" computer-vision"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "54ec152cd401b69b5aee44e228f1d9b7ee08097e22c32a18751f856a51c90b2b",
"md5": "02df672008aa57d0afd966ed0e9ab4dc",
"sha256": "240422599698cb4b618c2b47a82f09e2f38555d037d76e80df86665c34acbe0e"
},
"downloads": -1,
"filename": "isopro-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "02df672008aa57d0afd966ed0e9ab4dc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 93759,
"upload_time": "2024-11-01T07:01:02",
"upload_time_iso_8601": "2024-11-01T07:01:02.352272Z",
"url": "https://files.pythonhosted.org/packages/54/ec/152cd401b69b5aee44e228f1d9b7ee08097e22c32a18751f856a51c90b2b/isopro-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d56d181b3a5e80e39418f34e4602b6245e16bdc1134dc9dfaeca3c72ee75b1b7",
"md5": "b5c0cd62a1a63b184d7e256c388927c2",
"sha256": "48fe70d3bf277a011d5b574804b1280514031a4ce21550ce6349f5258468fb24"
},
"downloads": -1,
"filename": "isopro-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "b5c0cd62a1a63b184d7e256c388927c2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 69251,
"upload_time": "2024-11-01T07:01:04",
"upload_time_iso_8601": "2024-11-01T07:01:04.351399Z",
"url": "https://files.pythonhosted.org/packages/d5/6d/181b3a5e80e39418f34e4602b6245e16bdc1134dc9dfaeca3c72ee75b1b7/isopro-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-01 07:01:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iso-ai",
"github_project": "isopro",
"github_not_found": true,
"lcname": "isopro"
}