From e435aa0bb8d2ed1cce741ba0cb7194351785a539 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:48:52 -0500 Subject: [PATCH 01/34] Adds a journal with much more context for the Anthropic API's Tool System --- .../agentops-anthropic-understanding-tools.ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb diff --git a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb new file mode 100644 index 000000000..d69e56c64 --- /dev/null +++ b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! ","metadata":{}},{"cell_type":"markdown","source":"To get started, we will import Agentops and Anthropic","metadata":{}},{"cell_type":"code","source":"!pip install agentops\n!pip install anthropic","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:29.141658Z","iopub.execute_input":"2024-11-11T15:51:29.142307Z","iopub.status.idle":"2024-11-11T15:51:51.690414Z","shell.execute_reply.started":"2024-11-11T15:51:29.142260Z","shell.execute_reply":"2024-11-11T15:51:51.689249Z"},"trusted":true},"execution_count":403,"outputs":[{"name":"stdout","text":"Requirement already satisfied: agentops in /opt/conda/lib/python3.10/site-packages (0.3.17)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nRequirement already satisfied: psutil==5.9.8 in /opt/conda/lib/python3.10/site-packages (from agentops) (5.9.8)\nRequirement already satisfied: packaging==23.2 in /opt/conda/lib/python3.10/site-packages (from agentops) (23.2)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nRequirement already satisfied: anthropic in /opt/conda/lib/python3.10/site-packages (0.39.0)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nRequirement already satisfied: jiter<1,>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.7.0)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Setup our generic default statements","metadata":{}},{"cell_type":"code","source":"from anthropic import Anthropic, AsyncAnthropic\nimport agentops\nimport os\nimport random #We don't need this for agentops, we use this to generate a message later\nimport time #We don't need this for agentops either, we use this when simulating an API later\nimport re #Regex for formatting\nfrom dotenv import load_dotenv","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.692522Z","iopub.execute_input":"2024-11-11T15:51:51.692856Z","iopub.status.idle":"2024-11-11T15:51:51.698055Z","shell.execute_reply.started":"2024-11-11T15:51:51.692820Z","shell.execute_reply":"2024-11-11T15:51:51.697133Z"},"trusted":true},"execution_count":404,"outputs":[]},{"cell_type":"markdown","source":"And set our API keys.","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.699276Z","iopub.execute_input":"2024-11-11T15:51:51.699649Z","iopub.status.idle":"2024-11-11T15:51:51.710752Z","shell.execute_reply.started":"2024-11-11T15:51:51.699607Z","shell.execute_reply":"2024-11-11T15:51:51.709955Z"},"trusted":true},"execution_count":405,"outputs":[]},{"cell_type":"markdown","source":"\nNow let's set the client as Anthropic and make an AgentOps session","metadata":{}},{"cell_type":"code","source":"agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"client = Anthropic(api_key=ANTHROPIC_API_KEY)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.726061Z","iopub.execute_input":"2024-11-11T15:51:51.726434Z","iopub.status.idle":"2024-11-11T15:51:51.745524Z","shell.execute_reply.started":"2024-11-11T15:51:51.726393Z","shell.execute_reply":"2024-11-11T15:51:51.744677Z"},"trusted":true},"execution_count":407,"outputs":[]},{"cell_type":"markdown","source":"Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack.","metadata":{}},{"cell_type":"code","source":"Locations = [\n {\n \"Name\": \"Super Gore Nest\",\n \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\"\n },\n {\n \"Name\": \"Exultia\",\n \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\"\n },\n {\n \"Name\": \"Cultist Base\",\n \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"Taras Nabad\",\n \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\"\n },\n {\n \"Name\": \"Nekravol\",\n \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\"\n },\n {\n \"Name\": \"Urdak\",\n \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"UAC Base\",\n \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\"\n }\n]\n\nCombatCasualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n\nMissions = [\n \"Locate and confront a key leader of Hell’s invasion forces.\",\n \"Clear out demonic infestations to secure a strategic foothold.\",\n \"Disrupt Hell's control over the area by eliminating critical targets.\",\n \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n \"Locate and destroy the central power source to weaken enemy forces.\",\n \"Collect essential resources before the area becomes unstable.\"\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.747664Z","iopub.execute_input":"2024-11-11T15:51:51.748003Z","iopub.status.idle":"2024-11-11T15:51:51.757044Z","shell.execute_reply.started":"2024-11-11T15:51:51.747963Z","shell.execute_reply":"2024-11-11T15:51:51.754966Z"},"trusted":true},"execution_count":408,"outputs":[]},{"cell_type":"markdown","source":"Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI.","metadata":{}},{"cell_type":"code","source":"def generate_missions():\n missions = []\n loop = 0\n \n while loop < 3:\n location = random.choice(Locations)\n casualties = random.choice(CombatCasualties)\n mission = random.choice(Missions)\n final = (\n f'LocationName: {location[\"Name\"]}, '\n f'LocationInfo: {location[\"Description\"]}, '\n f'HumanCombatCasualties: {casualties}, '\n f'Mission: {mission}'\n )\n \n missions.append(final)\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n missions_string = \"\\n\".join(missions) # Or \", \".join(missions) for a comma-separated string\n print(missions_string)\n return missions_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.758536Z","iopub.execute_input":"2024-11-11T15:51:51.758780Z","iopub.status.idle":"2024-11-11T15:51:51.770825Z","shell.execute_reply.started":"2024-11-11T15:51:51.758752Z","shell.execute_reply":"2024-11-11T15:51:51.770043Z"},"trusted":true},"execution_count":409,"outputs":[]},{"cell_type":"code","source":"generate_missions()","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.771788Z","iopub.execute_input":"2024-11-11T15:51:51.772033Z","iopub.status.idle":"2024-11-11T15:51:51.784220Z","shell.execute_reply.started":"2024-11-11T15:51:51.772005Z","shell.execute_reply":"2024-11-11T15:51:51.783349Z"},"trusted":true},"execution_count":410,"outputs":[{"name":"stdout","text":"LocationName: Urdak, LocationInfo: A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth., HumanCombatCasualties: Nonexistent, Mission: Clear out demonic infestations to secure a strategic foothold.\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: Nonexistent, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: High, Mission: Disrupt Hell's control over the area by eliminating critical targets.\n","output_type":"stream"},{"execution_count":410,"output_type":"execute_result","data":{"text/plain":"\"LocationName: Urdak, LocationInfo: A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth., HumanCombatCasualties: Nonexistent, Mission: Clear out demonic infestations to secure a strategic foothold.\\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: Nonexistent, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: High, Mission: Disrupt Hell's control over the area by eliminating critical targets.\""},"metadata":{}}]},{"cell_type":"markdown","source":"Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n\nWe are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line","metadata":{}},{"cell_type":"markdown","source":"Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!","metadata":{}},{"cell_type":"code","source":"# We make our history a separate block to be easier to add to later on! This is essentially our history\ninitialmessages = initialmessages = [\n {\n \"role\": \"user\",\n \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.785451Z","iopub.execute_input":"2024-11-11T15:51:51.785792Z","iopub.status.idle":"2024-11-11T15:51:51.793099Z","shell.execute_reply.started":"2024-11-11T15:51:51.785752Z","shell.execute_reply":"2024-11-11T15:51:51.792382Z"},"trusted":true},"execution_count":411,"outputs":[]},{"cell_type":"markdown","source":"Now to construct a request!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initialmessages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.797081Z","iopub.execute_input":"2024-11-11T15:51:51.797388Z","iopub.status.idle":"2024-11-11T15:51:56.954146Z","shell.execute_reply.started":"2024-11-11T15:51:51.797357Z","shell.execute_reply":"2024-11-11T15:51:56.953227Z"},"trusted":true},"execution_count":412,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01FavorMsz4Yp8TwTgfxVEpU', content=[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01LQEsSBrbipWxkWWyLXiJkH', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=393, output_tokens=97))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Let's isolate the AI dialogue just for fun","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.955196Z","iopub.execute_input":"2024-11-11T15:51:56.955482Z","iopub.status.idle":"2024-11-11T15:51:56.960115Z","shell.execute_reply.started":"2024-11-11T15:51:56.955448Z","shell.execute_reply":"2024-11-11T15:51:56.959246Z"},"trusted":true},"execution_count":413,"outputs":[{"name":"stdout","text":"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\n\nLet's begin by retrieving the missions:\n","output_type":"stream"}]},{"cell_type":"markdown","source":"The code below finds the tool used!","metadata":{}},{"cell_type":"code","source":"GenMissionResult = \"\"\n\n# Print response content to see the data\nprint(response.content)\n\n# Assuming ToolUseBlock is at index 1\ntool_use_block = response.content[1]\n\n# Get the tool name and input\ntool_name = tool_use_block.name\ntool_input = tool_use_block.input\n\n# We don't need to look to extract any inputs since we don't use any\n\n# Check if the tool name is \"generate_missions\"\nif tool_name == \"generate_missions\":\n # Call the function with the tool creator as an argument\n GenMissionResult = generate_missions()\n ","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.961292Z","iopub.execute_input":"2024-11-11T15:51:56.961583Z","iopub.status.idle":"2024-11-11T15:51:56.974731Z","shell.execute_reply.started":"2024-11-11T15:51:56.961551Z","shell.execute_reply":"2024-11-11T15:51:56.973896Z"},"trusted":true},"execution_count":414,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01LQEsSBrbipWxkWWyLXiJkH', input={}, name='generate_missions', type='tool_use')]\nLocationName: Exultia, LocationInfo: An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces., HumanCombatCasualties: High, Mission: Locate and destroy the central power source to weaken enemy forces.\nLocationName: UAC Base, LocationInfo: A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions., HumanCombatCasualties: High, Mission: Locate and destroy the central power source to weaken enemy forces.\nLocationName: Exultia, LocationInfo: An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces., HumanCombatCasualties: Extinction, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"Now we add these as context to the LLM through intial messages!","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": GenMissionResult\n})\n\ninitialmessages.append({\n \"role\": \"user\",\n \"content\": \"Based on these, which location should take priority and why?\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.975759Z","iopub.execute_input":"2024-11-11T15:51:56.976046Z","iopub.status.idle":"2024-11-11T15:51:56.985098Z","shell.execute_reply.started":"2024-11-11T15:51:56.976002Z","shell.execute_reply":"2024-11-11T15:51:56.984354Z"},"trusted":true},"execution_count":415,"outputs":[]},{"cell_type":"markdown","source":"And now to get a response!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initialmessages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.986100Z","iopub.execute_input":"2024-11-11T15:51:56.986406Z","iopub.status.idle":"2024-11-11T15:52:07.462887Z","shell.execute_reply.started":"2024-11-11T15:51:56.986376Z","shell.execute_reply":"2024-11-11T15:52:07.462024Z"},"trusted":true},"execution_count":416,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01MBwHFvHykWyYJSZZKtDWKd', content=[TextBlock(text='Based on the missions generated, I\\'ll analyze them and prioritize them for you, DoomSlayer. Here\\'s my assessment of the importance of each mission, from most critical to least:\\n\\n1. Exultia (Mission: Enter a critical demonic stronghold to disrupt enemy operations)\\n Priority: Highest\\n Reason: This mission is the most crucial because:\\n - The human combat casualties are listed as \"Extinction,\" which indicates an extremely dire situation.\\n - The mission involves directly disrupting enemy operations by entering a critical demonic stronghold.\\n - Exultia\\'s mystical nature and connection to the Night Sentinels suggest that success here could have far-reaching implications in the fight against Hell.\\n\\n2. UAC Base (Mission: Locate and destroy the central power source to weaken enemy forces)\\n Priority: High\\n Reason: This mission is second in importance because:\\n - It\\'s on Earth, making it a critical location for humanity\\'s survival.\\n - The UAC Base is described as a human foothold in the fight against Hell.\\n - Destroying the central power source could significantly weaken the enemy\\'s presence on Earth.\\n - The human combat casualties are listed as \"High,\" indicating an urgent situation.\\n\\n3. Exultia (Mission: Locate and destroy the central power source to weaken enemy forces)\\n Priority: Moderate\\n Reason: While still important, this mission is the least critical of the three because:\\n - It\\'s similar to the UAC Base mission but on a different world.\\n - The human combat casualties are listed as \"High,\" which is severe but not as critical as the \"Extinction\" level in the first Exultia mission.\\n - While weakening enemy forces is crucial, it\\'s not as direct an action as disrupting their operations in a critical stronghold.\\n\\nIn conclusion, DoomSlayer, I recommend prioritizing the mission to enter the critical demonic stronghold on Exultia. This action has the potential to make the most significant impact on the forces of Hell and potentially prevent the extinction-level threat to humanity. The UAC Base mission should be your second priority to secure Earth, followed by the other Exultia mission to further weaken the enemy\\'s power sources.\\n\\nRemember, Slayer, the fate of humanity rests on your shoulders. Rip and tear, until it is done.', type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=696, output_tokens=528))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Isolate again!","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.464253Z","iopub.execute_input":"2024-11-11T15:52:07.464544Z","iopub.status.idle":"2024-11-11T15:52:07.469571Z","shell.execute_reply.started":"2024-11-11T15:52:07.464512Z","shell.execute_reply":"2024-11-11T15:52:07.468685Z"},"trusted":true},"execution_count":417,"outputs":[{"name":"stdout","text":"Based on the missions generated, I'll analyze them and prioritize them for you, DoomSlayer. Here's my assessment of the importance of each mission, from most critical to least:\n\n1. Exultia (Mission: Enter a critical demonic stronghold to disrupt enemy operations)\n Priority: Highest\n Reason: This mission is the most crucial because:\n - The human combat casualties are listed as \"Extinction,\" which indicates an extremely dire situation.\n - The mission involves directly disrupting enemy operations by entering a critical demonic stronghold.\n - Exultia's mystical nature and connection to the Night Sentinels suggest that success here could have far-reaching implications in the fight against Hell.\n\n2. UAC Base (Mission: Locate and destroy the central power source to weaken enemy forces)\n Priority: High\n Reason: This mission is second in importance because:\n - It's on Earth, making it a critical location for humanity's survival.\n - The UAC Base is described as a human foothold in the fight against Hell.\n - Destroying the central power source could significantly weaken the enemy's presence on Earth.\n - The human combat casualties are listed as \"High,\" indicating an urgent situation.\n\n3. Exultia (Mission: Locate and destroy the central power source to weaken enemy forces)\n Priority: Moderate\n Reason: While still important, this mission is the least critical of the three because:\n - It's similar to the UAC Base mission but on a different world.\n - The human combat casualties are listed as \"High,\" which is severe but not as critical as the \"Extinction\" level in the first Exultia mission.\n - While weakening enemy forces is crucial, it's not as direct an action as disrupting their operations in a critical stronghold.\n\nIn conclusion, DoomSlayer, I recommend prioritizing the mission to enter the critical demonic stronghold on Exultia. This action has the potential to make the most significant impact on the forces of Hell and potentially prevent the extinction-level threat to humanity. The UAC Base mission should be your second priority to secure Earth, followed by the other Exultia mission to further weaken the enemy's power sources.\n\nRemember, Slayer, the fate of humanity rests on your shoulders. Rip and tear, until it is done.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n\nOne will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)","metadata":{}},{"cell_type":"code","source":"Demons = [\n {\n \"Name\": \"Imp\",\n \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\"\n },\n {\n \"Name\": \"Cacodemon\",\n \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\"\n },\n {\n \"Name\": \"Hell Knight\",\n \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\"\n },\n {\n \"Name\": \"Mancubus\",\n \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\"\n },\n {\n \"Name\": \"Baron of Hell\",\n \"Description\": \"A large, heavily armored demon wielding twin plasma cannons, capable of charging and throwing devastating shockwaves. The Baron of Hell is one of Hell’s elite warriors, combining brute strength and ranged firepower.\"\n },\n {\n \"Name\": \"Pinky\",\n \"Description\": \"A fast, aggressive demon with a large, muscular body and a ravenous appetite. Pinkys are often encountered in swarms and attack by charging at enemies, using their powerful jaws to bite through armor and flesh alike.\"\n },\n {\n \"Name\": \"Arachnotron\",\n \"Description\": \"A spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\"\n },\n {\n \"Name\": \"Revenant\",\n \"Description\": \"A skeletal demon with jetpacks and missile launchers attached to its shoulders. Revenants are highly mobile, capable of flying across the battlefield while launching explosive missiles and engaging in swift hit-and-run tactics.\"\n },\n {\n \"Name\": \"Cyberdemon\",\n \"Description\": \"One of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\"\n },\n {\n \"Name\": \"Doom Hunter\",\n \"Description\": \"A high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\"\n }\n]\n\n\n\nWeapons = [\n {\n \"Name\": \"Super Shotgun\",\n \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\"\n },\n {\n \"Name\": \"Combat Shotgun\",\n \"Description\": \"A versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\"\n },\n {\n \"Name\": \"Rocket Launcher\",\n \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\"\n },\n {\n \"Name\": \"Chaingun\",\n \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\"\n },\n {\n \"Name\": \"Plasma Rifle\",\n \"Description\": \"A precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\"\n },\n {\n \"Name\": \"Ballista\",\n \"Description\": \"A heavy-hitting energy weapon that fires high-damage projectiles capable of piercing through enemies. The Ballista is excellent for taking out larger demons at a distance and can be equipped with the Remote Detonate mod for precision targeting.\"\n },\n {\n \"Name\": \"BFG 9000\",\n \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\"\n },\n {\n \"Name\": \"Heavy Cannon\",\n \"Description\": \"A reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\"\n },\n {\n \"Name\": \"Flamethrower\",\n \"Description\": \"A close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\"\n },\n {\n \"Name\": \"Ice Bomb\",\n \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.471031Z","iopub.execute_input":"2024-11-11T15:52:07.471319Z","iopub.status.idle":"2024-11-11T15:52:07.483968Z","shell.execute_reply.started":"2024-11-11T15:52:07.471281Z","shell.execute_reply":"2024-11-11T15:52:07.483201Z"},"trusted":true},"execution_count":418,"outputs":[]},{"cell_type":"markdown","source":"Now we can keep the initialmessages from before actually! However let's change the context","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"user\",\n \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\"\n})\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.484921Z","iopub.execute_input":"2024-11-11T15:52:07.485167Z","iopub.status.idle":"2024-11-11T15:52:07.497268Z","shell.execute_reply.started":"2024-11-11T15:52:07.485139Z","shell.execute_reply":"2024-11-11T15:52:07.496433Z"},"trusted":true},"execution_count":419,"outputs":[]},{"cell_type":"markdown","source":"And we of course make functions","metadata":{}},{"cell_type":"code","source":"def enemyscan(amount):\n enemiesonscene = []\n loop = 0\n \n while loop < amount + 1:\n scannedenemy = random.choice(Demons)\n \n # Append just the name of the demon to the list\n enemiesonscene.append(scannedenemy[\"Name\"])\n enemiesonscene.append(scannedenemy[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n enemies_string = \"\\n\".join(enemiesonscene) \n print(enemies_string)\n return enemies_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.498416Z","iopub.execute_input":"2024-11-11T15:52:07.498717Z","iopub.status.idle":"2024-11-11T15:52:07.506928Z","shell.execute_reply.started":"2024-11-11T15:52:07.498684Z","shell.execute_reply":"2024-11-11T15:52:07.506229Z"},"trusted":true},"execution_count":420,"outputs":[]},{"cell_type":"code","source":"enemyscan(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.507878Z","iopub.execute_input":"2024-11-11T15:52:07.508168Z","iopub.status.idle":"2024-11-11T15:52:07.519118Z","shell.execute_reply.started":"2024-11-11T15:52:07.508137Z","shell.execute_reply":"2024-11-11T15:52:07.518064Z"},"trusted":true},"execution_count":421,"outputs":[{"name":"stdout","text":"Doom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"},{"execution_count":421,"output_type":"execute_result","data":{"text/plain":"'Doom Hunter\\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\\nArachnotron\\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.'"},"metadata":{}}]},{"cell_type":"markdown","source":"And now inventory","metadata":{}},{"cell_type":"code","source":"def inventoryscan():\n weaponsathand = []\n loop = 0\n \n while loop < 5:\n weapon = random.choice(Weapons)\n \n # Append just the name of the demon to the list\n weaponsathand.append(weapon[\"Name\"])\n weaponsathand.append(weapon[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n weapons_string = \"\\n\".join(weaponsathand) \n print(weapons_string)\n return weapons_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.520282Z","iopub.execute_input":"2024-11-11T15:52:07.520557Z","iopub.status.idle":"2024-11-11T15:52:07.527632Z","shell.execute_reply.started":"2024-11-11T15:52:07.520526Z","shell.execute_reply":"2024-11-11T15:52:07.526811Z"},"trusted":true},"execution_count":422,"outputs":[]},{"cell_type":"code","source":"inventoryscan()","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.528628Z","iopub.execute_input":"2024-11-11T15:52:07.528894Z","iopub.status.idle":"2024-11-11T15:52:07.539482Z","shell.execute_reply.started":"2024-11-11T15:52:07.528864Z","shell.execute_reply":"2024-11-11T15:52:07.538672Z"},"trusted":true},"execution_count":423,"outputs":[{"name":"stdout","text":"Chaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nHeavy Cannon\nA reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nPlasma Rifle\nA precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n","output_type":"stream"},{"execution_count":423,"output_type":"execute_result","data":{"text/plain":"'Chaingun\\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\\nHeavy Cannon\\nA reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\\nFlamethrower\\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\\nPlasma Rifle\\nA precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\\nIce Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.'"},"metadata":{}}]},{"cell_type":"markdown","source":"With that, let's construct our new tools and run this!!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initialmessages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.540620Z","iopub.execute_input":"2024-11-11T15:52:07.540928Z","iopub.status.idle":"2024-11-11T15:52:10.400639Z","shell.execute_reply.started":"2024-11-11T15:52:07.540897Z","shell.execute_reply":"2024-11-11T15:52:10.399738Z"},"trusted":true},"execution_count":424,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01Xx6ZEquNw7BA7X7ADxNEfq', content=[TextBlock(text=\"Certainly, I'll analyze the mission priorities and use the tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\", type='text'), ToolUseBlock(id='toolu_01Ra4zv4XDkEkrwhJnrMCnM8', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_013d1iJRt6gFpQsSxci5t5nL', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=809, output_tokens=110))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Display just the text","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.401986Z","iopub.execute_input":"2024-11-11T15:52:10.402434Z","iopub.status.idle":"2024-11-11T15:52:10.407568Z","shell.execute_reply.started":"2024-11-11T15:52:10.402388Z","shell.execute_reply":"2024-11-11T15:52:10.406720Z"},"trusted":true},"execution_count":425,"outputs":[{"name":"stdout","text":"Certainly, I'll analyze the mission priorities and use the tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\n","output_type":"stream"}]},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": f\"{str(response)}\" \n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.408592Z","iopub.execute_input":"2024-11-11T15:52:10.408845Z","iopub.status.idle":"2024-11-11T15:52:10.417402Z","shell.execute_reply.started":"2024-11-11T15:52:10.408812Z","shell.execute_reply":"2024-11-11T15:52:10.416481Z"},"trusted":true},"execution_count":426,"outputs":[]},{"cell_type":"markdown","source":"And now to get the information and put it all together! PLEASE read the comments!","metadata":{}},{"cell_type":"code","source":"invscanres = \"\"\nenemyscanres = \"\"\n\n\nresponse_str = str(response) \ntool_use_count = response_str.count(\"ToolUseBlock\") #We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n\n\nprint (tool_use_count)\n\nloop = 0 \n\nwhile loop < tool_use_count: #We will get the tools now\n tool_use_block = response.content[loop + 1] #We start at 1 since 0 holds the AI mesage\n tool_name = tool_use_block.name\n tool_input = tool_use_block.input\n \n if tool_name == \"inventoryscan_tool\":\n # Call the inventoryscan function for inventoryscan_tool\n invscanres = inventoryscan()\n elif tool_name == \"enemyscan_tool\":\n # Get the amount for enemyscan_tool\n amount = tool_input['amount']\n # Call the enemyscan function with the amount\n enemyscanres = enemyscan(amount)\n \n loop = loop + 1 \nprint (invscanres)\nprint (enemyscanres)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.418587Z","iopub.execute_input":"2024-11-11T15:52:10.419272Z","iopub.status.idle":"2024-11-11T15:52:10.429115Z","shell.execute_reply.started":"2024-11-11T15:52:10.419227Z","shell.execute_reply":"2024-11-11T15:52:10.428296Z"},"trusted":true},"execution_count":427,"outputs":[{"name":"stdout","text":"2\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nDoom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nCyberdemon\nOne of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nCombat Shotgun\nA versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nChaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nCombat Shotgun\nA versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nChaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nDoom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nCyberdemon\nOne of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we are basically done! We can give this to th AI and see what we get","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": f\"Weapons Inventory Scan Result: {invscanres}\\nEnemy Scans Result: {enemyscanres}\" \n})\n\n\ninitialmessages.append({\n \"role\": \"user\",\n \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:02:01.314221Z","iopub.execute_input":"2024-11-11T16:02:01.315164Z","iopub.status.idle":"2024-11-11T16:02:01.319895Z","shell.execute_reply.started":"2024-11-11T16:02:01.315122Z","shell.execute_reply":"2024-11-11T16:02:01.318999Z"},"trusted":true},"execution_count":430,"outputs":[]},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initialmessages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:02:03.002623Z","iopub.execute_input":"2024-11-11T16:02:03.003575Z","iopub.status.idle":"2024-11-11T16:02:17.228099Z","shell.execute_reply.started":"2024-11-11T16:02:03.003515Z","shell.execute_reply":"2024-11-11T16:02:17.227224Z"},"trusted":true},"execution_count":431,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01QWS6cinVuJWVeJgF2srgJB', content=[TextBlock(text=\"Based on the enemy scan and weapon inventory results from the previous message, I'll outline a strategic combat plan for the Doom Slayer to efficiently eliminate these demons. Here's the recommended order of engagement, along with the most effective weapons and tactics for each:\\n\\n1. Arachnotron\\n Weapon: Combat Shotgun with Sticky Bombs mod\\n Strategy: Target the turret on its back to disable its ranged attack. Use the Sticky Bombs to precisely hit this weak point. Once disabled, finish it off with regular shotgun blasts.\\n\\n2. Cacodemon\\n Weapon: Combat Shotgun (Sticky Bomb) or Rocket Launcher\\n Strategy: Shoot a Sticky Bomb or rocket directly into its mouth when it opens to attack. This will stagger it, allowing for an instant Glory Kill.\\n\\n3. Hell Knight\\n Weapon: Rocket Launcher with Lock-On Burst mod\\n Strategy: Use the Lock-On Burst to unleash a barrage of rockets. Aim for its head to maximize damage. The Ice Bomb can be used to freeze it, allowing for easy rocket hits.\\n\\n4. Mancubus\\n Weapon: Chaingun with Heat Blast mod\\n Strategy: Target its arm cannons to disable its ranged attacks. Use the Chaingun's high rate of fire to quickly destroy these weak points. Finish it off with the Heat Blast for area damage.\\n\\n5. Doom Hunter\\n Weapon: Plasma Rifle (not in current inventory, so use Rocket Launcher)\\n Strategy: First, focus fire on its sled to immobilize it. The Rocket Launcher can deal significant damage here. Once the sled is destroyed, use the Combat Shotgun for closer engagements.\\n\\n6. Cyberdemon\\n Weapon: Combination of Rocket Launcher and Chaingun\\n Strategy: This is a boss-level enemy, so use all available weapons. Start with the Rocket Launcher's Lock-On Burst for high initial damage. Switch to the Chaingun for sustained damage. Use the Ice Bomb to create openings for heavy damage phases.\\n\\nGeneral tactics:\\n1. Utilize the Flamethrower frequently to generate armor and weaken enemies.\\n2. Use the Ice Bomb for crowd control when multiple enemies are clustered.\\n3. Prioritize destroying weak points (e.g., Arachnotron's turret, Mancubus's arm cannons) to reduce incoming damage.\\n4. Keep mobile and use the environment for cover, especially against ranged attackers like the Arachnotron and Cacodemon.\\n5. Save the Cyberdemon for last, as it will require the most resources and focus to defeat.\\n6. Remember to use Glory Kills on staggered enemies to replenish health and create momentary invulnerability frames.\\n\\nThis strategy prioritizes eliminating the most immediate threats first (Arachnotron and Cacodemon) and works up to the most formidable foe (Cyberdemon). Adjust tactics as needed based on the specific combat arena and how the enemies are positioned.\", type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=1791, output_tokens=702))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we view the end result","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:03:40.328053Z","iopub.execute_input":"2024-11-11T16:03:40.328542Z","iopub.status.idle":"2024-11-11T16:03:40.334738Z","shell.execute_reply.started":"2024-11-11T16:03:40.328488Z","shell.execute_reply":"2024-11-11T16:03:40.333654Z"},"trusted":true},"execution_count":432,"outputs":[{"name":"stdout","text":"Based on the enemy scan and weapon inventory results from the previous message, I'll outline a strategic combat plan for the Doom Slayer to efficiently eliminate these demons. Here's the recommended order of engagement, along with the most effective weapons and tactics for each:\n\n1. Arachnotron\n Weapon: Combat Shotgun with Sticky Bombs mod\n Strategy: Target the turret on its back to disable its ranged attack. Use the Sticky Bombs to precisely hit this weak point. Once disabled, finish it off with regular shotgun blasts.\n\n2. Cacodemon\n Weapon: Combat Shotgun (Sticky Bomb) or Rocket Launcher\n Strategy: Shoot a Sticky Bomb or rocket directly into its mouth when it opens to attack. This will stagger it, allowing for an instant Glory Kill.\n\n3. Hell Knight\n Weapon: Rocket Launcher with Lock-On Burst mod\n Strategy: Use the Lock-On Burst to unleash a barrage of rockets. Aim for its head to maximize damage. The Ice Bomb can be used to freeze it, allowing for easy rocket hits.\n\n4. Mancubus\n Weapon: Chaingun with Heat Blast mod\n Strategy: Target its arm cannons to disable its ranged attacks. Use the Chaingun's high rate of fire to quickly destroy these weak points. Finish it off with the Heat Blast for area damage.\n\n5. Doom Hunter\n Weapon: Plasma Rifle (not in current inventory, so use Rocket Launcher)\n Strategy: First, focus fire on its sled to immobilize it. The Rocket Launcher can deal significant damage here. Once the sled is destroyed, use the Combat Shotgun for closer engagements.\n\n6. Cyberdemon\n Weapon: Combination of Rocket Launcher and Chaingun\n Strategy: This is a boss-level enemy, so use all available weapons. Start with the Rocket Launcher's Lock-On Burst for high initial damage. Switch to the Chaingun for sustained damage. Use the Ice Bomb to create openings for heavy damage phases.\n\nGeneral tactics:\n1. Utilize the Flamethrower frequently to generate armor and weaken enemies.\n2. Use the Ice Bomb for crowd control when multiple enemies are clustered.\n3. Prioritize destroying weak points (e.g., Arachnotron's turret, Mancubus's arm cannons) to reduce incoming damage.\n4. Keep mobile and use the environment for cover, especially against ranged attackers like the Arachnotron and Cacodemon.\n5. Save the Cyberdemon for last, as it will require the most resources and focus to defeat.\n6. Remember to use Glory Kills on staggered enemies to replenish health and create momentary invulnerability frames.\n\nThis strategy prioritizes eliminating the most immediate threats first (Arachnotron and Cacodemon) and works up to the most formidable foe (Cyberdemon). Adjust tactics as needed based on the specific combat arena and how the enemies are positioned.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"End the session","metadata":{}},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.495828Z","iopub.status.idle":"2024-11-11T15:52:10.496330Z","shell.execute_reply.started":"2024-11-11T15:52:10.496058Z","shell.execute_reply":"2024-11-11T15:52:10.496085Z"},"trusted":true},"execution_count":null,"outputs":[]}]} \ No newline at end of file From 37e265fc3d1b6cb3f6fd81045eedb887d0713182 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:07:30 -0500 Subject: [PATCH 02/34] Update anthropicguide.md --- examples/anthropic_examples/anthropicguide.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/anthropic_examples/anthropicguide.md b/examples/anthropic_examples/anthropicguide.md index c24b78ed6..977288401 100644 --- a/examples/anthropic_examples/anthropicguide.md +++ b/examples/anthropic_examples/anthropicguide.md @@ -63,13 +63,28 @@ In this example, we generate a script line for a mech based on it's health and t ## Tool Example; Cyberware -In this example, we have the LLM call a simulated tool which gives one random piece of Cyberware based on the user's requested company. From there, the AI tells the user if the cyberware is good for the user's intended purpose. (combatant, hacker, etc.), +In this example, we have the LLM call a simulated tool which gives one random piece of Cyberware based on the user's requested company. From there, the AI tells the user if the cyberware is good for the user's intended purpose. (combatant, hacker, etc.). [Access the Journal By Clicking Here](./antrophic-example-tool.ipynb) +> [!WARNING] +> If you want to use the tools system, please look at the journal below! This gives examples related to knowing when a tool was used, some practices for calling a function from an API and returning it among other things! Using it is NOT the same as the other examples! + + +## Tool Deepdive; VEGA Hell Combat System + +In this example, we look at the tool system through a deeper dive; we will use our LLM assistant, VEGA, to get three missions from an API and determine which deserves priority. Then, we will send a number of enemies we want to scan for during combat while also getting our weapons inventory (using two tools at the same time). VEGA will tell us the bet way in which to combat these enemies through a combat strategy. + +[Access the Journal By Clicking Here](./agentops-anthropic-understanding-tools.ipynb) +[You should also look at Anthropic's Tool Documents!](https://docs.anthropic.com/en/docs/build-with-claude/tool-use) + + + + + ## Looking for a Barebones, Straight To The Point Journal? From c4ed5bc3c7d71d36699b89767df4ddca6c9d77a0 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:08:00 -0500 Subject: [PATCH 03/34] Update anthropicguide.md --- examples/anthropic_examples/anthropicguide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/anthropic_examples/anthropicguide.md b/examples/anthropic_examples/anthropicguide.md index 977288401..ddc6ac580 100644 --- a/examples/anthropic_examples/anthropicguide.md +++ b/examples/anthropic_examples/anthropicguide.md @@ -79,6 +79,8 @@ In this example, we have the LLM call a simulated tool which gives one random pi In this example, we look at the tool system through a deeper dive; we will use our LLM assistant, VEGA, to get three missions from an API and determine which deserves priority. Then, we will send a number of enemies we want to scan for during combat while also getting our weapons inventory (using two tools at the same time). VEGA will tell us the bet way in which to combat these enemies through a combat strategy. [Access the Journal By Clicking Here](./agentops-anthropic-understanding-tools.ipynb) + + [You should also look at Anthropic's Tool Documents!](https://docs.anthropic.com/en/docs/build-with-claude/tool-use) From fc9135d2c50159dcccc97c8909bff07b4896b470 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:31:02 -0500 Subject: [PATCH 04/34] Fixed Example Tool Journal Added more context to certain areas and implemented fix requests --- .../agentops-anthropic-understanding-tools.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb index d69e56c64..71c36f673 100644 --- a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb +++ b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb @@ -1 +1 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! ","metadata":{}},{"cell_type":"markdown","source":"To get started, we will import Agentops and Anthropic","metadata":{}},{"cell_type":"code","source":"!pip install agentops\n!pip install anthropic","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:29.141658Z","iopub.execute_input":"2024-11-11T15:51:29.142307Z","iopub.status.idle":"2024-11-11T15:51:51.690414Z","shell.execute_reply.started":"2024-11-11T15:51:29.142260Z","shell.execute_reply":"2024-11-11T15:51:51.689249Z"},"trusted":true},"execution_count":403,"outputs":[{"name":"stdout","text":"Requirement already satisfied: agentops in /opt/conda/lib/python3.10/site-packages (0.3.17)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nRequirement already satisfied: psutil==5.9.8 in /opt/conda/lib/python3.10/site-packages (from agentops) (5.9.8)\nRequirement already satisfied: packaging==23.2 in /opt/conda/lib/python3.10/site-packages (from agentops) (23.2)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nRequirement already satisfied: anthropic in /opt/conda/lib/python3.10/site-packages (0.39.0)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nRequirement already satisfied: jiter<1,>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.7.0)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Setup our generic default statements","metadata":{}},{"cell_type":"code","source":"from anthropic import Anthropic, AsyncAnthropic\nimport agentops\nimport os\nimport random #We don't need this for agentops, we use this to generate a message later\nimport time #We don't need this for agentops either, we use this when simulating an API later\nimport re #Regex for formatting\nfrom dotenv import load_dotenv","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.692522Z","iopub.execute_input":"2024-11-11T15:51:51.692856Z","iopub.status.idle":"2024-11-11T15:51:51.698055Z","shell.execute_reply.started":"2024-11-11T15:51:51.692820Z","shell.execute_reply":"2024-11-11T15:51:51.697133Z"},"trusted":true},"execution_count":404,"outputs":[]},{"cell_type":"markdown","source":"And set our API keys.","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.699276Z","iopub.execute_input":"2024-11-11T15:51:51.699649Z","iopub.status.idle":"2024-11-11T15:51:51.710752Z","shell.execute_reply.started":"2024-11-11T15:51:51.699607Z","shell.execute_reply":"2024-11-11T15:51:51.709955Z"},"trusted":true},"execution_count":405,"outputs":[]},{"cell_type":"markdown","source":"\nNow let's set the client as Anthropic and make an AgentOps session","metadata":{}},{"cell_type":"code","source":"agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"client = Anthropic(api_key=ANTHROPIC_API_KEY)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.726061Z","iopub.execute_input":"2024-11-11T15:51:51.726434Z","iopub.status.idle":"2024-11-11T15:51:51.745524Z","shell.execute_reply.started":"2024-11-11T15:51:51.726393Z","shell.execute_reply":"2024-11-11T15:51:51.744677Z"},"trusted":true},"execution_count":407,"outputs":[]},{"cell_type":"markdown","source":"Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack.","metadata":{}},{"cell_type":"code","source":"Locations = [\n {\n \"Name\": \"Super Gore Nest\",\n \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\"\n },\n {\n \"Name\": \"Exultia\",\n \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\"\n },\n {\n \"Name\": \"Cultist Base\",\n \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"Taras Nabad\",\n \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\"\n },\n {\n \"Name\": \"Nekravol\",\n \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\"\n },\n {\n \"Name\": \"Urdak\",\n \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"UAC Base\",\n \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\"\n }\n]\n\nCombatCasualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n\nMissions = [\n \"Locate and confront a key leader of Hell’s invasion forces.\",\n \"Clear out demonic infestations to secure a strategic foothold.\",\n \"Disrupt Hell's control over the area by eliminating critical targets.\",\n \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n \"Locate and destroy the central power source to weaken enemy forces.\",\n \"Collect essential resources before the area becomes unstable.\"\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.747664Z","iopub.execute_input":"2024-11-11T15:51:51.748003Z","iopub.status.idle":"2024-11-11T15:51:51.757044Z","shell.execute_reply.started":"2024-11-11T15:51:51.747963Z","shell.execute_reply":"2024-11-11T15:51:51.754966Z"},"trusted":true},"execution_count":408,"outputs":[]},{"cell_type":"markdown","source":"Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI.","metadata":{}},{"cell_type":"code","source":"def generate_missions():\n missions = []\n loop = 0\n \n while loop < 3:\n location = random.choice(Locations)\n casualties = random.choice(CombatCasualties)\n mission = random.choice(Missions)\n final = (\n f'LocationName: {location[\"Name\"]}, '\n f'LocationInfo: {location[\"Description\"]}, '\n f'HumanCombatCasualties: {casualties}, '\n f'Mission: {mission}'\n )\n \n missions.append(final)\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n missions_string = \"\\n\".join(missions) # Or \", \".join(missions) for a comma-separated string\n print(missions_string)\n return missions_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.758536Z","iopub.execute_input":"2024-11-11T15:51:51.758780Z","iopub.status.idle":"2024-11-11T15:51:51.770825Z","shell.execute_reply.started":"2024-11-11T15:51:51.758752Z","shell.execute_reply":"2024-11-11T15:51:51.770043Z"},"trusted":true},"execution_count":409,"outputs":[]},{"cell_type":"code","source":"generate_missions()","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.771788Z","iopub.execute_input":"2024-11-11T15:51:51.772033Z","iopub.status.idle":"2024-11-11T15:51:51.784220Z","shell.execute_reply.started":"2024-11-11T15:51:51.772005Z","shell.execute_reply":"2024-11-11T15:51:51.783349Z"},"trusted":true},"execution_count":410,"outputs":[{"name":"stdout","text":"LocationName: Urdak, LocationInfo: A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth., HumanCombatCasualties: Nonexistent, Mission: Clear out demonic infestations to secure a strategic foothold.\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: Nonexistent, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: High, Mission: Disrupt Hell's control over the area by eliminating critical targets.\n","output_type":"stream"},{"execution_count":410,"output_type":"execute_result","data":{"text/plain":"\"LocationName: Urdak, LocationInfo: A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth., HumanCombatCasualties: Nonexistent, Mission: Clear out demonic infestations to secure a strategic foothold.\\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: Nonexistent, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\\nLocationName: Super Gore Nest, LocationInfo: A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city., HumanCombatCasualties: High, Mission: Disrupt Hell's control over the area by eliminating critical targets.\""},"metadata":{}}]},{"cell_type":"markdown","source":"Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n\nWe are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line","metadata":{}},{"cell_type":"markdown","source":"Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!","metadata":{}},{"cell_type":"code","source":"# We make our history a separate block to be easier to add to later on! This is essentially our history\ninitialmessages = initialmessages = [\n {\n \"role\": \"user\",\n \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.785451Z","iopub.execute_input":"2024-11-11T15:51:51.785792Z","iopub.status.idle":"2024-11-11T15:51:51.793099Z","shell.execute_reply.started":"2024-11-11T15:51:51.785752Z","shell.execute_reply":"2024-11-11T15:51:51.792382Z"},"trusted":true},"execution_count":411,"outputs":[]},{"cell_type":"markdown","source":"Now to construct a request!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initialmessages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:51.797081Z","iopub.execute_input":"2024-11-11T15:51:51.797388Z","iopub.status.idle":"2024-11-11T15:51:56.954146Z","shell.execute_reply.started":"2024-11-11T15:51:51.797357Z","shell.execute_reply":"2024-11-11T15:51:56.953227Z"},"trusted":true},"execution_count":412,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01FavorMsz4Yp8TwTgfxVEpU', content=[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01LQEsSBrbipWxkWWyLXiJkH', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=393, output_tokens=97))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Let's isolate the AI dialogue just for fun","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.955196Z","iopub.execute_input":"2024-11-11T15:51:56.955482Z","iopub.status.idle":"2024-11-11T15:51:56.960115Z","shell.execute_reply.started":"2024-11-11T15:51:56.955448Z","shell.execute_reply":"2024-11-11T15:51:56.959246Z"},"trusted":true},"execution_count":413,"outputs":[{"name":"stdout","text":"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\n\nLet's begin by retrieving the missions:\n","output_type":"stream"}]},{"cell_type":"markdown","source":"The code below finds the tool used!","metadata":{}},{"cell_type":"code","source":"GenMissionResult = \"\"\n\n# Print response content to see the data\nprint(response.content)\n\n# Assuming ToolUseBlock is at index 1\ntool_use_block = response.content[1]\n\n# Get the tool name and input\ntool_name = tool_use_block.name\ntool_input = tool_use_block.input\n\n# We don't need to look to extract any inputs since we don't use any\n\n# Check if the tool name is \"generate_missions\"\nif tool_name == \"generate_missions\":\n # Call the function with the tool creator as an argument\n GenMissionResult = generate_missions()\n ","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.961292Z","iopub.execute_input":"2024-11-11T15:51:56.961583Z","iopub.status.idle":"2024-11-11T15:51:56.974731Z","shell.execute_reply.started":"2024-11-11T15:51:56.961551Z","shell.execute_reply":"2024-11-11T15:51:56.973896Z"},"trusted":true},"execution_count":414,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance in quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01LQEsSBrbipWxkWWyLXiJkH', input={}, name='generate_missions', type='tool_use')]\nLocationName: Exultia, LocationInfo: An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces., HumanCombatCasualties: High, Mission: Locate and destroy the central power source to weaken enemy forces.\nLocationName: UAC Base, LocationInfo: A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions., HumanCombatCasualties: High, Mission: Locate and destroy the central power source to weaken enemy forces.\nLocationName: Exultia, LocationInfo: An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces., HumanCombatCasualties: Extinction, Mission: Enter a critical demonic stronghold to disrupt enemy operations.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"Now we add these as context to the LLM through intial messages!","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": GenMissionResult\n})\n\ninitialmessages.append({\n \"role\": \"user\",\n \"content\": \"Based on these, which location should take priority and why?\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.975759Z","iopub.execute_input":"2024-11-11T15:51:56.976046Z","iopub.status.idle":"2024-11-11T15:51:56.985098Z","shell.execute_reply.started":"2024-11-11T15:51:56.976002Z","shell.execute_reply":"2024-11-11T15:51:56.984354Z"},"trusted":true},"execution_count":415,"outputs":[]},{"cell_type":"markdown","source":"And now to get a response!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initialmessages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:51:56.986100Z","iopub.execute_input":"2024-11-11T15:51:56.986406Z","iopub.status.idle":"2024-11-11T15:52:07.462887Z","shell.execute_reply.started":"2024-11-11T15:51:56.986376Z","shell.execute_reply":"2024-11-11T15:52:07.462024Z"},"trusted":true},"execution_count":416,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01MBwHFvHykWyYJSZZKtDWKd', content=[TextBlock(text='Based on the missions generated, I\\'ll analyze them and prioritize them for you, DoomSlayer. Here\\'s my assessment of the importance of each mission, from most critical to least:\\n\\n1. Exultia (Mission: Enter a critical demonic stronghold to disrupt enemy operations)\\n Priority: Highest\\n Reason: This mission is the most crucial because:\\n - The human combat casualties are listed as \"Extinction,\" which indicates an extremely dire situation.\\n - The mission involves directly disrupting enemy operations by entering a critical demonic stronghold.\\n - Exultia\\'s mystical nature and connection to the Night Sentinels suggest that success here could have far-reaching implications in the fight against Hell.\\n\\n2. UAC Base (Mission: Locate and destroy the central power source to weaken enemy forces)\\n Priority: High\\n Reason: This mission is second in importance because:\\n - It\\'s on Earth, making it a critical location for humanity\\'s survival.\\n - The UAC Base is described as a human foothold in the fight against Hell.\\n - Destroying the central power source could significantly weaken the enemy\\'s presence on Earth.\\n - The human combat casualties are listed as \"High,\" indicating an urgent situation.\\n\\n3. Exultia (Mission: Locate and destroy the central power source to weaken enemy forces)\\n Priority: Moderate\\n Reason: While still important, this mission is the least critical of the three because:\\n - It\\'s similar to the UAC Base mission but on a different world.\\n - The human combat casualties are listed as \"High,\" which is severe but not as critical as the \"Extinction\" level in the first Exultia mission.\\n - While weakening enemy forces is crucial, it\\'s not as direct an action as disrupting their operations in a critical stronghold.\\n\\nIn conclusion, DoomSlayer, I recommend prioritizing the mission to enter the critical demonic stronghold on Exultia. This action has the potential to make the most significant impact on the forces of Hell and potentially prevent the extinction-level threat to humanity. The UAC Base mission should be your second priority to secure Earth, followed by the other Exultia mission to further weaken the enemy\\'s power sources.\\n\\nRemember, Slayer, the fate of humanity rests on your shoulders. Rip and tear, until it is done.', type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=696, output_tokens=528))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Isolate again!","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.464253Z","iopub.execute_input":"2024-11-11T15:52:07.464544Z","iopub.status.idle":"2024-11-11T15:52:07.469571Z","shell.execute_reply.started":"2024-11-11T15:52:07.464512Z","shell.execute_reply":"2024-11-11T15:52:07.468685Z"},"trusted":true},"execution_count":417,"outputs":[{"name":"stdout","text":"Based on the missions generated, I'll analyze them and prioritize them for you, DoomSlayer. Here's my assessment of the importance of each mission, from most critical to least:\n\n1. Exultia (Mission: Enter a critical demonic stronghold to disrupt enemy operations)\n Priority: Highest\n Reason: This mission is the most crucial because:\n - The human combat casualties are listed as \"Extinction,\" which indicates an extremely dire situation.\n - The mission involves directly disrupting enemy operations by entering a critical demonic stronghold.\n - Exultia's mystical nature and connection to the Night Sentinels suggest that success here could have far-reaching implications in the fight against Hell.\n\n2. UAC Base (Mission: Locate and destroy the central power source to weaken enemy forces)\n Priority: High\n Reason: This mission is second in importance because:\n - It's on Earth, making it a critical location for humanity's survival.\n - The UAC Base is described as a human foothold in the fight against Hell.\n - Destroying the central power source could significantly weaken the enemy's presence on Earth.\n - The human combat casualties are listed as \"High,\" indicating an urgent situation.\n\n3. Exultia (Mission: Locate and destroy the central power source to weaken enemy forces)\n Priority: Moderate\n Reason: While still important, this mission is the least critical of the three because:\n - It's similar to the UAC Base mission but on a different world.\n - The human combat casualties are listed as \"High,\" which is severe but not as critical as the \"Extinction\" level in the first Exultia mission.\n - While weakening enemy forces is crucial, it's not as direct an action as disrupting their operations in a critical stronghold.\n\nIn conclusion, DoomSlayer, I recommend prioritizing the mission to enter the critical demonic stronghold on Exultia. This action has the potential to make the most significant impact on the forces of Hell and potentially prevent the extinction-level threat to humanity. The UAC Base mission should be your second priority to secure Earth, followed by the other Exultia mission to further weaken the enemy's power sources.\n\nRemember, Slayer, the fate of humanity rests on your shoulders. Rip and tear, until it is done.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n\nOne will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)","metadata":{}},{"cell_type":"code","source":"Demons = [\n {\n \"Name\": \"Imp\",\n \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\"\n },\n {\n \"Name\": \"Cacodemon\",\n \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\"\n },\n {\n \"Name\": \"Hell Knight\",\n \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\"\n },\n {\n \"Name\": \"Mancubus\",\n \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\"\n },\n {\n \"Name\": \"Baron of Hell\",\n \"Description\": \"A large, heavily armored demon wielding twin plasma cannons, capable of charging and throwing devastating shockwaves. The Baron of Hell is one of Hell’s elite warriors, combining brute strength and ranged firepower.\"\n },\n {\n \"Name\": \"Pinky\",\n \"Description\": \"A fast, aggressive demon with a large, muscular body and a ravenous appetite. Pinkys are often encountered in swarms and attack by charging at enemies, using their powerful jaws to bite through armor and flesh alike.\"\n },\n {\n \"Name\": \"Arachnotron\",\n \"Description\": \"A spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\"\n },\n {\n \"Name\": \"Revenant\",\n \"Description\": \"A skeletal demon with jetpacks and missile launchers attached to its shoulders. Revenants are highly mobile, capable of flying across the battlefield while launching explosive missiles and engaging in swift hit-and-run tactics.\"\n },\n {\n \"Name\": \"Cyberdemon\",\n \"Description\": \"One of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\"\n },\n {\n \"Name\": \"Doom Hunter\",\n \"Description\": \"A high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\"\n }\n]\n\n\n\nWeapons = [\n {\n \"Name\": \"Super Shotgun\",\n \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\"\n },\n {\n \"Name\": \"Combat Shotgun\",\n \"Description\": \"A versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\"\n },\n {\n \"Name\": \"Rocket Launcher\",\n \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\"\n },\n {\n \"Name\": \"Chaingun\",\n \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\"\n },\n {\n \"Name\": \"Plasma Rifle\",\n \"Description\": \"A precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\"\n },\n {\n \"Name\": \"Ballista\",\n \"Description\": \"A heavy-hitting energy weapon that fires high-damage projectiles capable of piercing through enemies. The Ballista is excellent for taking out larger demons at a distance and can be equipped with the Remote Detonate mod for precision targeting.\"\n },\n {\n \"Name\": \"BFG 9000\",\n \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\"\n },\n {\n \"Name\": \"Heavy Cannon\",\n \"Description\": \"A reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\"\n },\n {\n \"Name\": \"Flamethrower\",\n \"Description\": \"A close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\"\n },\n {\n \"Name\": \"Ice Bomb\",\n \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.471031Z","iopub.execute_input":"2024-11-11T15:52:07.471319Z","iopub.status.idle":"2024-11-11T15:52:07.483968Z","shell.execute_reply.started":"2024-11-11T15:52:07.471281Z","shell.execute_reply":"2024-11-11T15:52:07.483201Z"},"trusted":true},"execution_count":418,"outputs":[]},{"cell_type":"markdown","source":"Now we can keep the initialmessages from before actually! However let's change the context","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"user\",\n \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\"\n})\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.484921Z","iopub.execute_input":"2024-11-11T15:52:07.485167Z","iopub.status.idle":"2024-11-11T15:52:07.497268Z","shell.execute_reply.started":"2024-11-11T15:52:07.485139Z","shell.execute_reply":"2024-11-11T15:52:07.496433Z"},"trusted":true},"execution_count":419,"outputs":[]},{"cell_type":"markdown","source":"And we of course make functions","metadata":{}},{"cell_type":"code","source":"def enemyscan(amount):\n enemiesonscene = []\n loop = 0\n \n while loop < amount + 1:\n scannedenemy = random.choice(Demons)\n \n # Append just the name of the demon to the list\n enemiesonscene.append(scannedenemy[\"Name\"])\n enemiesonscene.append(scannedenemy[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n enemies_string = \"\\n\".join(enemiesonscene) \n print(enemies_string)\n return enemies_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.498416Z","iopub.execute_input":"2024-11-11T15:52:07.498717Z","iopub.status.idle":"2024-11-11T15:52:07.506928Z","shell.execute_reply.started":"2024-11-11T15:52:07.498684Z","shell.execute_reply":"2024-11-11T15:52:07.506229Z"},"trusted":true},"execution_count":420,"outputs":[]},{"cell_type":"code","source":"enemyscan(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.507878Z","iopub.execute_input":"2024-11-11T15:52:07.508168Z","iopub.status.idle":"2024-11-11T15:52:07.519118Z","shell.execute_reply.started":"2024-11-11T15:52:07.508137Z","shell.execute_reply":"2024-11-11T15:52:07.518064Z"},"trusted":true},"execution_count":421,"outputs":[{"name":"stdout","text":"Doom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"},{"execution_count":421,"output_type":"execute_result","data":{"text/plain":"'Doom Hunter\\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\\nArachnotron\\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.'"},"metadata":{}}]},{"cell_type":"markdown","source":"And now inventory","metadata":{}},{"cell_type":"code","source":"def inventoryscan():\n weaponsathand = []\n loop = 0\n \n while loop < 5:\n weapon = random.choice(Weapons)\n \n # Append just the name of the demon to the list\n weaponsathand.append(weapon[\"Name\"])\n weaponsathand.append(weapon[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n weapons_string = \"\\n\".join(weaponsathand) \n print(weapons_string)\n return weapons_string","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.520282Z","iopub.execute_input":"2024-11-11T15:52:07.520557Z","iopub.status.idle":"2024-11-11T15:52:07.527632Z","shell.execute_reply.started":"2024-11-11T15:52:07.520526Z","shell.execute_reply":"2024-11-11T15:52:07.526811Z"},"trusted":true},"execution_count":422,"outputs":[]},{"cell_type":"code","source":"inventoryscan()","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.528628Z","iopub.execute_input":"2024-11-11T15:52:07.528894Z","iopub.status.idle":"2024-11-11T15:52:07.539482Z","shell.execute_reply.started":"2024-11-11T15:52:07.528864Z","shell.execute_reply":"2024-11-11T15:52:07.538672Z"},"trusted":true},"execution_count":423,"outputs":[{"name":"stdout","text":"Chaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nHeavy Cannon\nA reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nPlasma Rifle\nA precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n","output_type":"stream"},{"execution_count":423,"output_type":"execute_result","data":{"text/plain":"'Chaingun\\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\\nHeavy Cannon\\nA reliable, semi-automatic weapon that fires explosive rounds. The Heavy Cannon is great for picking off enemies from a distance and can be equipped with mods like the Precision Bolt, turning it into a sniper-like weapon for high-damage headshots.\\nFlamethrower\\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\\nPlasma Rifle\\nA precision energy weapon that fires powerful plasma shots. The Plasma Rifle excels at taking down armored enemies and can be modded with the Micromissiles mod, adding extra firepower in the form of homing projectiles.\\nIce Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.'"},"metadata":{}}]},{"cell_type":"markdown","source":"With that, let's construct our new tools and run this!!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initialmessages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:07.540620Z","iopub.execute_input":"2024-11-11T15:52:07.540928Z","iopub.status.idle":"2024-11-11T15:52:10.400639Z","shell.execute_reply.started":"2024-11-11T15:52:07.540897Z","shell.execute_reply":"2024-11-11T15:52:10.399738Z"},"trusted":true},"execution_count":424,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01Xx6ZEquNw7BA7X7ADxNEfq', content=[TextBlock(text=\"Certainly, I'll analyze the mission priorities and use the tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\", type='text'), ToolUseBlock(id='toolu_01Ra4zv4XDkEkrwhJnrMCnM8', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_013d1iJRt6gFpQsSxci5t5nL', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=809, output_tokens=110))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Display just the text","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.401986Z","iopub.execute_input":"2024-11-11T15:52:10.402434Z","iopub.status.idle":"2024-11-11T15:52:10.407568Z","shell.execute_reply.started":"2024-11-11T15:52:10.402388Z","shell.execute_reply":"2024-11-11T15:52:10.406720Z"},"trusted":true},"execution_count":425,"outputs":[{"name":"stdout","text":"Certainly, I'll analyze the mission priorities and use the tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\n","output_type":"stream"}]},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": f\"{str(response)}\" \n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.408592Z","iopub.execute_input":"2024-11-11T15:52:10.408845Z","iopub.status.idle":"2024-11-11T15:52:10.417402Z","shell.execute_reply.started":"2024-11-11T15:52:10.408812Z","shell.execute_reply":"2024-11-11T15:52:10.416481Z"},"trusted":true},"execution_count":426,"outputs":[]},{"cell_type":"markdown","source":"And now to get the information and put it all together! PLEASE read the comments!","metadata":{}},{"cell_type":"code","source":"invscanres = \"\"\nenemyscanres = \"\"\n\n\nresponse_str = str(response) \ntool_use_count = response_str.count(\"ToolUseBlock\") #We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n\n\nprint (tool_use_count)\n\nloop = 0 \n\nwhile loop < tool_use_count: #We will get the tools now\n tool_use_block = response.content[loop + 1] #We start at 1 since 0 holds the AI mesage\n tool_name = tool_use_block.name\n tool_input = tool_use_block.input\n \n if tool_name == \"inventoryscan_tool\":\n # Call the inventoryscan function for inventoryscan_tool\n invscanres = inventoryscan()\n elif tool_name == \"enemyscan_tool\":\n # Get the amount for enemyscan_tool\n amount = tool_input['amount']\n # Call the enemyscan function with the amount\n enemyscanres = enemyscan(amount)\n \n loop = loop + 1 \nprint (invscanres)\nprint (enemyscanres)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.418587Z","iopub.execute_input":"2024-11-11T15:52:10.419272Z","iopub.status.idle":"2024-11-11T15:52:10.429115Z","shell.execute_reply.started":"2024-11-11T15:52:10.419227Z","shell.execute_reply":"2024-11-11T15:52:10.428296Z"},"trusted":true},"execution_count":427,"outputs":[{"name":"stdout","text":"2\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nDoom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nCyberdemon\nOne of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nCombat Shotgun\nA versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nChaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nCombat Shotgun\nA versatile, semi-automatic shotgun that is effective at both close and mid-range combat. With its rapid fire rate and the ability to equip various mods, including the Sticky Bombs and the Full Auto mod, the Combat Shotgun is a reliable weapon in any situation.\nFlamethrower\nA close-range weapon that shoots a stream of fire, useful for weakening enemies and setting them up for a Glory Kill. The Flamethrower also generates armor when used on enemies, making it an essential tool for resource management in combat.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nChaingun\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nArachnotron\nA spider-like demon with a powerful energy weapon mounted on its back. The Arachnotron can climb walls and shoot high-powered plasma beams, making it a formidable opponent in both close and long-range combat.\nDoom Hunter\nA high-tech, demonic hybrid that combines elements of Hell’s most powerful warriors and advanced technology. The Doom Hunter rides a mechanical, armored exoskeleton and is equipped with an array of devastating weapons.\nCyberdemon\nOne of the most fearsome demons in Hell’s army, the Cyberdemon is a massive, cybernetic monstrosity with a rocket launcher for an arm. Its immense power and destructive capabilities make it a terrifying boss-level foe.\nCacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we are basically done! We can give this to th AI and see what we get","metadata":{}},{"cell_type":"code","source":"initialmessages.append({\n \"role\": \"assistant\",\n \"content\": f\"Weapons Inventory Scan Result: {invscanres}\\nEnemy Scans Result: {enemyscanres}\" \n})\n\n\ninitialmessages.append({\n \"role\": \"user\",\n \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:02:01.314221Z","iopub.execute_input":"2024-11-11T16:02:01.315164Z","iopub.status.idle":"2024-11-11T16:02:01.319895Z","shell.execute_reply.started":"2024-11-11T16:02:01.315122Z","shell.execute_reply":"2024-11-11T16:02:01.318999Z"},"trusted":true},"execution_count":430,"outputs":[]},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initialmessages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:02:03.002623Z","iopub.execute_input":"2024-11-11T16:02:03.003575Z","iopub.status.idle":"2024-11-11T16:02:17.228099Z","shell.execute_reply.started":"2024-11-11T16:02:03.003515Z","shell.execute_reply":"2024-11-11T16:02:17.227224Z"},"trusted":true},"execution_count":431,"outputs":[{"name":"stderr","text":"\u001b[31;1m🖇 AgentOps: Could not record event. Start a session by calling agentops.start_session().\u001b[0m\n","output_type":"stream"},{"name":"stdout","text":"Message(id='msg_01QWS6cinVuJWVeJgF2srgJB', content=[TextBlock(text=\"Based on the enemy scan and weapon inventory results from the previous message, I'll outline a strategic combat plan for the Doom Slayer to efficiently eliminate these demons. Here's the recommended order of engagement, along with the most effective weapons and tactics for each:\\n\\n1. Arachnotron\\n Weapon: Combat Shotgun with Sticky Bombs mod\\n Strategy: Target the turret on its back to disable its ranged attack. Use the Sticky Bombs to precisely hit this weak point. Once disabled, finish it off with regular shotgun blasts.\\n\\n2. Cacodemon\\n Weapon: Combat Shotgun (Sticky Bomb) or Rocket Launcher\\n Strategy: Shoot a Sticky Bomb or rocket directly into its mouth when it opens to attack. This will stagger it, allowing for an instant Glory Kill.\\n\\n3. Hell Knight\\n Weapon: Rocket Launcher with Lock-On Burst mod\\n Strategy: Use the Lock-On Burst to unleash a barrage of rockets. Aim for its head to maximize damage. The Ice Bomb can be used to freeze it, allowing for easy rocket hits.\\n\\n4. Mancubus\\n Weapon: Chaingun with Heat Blast mod\\n Strategy: Target its arm cannons to disable its ranged attacks. Use the Chaingun's high rate of fire to quickly destroy these weak points. Finish it off with the Heat Blast for area damage.\\n\\n5. Doom Hunter\\n Weapon: Plasma Rifle (not in current inventory, so use Rocket Launcher)\\n Strategy: First, focus fire on its sled to immobilize it. The Rocket Launcher can deal significant damage here. Once the sled is destroyed, use the Combat Shotgun for closer engagements.\\n\\n6. Cyberdemon\\n Weapon: Combination of Rocket Launcher and Chaingun\\n Strategy: This is a boss-level enemy, so use all available weapons. Start with the Rocket Launcher's Lock-On Burst for high initial damage. Switch to the Chaingun for sustained damage. Use the Ice Bomb to create openings for heavy damage phases.\\n\\nGeneral tactics:\\n1. Utilize the Flamethrower frequently to generate armor and weaken enemies.\\n2. Use the Ice Bomb for crowd control when multiple enemies are clustered.\\n3. Prioritize destroying weak points (e.g., Arachnotron's turret, Mancubus's arm cannons) to reduce incoming damage.\\n4. Keep mobile and use the environment for cover, especially against ranged attackers like the Arachnotron and Cacodemon.\\n5. Save the Cyberdemon for last, as it will require the most resources and focus to defeat.\\n6. Remember to use Glory Kills on staggered enemies to replenish health and create momentary invulnerability frames.\\n\\nThis strategy prioritizes eliminating the most immediate threats first (Arachnotron and Cacodemon) and works up to the most formidable foe (Cyberdemon). Adjust tactics as needed based on the specific combat arena and how the enemies are positioned.\", type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=1791, output_tokens=702))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we view the end result","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-11T16:03:40.328053Z","iopub.execute_input":"2024-11-11T16:03:40.328542Z","iopub.status.idle":"2024-11-11T16:03:40.334738Z","shell.execute_reply.started":"2024-11-11T16:03:40.328488Z","shell.execute_reply":"2024-11-11T16:03:40.333654Z"},"trusted":true},"execution_count":432,"outputs":[{"name":"stdout","text":"Based on the enemy scan and weapon inventory results from the previous message, I'll outline a strategic combat plan for the Doom Slayer to efficiently eliminate these demons. Here's the recommended order of engagement, along with the most effective weapons and tactics for each:\n\n1. Arachnotron\n Weapon: Combat Shotgun with Sticky Bombs mod\n Strategy: Target the turret on its back to disable its ranged attack. Use the Sticky Bombs to precisely hit this weak point. Once disabled, finish it off with regular shotgun blasts.\n\n2. Cacodemon\n Weapon: Combat Shotgun (Sticky Bomb) or Rocket Launcher\n Strategy: Shoot a Sticky Bomb or rocket directly into its mouth when it opens to attack. This will stagger it, allowing for an instant Glory Kill.\n\n3. Hell Knight\n Weapon: Rocket Launcher with Lock-On Burst mod\n Strategy: Use the Lock-On Burst to unleash a barrage of rockets. Aim for its head to maximize damage. The Ice Bomb can be used to freeze it, allowing for easy rocket hits.\n\n4. Mancubus\n Weapon: Chaingun with Heat Blast mod\n Strategy: Target its arm cannons to disable its ranged attacks. Use the Chaingun's high rate of fire to quickly destroy these weak points. Finish it off with the Heat Blast for area damage.\n\n5. Doom Hunter\n Weapon: Plasma Rifle (not in current inventory, so use Rocket Launcher)\n Strategy: First, focus fire on its sled to immobilize it. The Rocket Launcher can deal significant damage here. Once the sled is destroyed, use the Combat Shotgun for closer engagements.\n\n6. Cyberdemon\n Weapon: Combination of Rocket Launcher and Chaingun\n Strategy: This is a boss-level enemy, so use all available weapons. Start with the Rocket Launcher's Lock-On Burst for high initial damage. Switch to the Chaingun for sustained damage. Use the Ice Bomb to create openings for heavy damage phases.\n\nGeneral tactics:\n1. Utilize the Flamethrower frequently to generate armor and weaken enemies.\n2. Use the Ice Bomb for crowd control when multiple enemies are clustered.\n3. Prioritize destroying weak points (e.g., Arachnotron's turret, Mancubus's arm cannons) to reduce incoming damage.\n4. Keep mobile and use the environment for cover, especially against ranged attackers like the Arachnotron and Cacodemon.\n5. Save the Cyberdemon for last, as it will require the most resources and focus to defeat.\n6. Remember to use Glory Kills on staggered enemies to replenish health and create momentary invulnerability frames.\n\nThis strategy prioritizes eliminating the most immediate threats first (Arachnotron and Cacodemon) and works up to the most formidable foe (Cyberdemon). Adjust tactics as needed based on the specific combat arena and how the enemies are positioned.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"End the session","metadata":{}},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"execution":{"iopub.status.busy":"2024-11-11T15:52:10.495828Z","iopub.status.idle":"2024-11-11T15:52:10.496330Z","shell.execute_reply.started":"2024-11-11T15:52:10.496058Z","shell.execute_reply":"2024-11-11T15:52:10.496085Z"},"trusted":true},"execution_count":null,"outputs":[]}]} \ No newline at end of file +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! ","metadata":{}},{"cell_type":"markdown","source":"To get started, we will import Agentops and Anthropic","metadata":{}},{"cell_type":"code","source":"!pip install agentops\n!pip install anthropic","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:10:18.453801Z","iopub.execute_input":"2024-11-15T14:10:18.454259Z","iopub.status.idle":"2024-11-15T14:10:43.013126Z","shell.execute_reply.started":"2024-11-15T14:10:18.454211Z","shell.execute_reply":"2024-11-15T14:10:43.011519Z"},"trusted":true},"execution_count":5,"outputs":[{"name":"stdout","text":"Requirement already satisfied: agentops in /opt/conda/lib/python3.10/site-packages (0.3.17)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nRequirement already satisfied: psutil==5.9.8 in /opt/conda/lib/python3.10/site-packages (from agentops) (5.9.8)\nRequirement already satisfied: packaging==23.2 in /opt/conda/lib/python3.10/site-packages (from agentops) (23.2)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nRequirement already satisfied: anthropic in /opt/conda/lib/python3.10/site-packages (0.39.0)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nRequirement already satisfied: jiter<1,>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.7.1)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Setup our generic default statements","metadata":{}},{"cell_type":"code","source":"from anthropic import Anthropic, AsyncAnthropic\nimport agentops\nimport os\nimport random #We don't need this for agentops, we use this to generate a message later\nimport time #We don't need this for agentops either, we use this when simulating an API later\nimport re #Regex for formatting\nfrom dotenv import load_dotenv","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:11:48.157831Z","iopub.execute_input":"2024-11-15T14:11:48.158313Z","iopub.status.idle":"2024-11-15T14:11:48.166924Z","shell.execute_reply.started":"2024-11-15T14:11:48.158267Z","shell.execute_reply":"2024-11-15T14:11:48.164611Z"},"trusted":true},"execution_count":6,"outputs":[]},{"cell_type":"markdown","source":"And set our API keys.","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:15:34.282826Z","iopub.execute_input":"2024-11-15T14:15:34.283338Z","iopub.status.idle":"2024-11-15T14:15:34.290763Z","shell.execute_reply.started":"2024-11-15T14:15:34.283286Z","shell.execute_reply":"2024-11-15T14:15:34.289526Z"},"trusted":true},"execution_count":10,"outputs":[]},{"cell_type":"markdown","source":"\nNow let's set the client as Anthropic and make an AgentOps session","metadata":{}},{"cell_type":"code","source":"agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"client = Anthropic(api_key=ANTHROPIC_API_KEY)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:15:43.763463Z","iopub.execute_input":"2024-11-15T14:15:43.763875Z","iopub.status.idle":"2024-11-15T14:15:43.784626Z","shell.execute_reply.started":"2024-11-15T14:15:43.763835Z","shell.execute_reply":"2024-11-15T14:15:43.783492Z"},"trusted":true},"execution_count":12,"outputs":[]},{"cell_type":"markdown","source":"Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack.","metadata":{}},{"cell_type":"code","source":"locations = [\n {\n \"Name\": \"Super Gore Nest\",\n \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\"\n },\n {\n \"Name\": \"Exultia\",\n \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\"\n },\n {\n \"Name\": \"Cultist Base\",\n \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"Taras Nabad\",\n \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\"\n },\n {\n \"Name\": \"Nekravol\",\n \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\"\n },\n {\n \"Name\": \"Urdak\",\n \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"UAC Base\",\n \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\"\n }\n]\n\ncombat_casualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n\nmissions = [\n \"Locate and confront a key leader of Hell’s invasion forces.\",\n \"Clear out demonic infestations to secure a strategic foothold.\",\n \"Disrupt Hell's control over the area by eliminating critical targets.\",\n \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n \"Locate and destroy the central power source to weaken enemy forces.\",\n \"Collect essential resources before the area becomes unstable.\"\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:18:36.451643Z","iopub.execute_input":"2024-11-15T14:18:36.452081Z","iopub.status.idle":"2024-11-15T14:18:36.461214Z","shell.execute_reply.started":"2024-11-15T14:18:36.452040Z","shell.execute_reply":"2024-11-15T14:18:36.459746Z"},"trusted":true},"execution_count":20,"outputs":[]},{"cell_type":"markdown","source":"Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI.","metadata":{}},{"cell_type":"code","source":"def generate_missions():\n selectedmissions = []\n loop = 0\n \n while loop < 3:\n location = random.choice(locations)\n casualties = random.choice(combat_casualties)\n mission = random.choice(missions)\n final = (\n f'LocationName: {location[\"Name\"]}, '\n f'LocationInfo: {location[\"Description\"]}, '\n f'HumanCombatCasualties: {casualties}, '\n f'Mission: {mission}'\n )\n \n selectedmissions.append(final)\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n missions_string = \"\\n\".join(missions) # Or \", \".join(missions) for a comma-separated string\n print(missions_string)\n return missions_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:19:45.598722Z","iopub.execute_input":"2024-11-15T14:19:45.599194Z","iopub.status.idle":"2024-11-15T14:19:45.607945Z","shell.execute_reply.started":"2024-11-15T14:19:45.599154Z","shell.execute_reply":"2024-11-15T14:19:45.606150Z"},"trusted":true},"execution_count":24,"outputs":[]},{"cell_type":"code","source":"generate_missions()","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:19:46.371416Z","iopub.execute_input":"2024-11-15T14:19:46.371856Z","iopub.status.idle":"2024-11-15T14:19:46.379708Z","shell.execute_reply.started":"2024-11-15T14:19:46.371816Z","shell.execute_reply":"2024-11-15T14:19:46.378629Z"},"trusted":true},"execution_count":25,"outputs":[{"name":"stdout","text":"Locate and confront a key leader of Hell’s invasion forces.\nClear out demonic infestations to secure a strategic foothold.\nDisrupt Hell's control over the area by eliminating critical targets.\nEnter a critical demonic stronghold to disrupt enemy operations.\nLocate and destroy the central power source to weaken enemy forces.\nCollect essential resources before the area becomes unstable.\n","output_type":"stream"},{"execution_count":25,"output_type":"execute_result","data":{"text/plain":"\"Locate and confront a key leader of Hell’s invasion forces.\\nClear out demonic infestations to secure a strategic foothold.\\nDisrupt Hell's control over the area by eliminating critical targets.\\nEnter a critical demonic stronghold to disrupt enemy operations.\\nLocate and destroy the central power source to weaken enemy forces.\\nCollect essential resources before the area becomes unstable.\""},"metadata":{}}]},{"cell_type":"markdown","source":"Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n\nWe are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line","metadata":{}},{"cell_type":"markdown","source":"Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!","metadata":{}},{"cell_type":"code","source":"# We make our history a separate block to be easier to add to later on! This is essentially our history\ninitial_messages = [\n {\n \"role\": \"user\",\n \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:46.496845Z","iopub.execute_input":"2024-11-15T14:22:46.497277Z","iopub.status.idle":"2024-11-15T14:22:46.504279Z","shell.execute_reply.started":"2024-11-15T14:22:46.497238Z","shell.execute_reply":"2024-11-15T14:22:46.502560Z"},"trusted":true},"execution_count":40,"outputs":[]},{"cell_type":"markdown","source":"Now to construct a request!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initial_messages\n)\n\nprint(response.content)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:50.514617Z","iopub.execute_input":"2024-11-15T14:22:50.515042Z","iopub.status.idle":"2024-11-15T14:22:53.121648Z","shell.execute_reply.started":"2024-11-15T14:22:50.514986Z","shell.execute_reply":"2024-11-15T14:22:53.120214Z"},"trusted":true},"execution_count":41,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's start by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01EFVz2tuJFfnz3irfJmuoxB', input={}, name='generate_missions', type='tool_use')]\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Having trouble understanding this? The first block given is always Ai dialouge! You can use response.content[0].text to get the AI's text! Let's try it below.","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:57.191407Z","iopub.execute_input":"2024-11-15T14:22:57.191916Z","iopub.status.idle":"2024-11-15T14:22:57.199061Z","shell.execute_reply.started":"2024-11-15T14:22:57.191874Z","shell.execute_reply":"2024-11-15T14:22:57.197206Z"},"trusted":true},"execution_count":42,"outputs":[{"name":"stdout","text":"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\n\nLet's start by retrieving the missions:\n","output_type":"stream"}]},{"cell_type":"markdown","source":"The code below finds the tool used!","metadata":{}},{"cell_type":"code","source":"gen_mission_result = \"\"\n\n# Print response content to see the data\nprint(response.content)\n\n# Assuming ToolUseBlock is at index 1\ntool_use_block = response.content[1]\n\n# Get the tool name and input\ntool_name = tool_use_block.name\ntool_input = tool_use_block.input\n\n# We don't need to look to extract any inputs since we don't use any\n\n# Check if the tool name is \"generate_missions\"\nif tool_name == \"generate_missions\":\n # Call the function with the tool creator as an argument\n gen_mission_result = generate_missions()\n ","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:04.154662Z","iopub.execute_input":"2024-11-15T14:23:04.155092Z","iopub.status.idle":"2024-11-15T14:23:04.162176Z","shell.execute_reply.started":"2024-11-15T14:23:04.155051Z","shell.execute_reply":"2024-11-15T14:23:04.160810Z"},"trusted":true},"execution_count":44,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's start by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01EFVz2tuJFfnz3irfJmuoxB', input={}, name='generate_missions', type='tool_use')]\nLocate and confront a key leader of Hell’s invasion forces.\nClear out demonic infestations to secure a strategic foothold.\nDisrupt Hell's control over the area by eliminating critical targets.\nEnter a critical demonic stronghold to disrupt enemy operations.\nLocate and destroy the central power source to weaken enemy forces.\nCollect essential resources before the area becomes unstable.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Now we add these as context to the LLM through intial messages!","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": gen_mission_result\n})\n\ninitial_messages.append({\n \"role\": \"user\",\n \"content\": \"Based on these, which location should take priority and why?\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:07.709617Z","iopub.execute_input":"2024-11-15T14:23:07.710057Z","iopub.status.idle":"2024-11-15T14:23:07.716515Z","shell.execute_reply.started":"2024-11-15T14:23:07.709991Z","shell.execute_reply":"2024-11-15T14:23:07.715065Z"},"trusted":true},"execution_count":45,"outputs":[]},{"cell_type":"markdown","source":"And now to get a response!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initial_messages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:11.419242Z","iopub.execute_input":"2024-11-15T14:23:11.420694Z","iopub.status.idle":"2024-11-15T14:23:13.335906Z","shell.execute_reply.started":"2024-11-15T14:23:11.420637Z","shell.execute_reply":"2024-11-15T14:23:13.334619Z"},"trusted":true},"execution_count":46,"outputs":[{"name":"stdout","text":"Message(id='msg_019ig6cyVqsAAXoH4b6UQ1E2', content=[TextBlock(text=\"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly accessing the mission data using the available tool. \", type='text'), ToolUseBlock(id='toolu_01TpiV2VVMR1bxPdjJqvEoTN', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=497, output_tokens=83))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Isolate again!","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:19.519440Z","iopub.execute_input":"2024-11-15T14:23:19.519851Z","iopub.status.idle":"2024-11-15T14:23:19.527206Z","shell.execute_reply.started":"2024-11-15T14:23:19.519813Z","shell.execute_reply":"2024-11-15T14:23:19.525421Z"},"trusted":true},"execution_count":47,"outputs":[{"name":"stdout","text":"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly accessing the mission data using the available tool. \n","output_type":"stream"}]},{"cell_type":"markdown","source":"Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n\nOne will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)","metadata":{}},{"cell_type":"code","source":"demons = [\n {\n \"Name\": \"Imp\",\n \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\"\n },\n {\n \"Name\": \"Cacodemon\",\n \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\"\n },\n {\n \"Name\": \"Hell Knight\",\n \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\"\n },\n {\n \"Name\": \"Mancubus\",\n \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\"\n }\n]\n\n\n\nweapons = [\n {\n \"Name\": \"Super Shotgun\",\n \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\"\n },\n {\n \"Name\": \"Rocket Launcher\",\n \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\"\n },\n {\n \"Name\": \"Chaingun\",\n \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\"\n },\n {\n \"Name\": \"BFG 9000\",\n \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\"\n },\n {\n \"Name\": \"Ice Bomb\",\n \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:22.484119Z","iopub.execute_input":"2024-11-15T14:23:22.484567Z","iopub.status.idle":"2024-11-15T14:23:22.493312Z","shell.execute_reply.started":"2024-11-15T14:23:22.484526Z","shell.execute_reply":"2024-11-15T14:23:22.492103Z"},"trusted":true},"execution_count":48,"outputs":[]},{"cell_type":"markdown","source":"Now we can keep the initialmessages from before actually! However let's change the context","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"user\",\n \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\"\n})\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:30.978162Z","iopub.execute_input":"2024-11-15T14:23:30.978580Z","iopub.status.idle":"2024-11-15T14:23:30.984405Z","shell.execute_reply.started":"2024-11-15T14:23:30.978541Z","shell.execute_reply":"2024-11-15T14:23:30.982981Z"},"trusted":true},"execution_count":50,"outputs":[]},{"cell_type":"markdown","source":"And we of course make functions","metadata":{}},{"cell_type":"code","source":"def enemyscan(amount):\n enemiesonscene = []\n loop = 0\n \n while loop < amount + 1:\n scannedenemy = random.choice(demons)\n \n # Append just the name of the demon to the list\n enemiesonscene.append(scannedenemy[\"Name\"])\n enemiesonscene.append(scannedenemy[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n enemies_string = \"\\n\".join(enemiesonscene) \n print(enemies_string)\n return enemies_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:35.486659Z","iopub.execute_input":"2024-11-15T14:23:35.487132Z","iopub.status.idle":"2024-11-15T14:23:35.494102Z","shell.execute_reply.started":"2024-11-15T14:23:35.487092Z","shell.execute_reply":"2024-11-15T14:23:35.492832Z"},"trusted":true},"execution_count":51,"outputs":[]},{"cell_type":"code","source":"enemyscan(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:38.992295Z","iopub.execute_input":"2024-11-15T14:23:38.992724Z","iopub.status.idle":"2024-11-15T14:23:39.002492Z","shell.execute_reply.started":"2024-11-15T14:23:38.992684Z","shell.execute_reply":"2024-11-15T14:23:39.000129Z"},"trusted":true},"execution_count":52,"outputs":[{"name":"stdout","text":"Cacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"},{"execution_count":52,"output_type":"execute_result","data":{"text/plain":"'Cacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\\nHell Knight\\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.'"},"metadata":{}}]},{"cell_type":"markdown","source":"And now inventory","metadata":{}},{"cell_type":"code","source":"def inventoryscan():\n weapons_at_hand = []\n loop = 0\n \n while loop < 5:\n weapon = random.choice(weapons)\n \n # Append just the name of the demon to the list\n weapons_at_hand.append(weapon[\"Name\"])\n weapons_at_hand.append(weapon[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n weapons_string = \"\\n\".join(weapons_at_hand) \n print(weapons_string)\n return weapons_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:58.063362Z","iopub.execute_input":"2024-11-15T14:23:58.064521Z","iopub.status.idle":"2024-11-15T14:23:58.074123Z","shell.execute_reply.started":"2024-11-15T14:23:58.064455Z","shell.execute_reply":"2024-11-15T14:23:58.072437Z"},"trusted":true},"execution_count":56,"outputs":[]},{"cell_type":"code","source":"inventoryscan()","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:59.680584Z","iopub.execute_input":"2024-11-15T14:23:59.681611Z","iopub.status.idle":"2024-11-15T14:23:59.690413Z","shell.execute_reply.started":"2024-11-15T14:23:59.681567Z","shell.execute_reply":"2024-11-15T14:23:59.688788Z"},"trusted":true},"execution_count":57,"outputs":[{"name":"stdout","text":"Ice Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nBFG 9000\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\nBFG 9000\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n","output_type":"stream"},{"execution_count":57,"output_type":"execute_result","data":{"text/plain":"'Ice Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\\nIce Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nSuper Shotgun\\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.'"},"metadata":{}}]},{"cell_type":"markdown","source":"With that, let's construct our new tools and run this!!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initial_messages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:09.047951Z","iopub.execute_input":"2024-11-15T14:24:09.048387Z","iopub.status.idle":"2024-11-15T14:24:14.559016Z","shell.execute_reply.started":"2024-11-15T14:24:09.048349Z","shell.execute_reply":"2024-11-15T14:24:14.557877Z"},"trusted":true},"execution_count":58,"outputs":[{"name":"stdout","text":"Message(id='msg_01HbnSVMaGjCWeeiHiQECsAL', content=[TextBlock(text=\"Certainly! I'll prioritize the missions and simultaneously scan for enemies and check the inventory to formulate the best combat strategy. Let's use both tools at once to gather the necessary information.\", type='text'), ToolUseBlock(id='toolu_01CF2bQUo6shR23g46iKzTZP', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_01MfKAuBYvbBNbYzgTT8ker1', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=644, output_tokens=117))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Display just the text","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:41.374866Z","iopub.execute_input":"2024-11-15T14:24:41.375417Z","iopub.status.idle":"2024-11-15T14:24:41.383240Z","shell.execute_reply.started":"2024-11-15T14:24:41.375367Z","shell.execute_reply":"2024-11-15T14:24:41.381493Z"},"trusted":true},"execution_count":59,"outputs":[{"name":"stdout","text":"Certainly! I'll prioritize the missions and simultaneously scan for enemies and check the inventory to formulate the best combat strategy. Let's use both tools at once to gather the necessary information.\n","output_type":"stream"}]},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": f\"{str(response)}\" \n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:49.135198Z","iopub.execute_input":"2024-11-15T14:24:49.136672Z","iopub.status.idle":"2024-11-15T14:24:49.141761Z","shell.execute_reply.started":"2024-11-15T14:24:49.136612Z","shell.execute_reply":"2024-11-15T14:24:49.140478Z"},"trusted":true},"execution_count":61,"outputs":[]},{"cell_type":"markdown","source":"And now to get the information and put it all together! PLEASE read the comments!","metadata":{}},{"cell_type":"code","source":"inv_scan_res = \"\"\nenemy_scan_res = \"\"\n\n\nresponse_str = str(response) \ntool_use_count = response_str.count(\"ToolUseBlock\") #We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n\n\n# You can use print(tool_use_count)to validate the ToolBlocks here if you wish\n\nloop = 0 \n\n#We do this instead of a (foreach) because we need to skip the first block! This contains the message from the AI, not the tool! This way allows us to reference the item we want as easily as possible without complex logic needed!\n\nwhile loop < tool_use_count: #We will get the tools now\n tool_use_block = response.content[loop + 1] #We start at 1 since 0 holds the AI mesage\n tool_name = tool_use_block.name\n tool_input = tool_use_block.input\n \n if tool_name == \"inventoryscan_tool\":\n # Call the inventoryscan function for inventoryscan_tool\n inv_scan_res = inventoryscan()\n elif tool_name == \"enemyscan_tool\":\n # Get the amount for enemyscan_tool\n amount = tool_input['amount']\n # Call the enemyscan function with the amount\n enemy_scan_res = enemyscan(amount)\n \n loop = loop + 1 \nprint (inv_scan_res)\nprint (enemy_scan_res)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:53.603991Z","iopub.execute_input":"2024-11-15T14:24:53.604447Z","iopub.status.idle":"2024-11-15T14:24:53.614728Z","shell.execute_reply.started":"2024-11-15T14:24:53.604392Z","shell.execute_reply":"2024-11-15T14:24:53.613125Z"},"trusted":true},"execution_count":62,"outputs":[{"name":"stdout","text":"Hell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we are basically done! We can give this to th AI and see what we get","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": f\"Weapons Inventory Scan Result: {inv_scan_res}\\nEnemy Scans Result: {enemy_scan_res}\" \n})\n\n\ninitial_messages.append({\n \"role\": \"user\",\n \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:25:57.234726Z","iopub.execute_input":"2024-11-15T14:25:57.235145Z","iopub.status.idle":"2024-11-15T14:25:57.242217Z","shell.execute_reply.started":"2024-11-15T14:25:57.235106Z","shell.execute_reply":"2024-11-15T14:25:57.240715Z"},"trusted":true},"execution_count":71,"outputs":[]},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initial_messages\n)\n\nmessage = response.content[0].text\nprint(message)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:26:39.556790Z","iopub.execute_input":"2024-11-15T14:26:39.557247Z","iopub.status.idle":"2024-11-15T14:26:51.509067Z","shell.execute_reply.started":"2024-11-15T14:26:39.557207Z","shell.execute_reply":"2024-11-15T14:26:51.507785Z"},"trusted":true},"execution_count":73,"outputs":[{"name":"stdout","text":"Based on the enemy scan and weapon inventory results, here's the recommended combat plan for eliminating these demons efficiently:\n\n1. Initial Crowd Control:\nStart by using the Ice Bomb to freeze as many demons as possible, particularly targeting the group of Hell Knights and the Mancubus. This will temporarily immobilize them and make them more vulnerable to attacks.\n\n2. Priority Target - Mancubus:\nThe Mancubus should be your first priority due to its high damage output and area denial capabilities.\nWeapon: Rocket Launcher\nStrategy: Use the Lock-On Burst mod (if available) to quickly dispatch the Mancubus while it's frozen. Aim for its arm cannons as they are typically weak points.\n\n3. Hell Knights (x3):\nNext, focus on the Hell Knights as they pose the greatest physical threat when they unfreeze.\nWeapon: Super Shotgun\nStrategy: Use the Meat Hook attachment to quickly close the distance and deliver devastating point-blank shots. Aim for their heads or exposed body parts for maximum damage. The Super Shotgun's high damage output is perfect for their tough hides.\n\n4. Imps (x2):\nClean up the remaining Imps last, as they are the least threatening in this group.\nWeapon: Super Shotgun\nStrategy: Their agility makes them tricky targets, but the Super Shotgun's spread will make it easier to hit them. Use quick, mobile shots to take them down efficiently.\n\nGeneral tips:\n1. Utilize the Meat Hook attachment on the Super Shotgun for rapid repositioning between targets.\n2. Keep moving to avoid being cornered by the Hell Knights once they unfreeze.\n3. Use Glory Kills whenever possible to replenish health and create momentary invulnerability frames.\n4. If enemies group up again, don't hesitate to use another Ice Bomb or Rocket Launcher shot for area damage.\n5. Be aware of the Imps' ability to climb walls and attack from unexpected angles.\n\nRemember, the key to success is maintaining mobility, prioritizing threats, and making efficient use of your powerful arsenal. Good luck, Doom Slayer!\n","output_type":"stream"}]},{"cell_type":"markdown","source":"End the session","metadata":{}},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]} \ No newline at end of file From 4d5b18bb2d52b1de33518ad9d176fed809f22565 Mon Sep 17 00:00:00 2001 From: reibs Date: Tue, 19 Nov 2024 00:23:53 -0800 Subject: [PATCH 05/34] clean notebook --- ...entops-anthropic-understanding-tools.ipynb | 1038 ++++++++++++++++- 1 file changed, 1037 insertions(+), 1 deletion(-) diff --git a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb index 71c36f673..9cc95c57b 100644 --- a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb +++ b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb @@ -1 +1,1037 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! ","metadata":{}},{"cell_type":"markdown","source":"To get started, we will import Agentops and Anthropic","metadata":{}},{"cell_type":"code","source":"!pip install agentops\n!pip install anthropic","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:10:18.453801Z","iopub.execute_input":"2024-11-15T14:10:18.454259Z","iopub.status.idle":"2024-11-15T14:10:43.013126Z","shell.execute_reply.started":"2024-11-15T14:10:18.454211Z","shell.execute_reply":"2024-11-15T14:10:43.011519Z"},"trusted":true},"execution_count":5,"outputs":[{"name":"stdout","text":"Requirement already satisfied: agentops in /opt/conda/lib/python3.10/site-packages (0.3.17)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nRequirement already satisfied: psutil==5.9.8 in /opt/conda/lib/python3.10/site-packages (from agentops) (5.9.8)\nRequirement already satisfied: packaging==23.2 in /opt/conda/lib/python3.10/site-packages (from agentops) (23.2)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nRequirement already satisfied: anthropic in /opt/conda/lib/python3.10/site-packages (0.39.0)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nRequirement already satisfied: jiter<1,>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.7.1)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Setup our generic default statements","metadata":{}},{"cell_type":"code","source":"from anthropic import Anthropic, AsyncAnthropic\nimport agentops\nimport os\nimport random #We don't need this for agentops, we use this to generate a message later\nimport time #We don't need this for agentops either, we use this when simulating an API later\nimport re #Regex for formatting\nfrom dotenv import load_dotenv","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:11:48.157831Z","iopub.execute_input":"2024-11-15T14:11:48.158313Z","iopub.status.idle":"2024-11-15T14:11:48.166924Z","shell.execute_reply.started":"2024-11-15T14:11:48.158267Z","shell.execute_reply":"2024-11-15T14:11:48.164611Z"},"trusted":true},"execution_count":6,"outputs":[]},{"cell_type":"markdown","source":"And set our API keys.","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:15:34.282826Z","iopub.execute_input":"2024-11-15T14:15:34.283338Z","iopub.status.idle":"2024-11-15T14:15:34.290763Z","shell.execute_reply.started":"2024-11-15T14:15:34.283286Z","shell.execute_reply":"2024-11-15T14:15:34.289526Z"},"trusted":true},"execution_count":10,"outputs":[]},{"cell_type":"markdown","source":"\nNow let's set the client as Anthropic and make an AgentOps session","metadata":{}},{"cell_type":"code","source":"agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"client = Anthropic(api_key=ANTHROPIC_API_KEY)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:15:43.763463Z","iopub.execute_input":"2024-11-15T14:15:43.763875Z","iopub.status.idle":"2024-11-15T14:15:43.784626Z","shell.execute_reply.started":"2024-11-15T14:15:43.763835Z","shell.execute_reply":"2024-11-15T14:15:43.783492Z"},"trusted":true},"execution_count":12,"outputs":[]},{"cell_type":"markdown","source":"Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack.","metadata":{}},{"cell_type":"code","source":"locations = [\n {\n \"Name\": \"Super Gore Nest\",\n \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\"\n },\n {\n \"Name\": \"Exultia\",\n \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\"\n },\n {\n \"Name\": \"Cultist Base\",\n \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"Taras Nabad\",\n \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\"\n },\n {\n \"Name\": \"Nekravol\",\n \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\"\n },\n {\n \"Name\": \"Urdak\",\n \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\"\n },\n {\n \"Name\": \"UAC Base\",\n \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\"\n }\n]\n\ncombat_casualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n\nmissions = [\n \"Locate and confront a key leader of Hell’s invasion forces.\",\n \"Clear out demonic infestations to secure a strategic foothold.\",\n \"Disrupt Hell's control over the area by eliminating critical targets.\",\n \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n \"Locate and destroy the central power source to weaken enemy forces.\",\n \"Collect essential resources before the area becomes unstable.\"\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:18:36.451643Z","iopub.execute_input":"2024-11-15T14:18:36.452081Z","iopub.status.idle":"2024-11-15T14:18:36.461214Z","shell.execute_reply.started":"2024-11-15T14:18:36.452040Z","shell.execute_reply":"2024-11-15T14:18:36.459746Z"},"trusted":true},"execution_count":20,"outputs":[]},{"cell_type":"markdown","source":"Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI.","metadata":{}},{"cell_type":"code","source":"def generate_missions():\n selectedmissions = []\n loop = 0\n \n while loop < 3:\n location = random.choice(locations)\n casualties = random.choice(combat_casualties)\n mission = random.choice(missions)\n final = (\n f'LocationName: {location[\"Name\"]}, '\n f'LocationInfo: {location[\"Description\"]}, '\n f'HumanCombatCasualties: {casualties}, '\n f'Mission: {mission}'\n )\n \n selectedmissions.append(final)\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n missions_string = \"\\n\".join(missions) # Or \", \".join(missions) for a comma-separated string\n print(missions_string)\n return missions_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:19:45.598722Z","iopub.execute_input":"2024-11-15T14:19:45.599194Z","iopub.status.idle":"2024-11-15T14:19:45.607945Z","shell.execute_reply.started":"2024-11-15T14:19:45.599154Z","shell.execute_reply":"2024-11-15T14:19:45.606150Z"},"trusted":true},"execution_count":24,"outputs":[]},{"cell_type":"code","source":"generate_missions()","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:19:46.371416Z","iopub.execute_input":"2024-11-15T14:19:46.371856Z","iopub.status.idle":"2024-11-15T14:19:46.379708Z","shell.execute_reply.started":"2024-11-15T14:19:46.371816Z","shell.execute_reply":"2024-11-15T14:19:46.378629Z"},"trusted":true},"execution_count":25,"outputs":[{"name":"stdout","text":"Locate and confront a key leader of Hell’s invasion forces.\nClear out demonic infestations to secure a strategic foothold.\nDisrupt Hell's control over the area by eliminating critical targets.\nEnter a critical demonic stronghold to disrupt enemy operations.\nLocate and destroy the central power source to weaken enemy forces.\nCollect essential resources before the area becomes unstable.\n","output_type":"stream"},{"execution_count":25,"output_type":"execute_result","data":{"text/plain":"\"Locate and confront a key leader of Hell’s invasion forces.\\nClear out demonic infestations to secure a strategic foothold.\\nDisrupt Hell's control over the area by eliminating critical targets.\\nEnter a critical demonic stronghold to disrupt enemy operations.\\nLocate and destroy the central power source to weaken enemy forces.\\nCollect essential resources before the area becomes unstable.\""},"metadata":{}}]},{"cell_type":"markdown","source":"Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n\nWe are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line","metadata":{}},{"cell_type":"markdown","source":"Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!","metadata":{}},{"cell_type":"code","source":"# We make our history a separate block to be easier to add to later on! This is essentially our history\ninitial_messages = [\n {\n \"role\": \"user\",\n \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:46.496845Z","iopub.execute_input":"2024-11-15T14:22:46.497277Z","iopub.status.idle":"2024-11-15T14:22:46.504279Z","shell.execute_reply.started":"2024-11-15T14:22:46.497238Z","shell.execute_reply":"2024-11-15T14:22:46.502560Z"},"trusted":true},"execution_count":40,"outputs":[]},{"cell_type":"markdown","source":"Now to construct a request!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initial_messages\n)\n\nprint(response.content)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:50.514617Z","iopub.execute_input":"2024-11-15T14:22:50.515042Z","iopub.status.idle":"2024-11-15T14:22:53.121648Z","shell.execute_reply.started":"2024-11-15T14:22:50.514986Z","shell.execute_reply":"2024-11-15T14:22:53.120214Z"},"trusted":true},"execution_count":41,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's start by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01EFVz2tuJFfnz3irfJmuoxB', input={}, name='generate_missions', type='tool_use')]\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Having trouble understanding this? The first block given is always Ai dialouge! You can use response.content[0].text to get the AI's text! Let's try it below.","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:22:57.191407Z","iopub.execute_input":"2024-11-15T14:22:57.191916Z","iopub.status.idle":"2024-11-15T14:22:57.199061Z","shell.execute_reply.started":"2024-11-15T14:22:57.191874Z","shell.execute_reply":"2024-11-15T14:22:57.197206Z"},"trusted":true},"execution_count":42,"outputs":[{"name":"stdout","text":"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\n\nLet's start by retrieving the missions:\n","output_type":"stream"}]},{"cell_type":"markdown","source":"The code below finds the tool used!","metadata":{}},{"cell_type":"code","source":"gen_mission_result = \"\"\n\n# Print response content to see the data\nprint(response.content)\n\n# Assuming ToolUseBlock is at index 1\ntool_use_block = response.content[1]\n\n# Get the tool name and input\ntool_name = tool_use_block.name\ntool_input = tool_use_block.input\n\n# We don't need to look to extract any inputs since we don't use any\n\n# Check if the tool name is \"generate_missions\"\nif tool_name == \"generate_missions\":\n # Call the function with the tool creator as an argument\n gen_mission_result = generate_missions()\n ","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:04.154662Z","iopub.execute_input":"2024-11-15T14:23:04.155092Z","iopub.status.idle":"2024-11-15T14:23:04.162176Z","shell.execute_reply.started":"2024-11-15T14:23:04.155051Z","shell.execute_reply":"2024-11-15T14:23:04.160810Z"},"trusted":true},"execution_count":44,"outputs":[{"name":"stdout","text":"[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's start by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01EFVz2tuJFfnz3irfJmuoxB', input={}, name='generate_missions', type='tool_use')]\nLocate and confront a key leader of Hell’s invasion forces.\nClear out demonic infestations to secure a strategic foothold.\nDisrupt Hell's control over the area by eliminating critical targets.\nEnter a critical demonic stronghold to disrupt enemy operations.\nLocate and destroy the central power source to weaken enemy forces.\nCollect essential resources before the area becomes unstable.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Now we add these as context to the LLM through intial messages!","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": gen_mission_result\n})\n\ninitial_messages.append({\n \"role\": \"user\",\n \"content\": \"Based on these, which location should take priority and why?\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:07.709617Z","iopub.execute_input":"2024-11-15T14:23:07.710057Z","iopub.status.idle":"2024-11-15T14:23:07.716515Z","shell.execute_reply.started":"2024-11-15T14:23:07.709991Z","shell.execute_reply":"2024-11-15T14:23:07.715065Z"},"trusted":true},"execution_count":45,"outputs":[]},{"cell_type":"markdown","source":"And now to get a response!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[{\n \"name\": \"generate_missions\",\n \"description\": \"Retrieve three missions for the DoomSlayer\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n },\n \"required\": []\n },\n }],\n messages=initial_messages\n)\n\nprint(response)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:11.419242Z","iopub.execute_input":"2024-11-15T14:23:11.420694Z","iopub.status.idle":"2024-11-15T14:23:13.335906Z","shell.execute_reply.started":"2024-11-15T14:23:11.420637Z","shell.execute_reply":"2024-11-15T14:23:13.334619Z"},"trusted":true},"execution_count":46,"outputs":[{"name":"stdout","text":"Message(id='msg_019ig6cyVqsAAXoH4b6UQ1E2', content=[TextBlock(text=\"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly accessing the mission data using the available tool. \", type='text'), ToolUseBlock(id='toolu_01TpiV2VVMR1bxPdjJqvEoTN', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=497, output_tokens=83))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Isolate again!","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:19.519440Z","iopub.execute_input":"2024-11-15T14:23:19.519851Z","iopub.status.idle":"2024-11-15T14:23:19.527206Z","shell.execute_reply.started":"2024-11-15T14:23:19.519813Z","shell.execute_reply":"2024-11-15T14:23:19.525421Z"},"trusted":true},"execution_count":47,"outputs":[{"name":"stdout","text":"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly accessing the mission data using the available tool. \n","output_type":"stream"}]},{"cell_type":"markdown","source":"Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n\nOne will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)","metadata":{}},{"cell_type":"code","source":"demons = [\n {\n \"Name\": \"Imp\",\n \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\"\n },\n {\n \"Name\": \"Cacodemon\",\n \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\"\n },\n {\n \"Name\": \"Hell Knight\",\n \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\"\n },\n {\n \"Name\": \"Mancubus\",\n \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\"\n }\n]\n\n\n\nweapons = [\n {\n \"Name\": \"Super Shotgun\",\n \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\"\n },\n {\n \"Name\": \"Rocket Launcher\",\n \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\"\n },\n {\n \"Name\": \"Chaingun\",\n \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\"\n },\n {\n \"Name\": \"BFG 9000\",\n \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\"\n },\n {\n \"Name\": \"Ice Bomb\",\n \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\"\n }\n]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:22.484119Z","iopub.execute_input":"2024-11-15T14:23:22.484567Z","iopub.status.idle":"2024-11-15T14:23:22.493312Z","shell.execute_reply.started":"2024-11-15T14:23:22.484526Z","shell.execute_reply":"2024-11-15T14:23:22.492103Z"},"trusted":true},"execution_count":48,"outputs":[]},{"cell_type":"markdown","source":"Now we can keep the initialmessages from before actually! However let's change the context","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"user\",\n \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\"\n})\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:30.978162Z","iopub.execute_input":"2024-11-15T14:23:30.978580Z","iopub.status.idle":"2024-11-15T14:23:30.984405Z","shell.execute_reply.started":"2024-11-15T14:23:30.978541Z","shell.execute_reply":"2024-11-15T14:23:30.982981Z"},"trusted":true},"execution_count":50,"outputs":[]},{"cell_type":"markdown","source":"And we of course make functions","metadata":{}},{"cell_type":"code","source":"def enemyscan(amount):\n enemiesonscene = []\n loop = 0\n \n while loop < amount + 1:\n scannedenemy = random.choice(demons)\n \n # Append just the name of the demon to the list\n enemiesonscene.append(scannedenemy[\"Name\"])\n enemiesonscene.append(scannedenemy[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n enemies_string = \"\\n\".join(enemiesonscene) \n print(enemies_string)\n return enemies_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:35.486659Z","iopub.execute_input":"2024-11-15T14:23:35.487132Z","iopub.status.idle":"2024-11-15T14:23:35.494102Z","shell.execute_reply.started":"2024-11-15T14:23:35.487092Z","shell.execute_reply":"2024-11-15T14:23:35.492832Z"},"trusted":true},"execution_count":51,"outputs":[]},{"cell_type":"code","source":"enemyscan(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:38.992295Z","iopub.execute_input":"2024-11-15T14:23:38.992724Z","iopub.status.idle":"2024-11-15T14:23:39.002492Z","shell.execute_reply.started":"2024-11-15T14:23:38.992684Z","shell.execute_reply":"2024-11-15T14:23:39.000129Z"},"trusted":true},"execution_count":52,"outputs":[{"name":"stdout","text":"Cacodemon\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n","output_type":"stream"},{"execution_count":52,"output_type":"execute_result","data":{"text/plain":"'Cacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\\nHell Knight\\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nMancubus\\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.'"},"metadata":{}}]},{"cell_type":"markdown","source":"And now inventory","metadata":{}},{"cell_type":"code","source":"def inventoryscan():\n weapons_at_hand = []\n loop = 0\n \n while loop < 5:\n weapon = random.choice(weapons)\n \n # Append just the name of the demon to the list\n weapons_at_hand.append(weapon[\"Name\"])\n weapons_at_hand.append(weapon[\"Description\"])\n loop += 1\n \n # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n weapons_string = \"\\n\".join(weapons_at_hand) \n print(weapons_string)\n return weapons_string","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:58.063362Z","iopub.execute_input":"2024-11-15T14:23:58.064521Z","iopub.status.idle":"2024-11-15T14:23:58.074123Z","shell.execute_reply.started":"2024-11-15T14:23:58.064455Z","shell.execute_reply":"2024-11-15T14:23:58.072437Z"},"trusted":true},"execution_count":56,"outputs":[]},{"cell_type":"code","source":"inventoryscan()","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:23:59.680584Z","iopub.execute_input":"2024-11-15T14:23:59.681611Z","iopub.status.idle":"2024-11-15T14:23:59.690413Z","shell.execute_reply.started":"2024-11-15T14:23:59.681567Z","shell.execute_reply":"2024-11-15T14:23:59.688788Z"},"trusted":true},"execution_count":57,"outputs":[{"name":"stdout","text":"Ice Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nBFG 9000\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\nBFG 9000\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n","output_type":"stream"},{"execution_count":57,"output_type":"execute_result","data":{"text/plain":"'Ice Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\\nIce Bomb\\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nSuper Shotgun\\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.'"},"metadata":{}}]},{"cell_type":"markdown","source":"With that, let's construct our new tools and run this!!","metadata":{}},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initial_messages\n)\n\nprint(response)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:09.047951Z","iopub.execute_input":"2024-11-15T14:24:09.048387Z","iopub.status.idle":"2024-11-15T14:24:14.559016Z","shell.execute_reply.started":"2024-11-15T14:24:09.048349Z","shell.execute_reply":"2024-11-15T14:24:14.557877Z"},"trusted":true},"execution_count":58,"outputs":[{"name":"stdout","text":"Message(id='msg_01HbnSVMaGjCWeeiHiQECsAL', content=[TextBlock(text=\"Certainly! I'll prioritize the missions and simultaneously scan for enemies and check the inventory to formulate the best combat strategy. Let's use both tools at once to gather the necessary information.\", type='text'), ToolUseBlock(id='toolu_01CF2bQUo6shR23g46iKzTZP', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_01MfKAuBYvbBNbYzgTT8ker1', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=644, output_tokens=117))\n","output_type":"stream"}]},{"cell_type":"markdown","source":"Display just the text","metadata":{}},{"cell_type":"code","source":"message = response.content[0].text\nprint(message)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:41.374866Z","iopub.execute_input":"2024-11-15T14:24:41.375417Z","iopub.status.idle":"2024-11-15T14:24:41.383240Z","shell.execute_reply.started":"2024-11-15T14:24:41.375367Z","shell.execute_reply":"2024-11-15T14:24:41.381493Z"},"trusted":true},"execution_count":59,"outputs":[{"name":"stdout","text":"Certainly! I'll prioritize the missions and simultaneously scan for enemies and check the inventory to formulate the best combat strategy. Let's use both tools at once to gather the necessary information.\n","output_type":"stream"}]},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": f\"{str(response)}\" \n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:49.135198Z","iopub.execute_input":"2024-11-15T14:24:49.136672Z","iopub.status.idle":"2024-11-15T14:24:49.141761Z","shell.execute_reply.started":"2024-11-15T14:24:49.136612Z","shell.execute_reply":"2024-11-15T14:24:49.140478Z"},"trusted":true},"execution_count":61,"outputs":[]},{"cell_type":"markdown","source":"And now to get the information and put it all together! PLEASE read the comments!","metadata":{}},{"cell_type":"code","source":"inv_scan_res = \"\"\nenemy_scan_res = \"\"\n\n\nresponse_str = str(response) \ntool_use_count = response_str.count(\"ToolUseBlock\") #We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n\n\n# You can use print(tool_use_count)to validate the ToolBlocks here if you wish\n\nloop = 0 \n\n#We do this instead of a (foreach) because we need to skip the first block! This contains the message from the AI, not the tool! This way allows us to reference the item we want as easily as possible without complex logic needed!\n\nwhile loop < tool_use_count: #We will get the tools now\n tool_use_block = response.content[loop + 1] #We start at 1 since 0 holds the AI mesage\n tool_name = tool_use_block.name\n tool_input = tool_use_block.input\n \n if tool_name == \"inventoryscan_tool\":\n # Call the inventoryscan function for inventoryscan_tool\n inv_scan_res = inventoryscan()\n elif tool_name == \"enemyscan_tool\":\n # Get the amount for enemyscan_tool\n amount = tool_input['amount']\n # Call the enemyscan function with the amount\n enemy_scan_res = enemyscan(amount)\n \n loop = loop + 1 \nprint (inv_scan_res)\nprint (enemy_scan_res)","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:24:53.603991Z","iopub.execute_input":"2024-11-15T14:24:53.604447Z","iopub.status.idle":"2024-11-15T14:24:53.614728Z","shell.execute_reply.started":"2024-11-15T14:24:53.604392Z","shell.execute_reply":"2024-11-15T14:24:53.613125Z"},"trusted":true},"execution_count":62,"outputs":[{"name":"stdout","text":"Hell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nSuper Shotgun\nA powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\nRocket Launcher\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\nIce Bomb\nA special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nMancubus\nA grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\nImp\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\nHell Knight\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n","output_type":"stream"}]},{"cell_type":"markdown","source":"And now we are basically done! We can give this to th AI and see what we get","metadata":{}},{"cell_type":"code","source":"initial_messages.append({\n \"role\": \"assistant\",\n \"content\": f\"Weapons Inventory Scan Result: {inv_scan_res}\\nEnemy Scans Result: {enemy_scan_res}\" \n})\n\n\ninitial_messages.append({\n \"role\": \"user\",\n \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\"\n})","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:25:57.234726Z","iopub.execute_input":"2024-11-15T14:25:57.235145Z","iopub.status.idle":"2024-11-15T14:25:57.242217Z","shell.execute_reply.started":"2024-11-15T14:25:57.235106Z","shell.execute_reply":"2024-11-15T14:25:57.240715Z"},"trusted":true},"execution_count":71,"outputs":[]},{"cell_type":"code","source":"response = client.messages.create(\n max_tokens=5000,\n model=\"claude-3-5-sonnet-20240620\",\n tools=[\n {\n \"name\": \"enemyscan_tool\",\n \"description\": \"Retrieve a list of demons currently present in the area.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"amount\": {\n \"type\": \"integer\",\n \"description\": \"Number of enemies to scan.\"\n }\n },\n \"required\": [\"amount\"]\n },\n },\n {\n \"name\": \"inventoryscan_tool\",\n \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {},\n \"required\": []\n },\n }\n ],\n messages=initial_messages\n)\n\nmessage = response.content[0].text\nprint(message)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-15T14:26:39.556790Z","iopub.execute_input":"2024-11-15T14:26:39.557247Z","iopub.status.idle":"2024-11-15T14:26:51.509067Z","shell.execute_reply.started":"2024-11-15T14:26:39.557207Z","shell.execute_reply":"2024-11-15T14:26:51.507785Z"},"trusted":true},"execution_count":73,"outputs":[{"name":"stdout","text":"Based on the enemy scan and weapon inventory results, here's the recommended combat plan for eliminating these demons efficiently:\n\n1. Initial Crowd Control:\nStart by using the Ice Bomb to freeze as many demons as possible, particularly targeting the group of Hell Knights and the Mancubus. This will temporarily immobilize them and make them more vulnerable to attacks.\n\n2. Priority Target - Mancubus:\nThe Mancubus should be your first priority due to its high damage output and area denial capabilities.\nWeapon: Rocket Launcher\nStrategy: Use the Lock-On Burst mod (if available) to quickly dispatch the Mancubus while it's frozen. Aim for its arm cannons as they are typically weak points.\n\n3. Hell Knights (x3):\nNext, focus on the Hell Knights as they pose the greatest physical threat when they unfreeze.\nWeapon: Super Shotgun\nStrategy: Use the Meat Hook attachment to quickly close the distance and deliver devastating point-blank shots. Aim for their heads or exposed body parts for maximum damage. The Super Shotgun's high damage output is perfect for their tough hides.\n\n4. Imps (x2):\nClean up the remaining Imps last, as they are the least threatening in this group.\nWeapon: Super Shotgun\nStrategy: Their agility makes them tricky targets, but the Super Shotgun's spread will make it easier to hit them. Use quick, mobile shots to take them down efficiently.\n\nGeneral tips:\n1. Utilize the Meat Hook attachment on the Super Shotgun for rapid repositioning between targets.\n2. Keep moving to avoid being cornered by the Hell Knights once they unfreeze.\n3. Use Glory Kills whenever possible to replenish health and create momentary invulnerability frames.\n4. If enemies group up again, don't hesitate to use another Ice Bomb or Rocket Launcher shot for area damage.\n5. Be aware of the Imps' ability to climb walls and attack from unexpected angles.\n\nRemember, the key to success is maintaining mobility, prioritizing threats, and making efficient use of your powerful arsenal. Good luck, Doom Slayer!\n","output_type":"stream"}]},{"cell_type":"markdown","source":"End the session","metadata":{}},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]} \ No newline at end of file +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To get started, we will import Agentops and Anthropic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install agentops\n", + "!pip install anthropic" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Setup our generic default statements" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from anthropic import Anthropic, AsyncAnthropic\n", + "import agentops\n", + "import os\n", + "import random #We don't need this for agentops, we use this to generate a message later\n", + "import time #We don't need this for agentops either, we use this when simulating an API later\n", + "import re #Regex for formatting\n", + "from dotenv import load_dotenv" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And set our API keys." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "load_dotenv()\n", + "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\n", + "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "Now let's set the client as Anthropic and make an AgentOps session" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "client = Anthropic(api_key=ANTHROPIC_API_KEY)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "locations = [\n", + " {\n", + " \"Name\": \"Super Gore Nest\",\n", + " \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\"\n", + " },\n", + " {\n", + " \"Name\": \"Exultia\",\n", + " \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\"\n", + " },\n", + " {\n", + " \"Name\": \"Cultist Base\",\n", + " \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\"\n", + " },\n", + " {\n", + " \"Name\": \"Taras Nabad\",\n", + " \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\"\n", + " },\n", + " {\n", + " \"Name\": \"Nekravol\",\n", + " \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\"\n", + " },\n", + " {\n", + " \"Name\": \"Urdak\",\n", + " \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\"\n", + " },\n", + " {\n", + " \"Name\": \"UAC Base\",\n", + " \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\"\n", + " }\n", + "]\n", + "\n", + "combat_casualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n", + "\n", + "missions = [\n", + " \"Locate and confront a key leader of Hell’s invasion forces.\",\n", + " \"Clear out demonic infestations to secure a strategic foothold.\",\n", + " \"Disrupt Hell's control over the area by eliminating critical targets.\",\n", + " \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n", + " \"Locate and destroy the central power source to weaken enemy forces.\",\n", + " \"Collect essential resources before the area becomes unstable.\"\n", + "]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "def generate_missions():\n", + " selectedmissions = []\n", + " loop = 0\n", + " \n", + " while loop < 3:\n", + " location = random.choice(locations)\n", + " casualties = random.choice(combat_casualties)\n", + " mission = random.choice(missions)\n", + " final = (\n", + " f'LocationName: {location[\"Name\"]}, '\n", + " f'LocationInfo: {location[\"Description\"]}, '\n", + " f'HumanCombatCasualties: {casualties}, '\n", + " f'Mission: {mission}'\n", + " )\n", + " \n", + " selectedmissions.append(final)\n", + " loop += 1\n", + " \n", + " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n", + " missions_string = \"\\n\".join(missions) # Or \", \".join(missions) for a comma-separated string\n", + " print(missions_string)\n", + " return missions_string" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Locate and confront a key leader of Hell’s invasion forces.\n", + "Clear out demonic infestations to secure a strategic foothold.\n", + "Disrupt Hell's control over the area by eliminating critical targets.\n", + "Enter a critical demonic stronghold to disrupt enemy operations.\n", + "Locate and destroy the central power source to weaken enemy forces.\n", + "Collect essential resources before the area becomes unstable.\n" + ] + }, + { + "data": { + "text/plain": [ + "\"Locate and confront a key leader of Hell’s invasion forces.\\nClear out demonic infestations to secure a strategic foothold.\\nDisrupt Hell's control over the area by eliminating critical targets.\\nEnter a critical demonic stronghold to disrupt enemy operations.\\nLocate and destroy the central power source to weaken enemy forces.\\nCollect essential resources before the area becomes unstable.\"" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "generate_missions()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n", + "\n", + "We are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "# We make our history a separate block to be easier to add to later on! This is essentially our history\n", + "initial_messages = [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \"\n", + " }\n", + "]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now to construct a request!" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n" + ] + } + ], + "source": [ + "response = client.messages.create(\n", + " max_tokens=5000,\n", + " model=\"claude-3-5-sonnet-20240620\",\n", + " tools=[{\n", + " \"name\": \"generate_missions\",\n", + " \"description\": \"Retrieve three missions for the DoomSlayer\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " },\n", + " \"required\": []\n", + " },\n", + " }],\n", + " messages=initial_messages\n", + ")\n", + "\n", + "print(response.content)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Having trouble understanding this? The first block given is always Ai dialouge! You can use response.content[0].text to get the AI's text! Let's try it below." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\n", + "\n", + "Let's begin by retrieving the missions:\n" + ] + } + ], + "source": [ + "message = response.content[0].text\n", + "print(message)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The code below finds the tool used!" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n", + "Locate and confront a key leader of Hell’s invasion forces.\n", + "Clear out demonic infestations to secure a strategic foothold.\n", + "Disrupt Hell's control over the area by eliminating critical targets.\n", + "Enter a critical demonic stronghold to disrupt enemy operations.\n", + "Locate and destroy the central power source to weaken enemy forces.\n", + "Collect essential resources before the area becomes unstable.\n" + ] + } + ], + "source": [ + "gen_mission_result = \"\"\n", + "\n", + "# Print response content to see the data\n", + "print(response.content)\n", + "\n", + "# Assuming ToolUseBlock is at index 1\n", + "tool_use_block = response.content[1]\n", + "\n", + "# Get the tool name and input\n", + "tool_name = tool_use_block.name\n", + "tool_input = tool_use_block.input\n", + "\n", + "# We don't need to look to extract any inputs since we don't use any\n", + "\n", + "# Check if the tool name is \"generate_missions\"\n", + "if tool_name == \"generate_missions\":\n", + " # Call the function with the tool creator as an argument\n", + " gen_mission_result = generate_missions()\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we add these as context to the LLM through intial messages!" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "initial_messages.append({\n", + " \"role\": \"assistant\",\n", + " \"content\": gen_mission_result\n", + "})\n", + "\n", + "initial_messages.append({\n", + " \"role\": \"user\",\n", + " \"content\": \"Based on these, which location should take priority and why?\"\n", + "})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And now to get a response!" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Message(id='msg_016Hd62W2sJNyd762Yp1udLd', content=[TextBlock(text=\"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \", type='text'), ToolUseBlock(id='toolu_01TUaMJbZc7VHMVZKaA9RqvL', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=497, output_tokens=83))\n" + ] + } + ], + "source": [ + "response = client.messages.create(\n", + " max_tokens=5000,\n", + " model=\"claude-3-5-sonnet-20240620\",\n", + " tools=[{\n", + " \"name\": \"generate_missions\",\n", + " \"description\": \"Retrieve three missions for the DoomSlayer\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " },\n", + " \"required\": []\n", + " },\n", + " }],\n", + " messages=initial_messages\n", + ")\n", + "\n", + "print(response)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Isolate again!" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \n" + ] + } + ], + "source": [ + "message = response.content[0].text\n", + "print(message)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n", + "\n", + "One will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "demons = [\n", + " {\n", + " \"Name\": \"Imp\",\n", + " \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\"\n", + " },\n", + " {\n", + " \"Name\": \"Cacodemon\",\n", + " \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\"\n", + " },\n", + " {\n", + " \"Name\": \"Hell Knight\",\n", + " \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\"\n", + " },\n", + " {\n", + " \"Name\": \"Mancubus\",\n", + " \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\"\n", + " }\n", + "]\n", + "\n", + "\n", + "\n", + "weapons = [\n", + " {\n", + " \"Name\": \"Super Shotgun\",\n", + " \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\"\n", + " },\n", + " {\n", + " \"Name\": \"Rocket Launcher\",\n", + " \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\"\n", + " },\n", + " {\n", + " \"Name\": \"Chaingun\",\n", + " \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\"\n", + " },\n", + " {\n", + " \"Name\": \"BFG 9000\",\n", + " \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\"\n", + " },\n", + " {\n", + " \"Name\": \"Ice Bomb\",\n", + " \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\"\n", + " }\n", + "]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we can keep the initialmessages from before actually! However let's change the context" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "initial_messages.append({\n", + " \"role\": \"user\",\n", + " \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\"\n", + "})\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we of course make functions" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "def enemyscan(amount):\n", + " enemiesonscene = []\n", + " loop = 0\n", + " \n", + " while loop < amount + 1:\n", + " scannedenemy = random.choice(demons)\n", + " \n", + " # Append just the name of the demon to the list\n", + " enemiesonscene.append(scannedenemy[\"Name\"])\n", + " enemiesonscene.append(scannedenemy[\"Description\"])\n", + " loop += 1\n", + " \n", + " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n", + " enemies_string = \"\\n\".join(enemiesonscene) \n", + " print(enemies_string)\n", + " return enemies_string" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Imp\n", + "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n", + "Cacodemon\n", + "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n", + "Imp\n", + "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n", + "Imp\n", + "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n", + "Cacodemon\n", + "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n" + ] + }, + { + "data": { + "text/plain": [ + "'Imp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nHell Knight\\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.'" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "enemyscan(5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And now inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [], + "source": [ + "def inventoryscan():\n", + " weapons_at_hand = []\n", + " loop = 0\n", + " \n", + " while loop < 5:\n", + " weapon = random.choice(weapons)\n", + " \n", + " # Append just the name of the demon to the list\n", + " weapons_at_hand.append(weapon[\"Name\"])\n", + " weapons_at_hand.append(weapon[\"Description\"])\n", + " loop += 1\n", + " \n", + " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n", + " weapons_string = \"\\n\".join(weapons_at_hand) \n", + " print(weapons_string)\n", + " return weapons_string" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "Chaingun\n", + "A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\n", + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "Rocket Launcher\n", + "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n", + "Rocket Launcher\n", + "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n" + ] + }, + { + "data": { + "text/plain": [ + "'BFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nChaingun\\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.'" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventoryscan()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With that, let's construct our new tools and run this!!" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Message(id='msg_0119o5gGDi7TRTsNPzNXd2ov', content=[TextBlock(text=\"Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\", type='text'), ToolUseBlock(id='toolu_01MmqMojDYtt5qdWnsXMJoWL', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_01WxN7tUMTFTai1WdiFc94HW', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=610, output_tokens=110))\n" + ] + } + ], + "source": [ + "response = client.messages.create(\n", + " max_tokens=5000,\n", + " model=\"claude-3-5-sonnet-20240620\",\n", + " tools=[\n", + " {\n", + " \"name\": \"enemyscan_tool\",\n", + " \"description\": \"Retrieve a list of demons currently present in the area.\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"amount\": {\n", + " \"type\": \"integer\",\n", + " \"description\": \"Number of enemies to scan.\"\n", + " }\n", + " },\n", + " \"required\": [\"amount\"]\n", + " },\n", + " },\n", + " {\n", + " \"name\": \"inventoryscan_tool\",\n", + " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {},\n", + " \"required\": []\n", + " },\n", + " }\n", + " ],\n", + " messages=initial_messages\n", + ")\n", + "\n", + "print(response)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Display just the text" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\n" + ] + } + ], + "source": [ + "message = response.content[0].text\n", + "print(message)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "initial_messages.append({\n", + " \"role\": \"assistant\",\n", + " \"content\": f\"{str(response)}\" \n", + "})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And now to get the information and put it all together! PLEASE read the comments!" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Imp\n", + "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Mancubus\n", + "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Cacodemon\n", + "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n", + "Rocket Launcher\n", + "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n", + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "Super Shotgun\n", + "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n", + "Ice Bomb\n", + "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n", + "Rocket Launcher\n", + "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n", + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "BFG 9000\n", + "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n", + "Super Shotgun\n", + "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n", + "Ice Bomb\n", + "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Imp\n", + "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Mancubus\n", + "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n", + "Hell Knight\n", + "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n", + "Cacodemon\n", + "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n" + ] + } + ], + "source": [ + "inv_scan_res = \"\"\n", + "enemy_scan_res = \"\"\n", + "\n", + "\n", + "response_str = str(response) \n", + "tool_use_count = response_str.count(\"ToolUseBlock\") #We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n", + "\n", + "\n", + "# You can use print(tool_use_count)to validate the ToolBlocks here if you wish\n", + "\n", + "loop = 0 \n", + "\n", + "#We do this instead of a (foreach) because we need to skip the first block! This contains the message from the AI, not the tool! This way allows us to reference the item we want as easily as possible without complex logic needed!\n", + "\n", + "while loop < tool_use_count: #We will get the tools now\n", + " tool_use_block = response.content[loop + 1] #We start at 1 since 0 holds the AI mesage\n", + " tool_name = tool_use_block.name\n", + " tool_input = tool_use_block.input\n", + " \n", + " if tool_name == \"inventoryscan_tool\":\n", + " # Call the inventoryscan function for inventoryscan_tool\n", + " inv_scan_res = inventoryscan()\n", + " elif tool_name == \"enemyscan_tool\":\n", + " # Get the amount for enemyscan_tool\n", + " amount = tool_input['amount']\n", + " # Call the enemyscan function with the amount\n", + " enemy_scan_res = enemyscan(amount)\n", + " \n", + " loop = loop + 1 \n", + "print (inv_scan_res)\n", + "print (enemy_scan_res)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And now we are basically done! We can give this to th AI and see what we get" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "initial_messages.append({\n", + " \"role\": \"assistant\",\n", + " \"content\": f\"Weapons Inventory Scan Result: {inv_scan_res}\\nEnemy Scans Result: {enemy_scan_res}\" \n", + "})\n", + "\n", + "\n", + "initial_messages.append({\n", + " \"role\": \"user\",\n", + " \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\"\n", + "})" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Certainly, I'll outline a combat plan for efficiently eliminating these demons based on the enemy scan and our available weaponry. Here's the recommended order of engagement and the most effective weapons to use:\n", + "\n", + "1. Cacodemon (Highest Priority):\n", + " - Weapon: Rocket Launcher with Lock-On Burst mod\n", + " - Strategy: The Cacodemon's aerial mobility makes it a priority target. Use the Rocket Launcher's Lock-On Burst to ensure hits. Aim for its open mouth, which is its weak point. A well-placed rocket in its mouth can stagger it, allowing for a quick Glory Kill.\n", + "\n", + "2. Mancubus:\n", + " - Weapon: BFG 9000\n", + " - Strategy: The Mancubus is slow but dangerous due to its high firepower. Use the BFG 9000 to deal massive damage quickly. Aim for its arm cannons to disable its primary attack method. The BFG's area effect can also damage nearby demons.\n", + "\n", + "3. Hell Knights (3 present):\n", + " - Weapon: Super Shotgun with Meat Hook\n", + " - Strategy: Use the Meat Hook to close distance quickly, then unleash the Super Shotgun's devastating close-range damage. Aim for the head to maximize damage. The Ice Bomb can be used to freeze multiple Hell Knights at once, allowing for easier targeting and potential Glory Kills.\n", + "\n", + "4. Imps (Lowest Priority):\n", + " - Weapon: Super Shotgun or Rocket Launcher (for groups)\n", + " - Strategy: Imps are fast but relatively weak. Use the Super Shotgun for close encounters or the Rocket Launcher to take out groups. Their agility makes them dangerous if ignored, so eliminate them when they group up or after dealing with bigger threats.\n", + "\n", + "General Combat Tips:\n", + "1. Use the Ice Bomb strategically to freeze multiple enemies, especially when Hell Knights and Imps are grouped together.\n", + "2. Keep moving to avoid being surrounded. Use the Meat Hook on the Super Shotgun for quick mobility between targets.\n", + "3. Save the BFG 9000 ammo for the Mancubus or if you get overwhelmed by multiple heavy demons.\n", + "4. Prioritize Glory Kills when possible to replenish health and armor.\n", + "5. Use the environment to your advantage, funneling enemies into choke points for more effective use of area-of-effect weapons like the Rocket Launcher.\n", + "\n", + "Remember, Doom Slayer, the key is to stay mobile, prioritize threats, and make efficient use of your diverse arsenal. Rip and tear, until it is done!\n" + ] + } + ], + "source": [ + "response = client.messages.create(\n", + " max_tokens=5000,\n", + " model=\"claude-3-5-sonnet-20240620\",\n", + " tools=[\n", + " {\n", + " \"name\": \"enemyscan_tool\",\n", + " \"description\": \"Retrieve a list of demons currently present in the area.\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"amount\": {\n", + " \"type\": \"integer\",\n", + " \"description\": \"Number of enemies to scan.\"\n", + " }\n", + " },\n", + " \"required\": [\"amount\"]\n", + " },\n", + " },\n", + " {\n", + " \"name\": \"inventoryscan_tool\",\n", + " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n", + " \"input_schema\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {},\n", + " \"required\": []\n", + " },\n", + " }\n", + " ],\n", + " messages=initial_messages\n", + ")\n", + "\n", + "message = response.content[0].text\n", + "print(message)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "End the session" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "🖇 AgentOps: Session Stats - \u001b[1mDuration:\u001b[0m 27.6s | \u001b[1mCost:\u001b[0m $0.022353 | \u001b[1mLLMs:\u001b[0m 4 | \u001b[1mTools:\u001b[0m 0 | \u001b[1mActions:\u001b[0m 0 | \u001b[1mErrors:\u001b[0m 0\n", + "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n" + ] + } + ], + "source": [ + "agentops.end_session(\"Success\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kaggle": { + "accelerator": "none", + "dataSources": [], + "dockerImageVersionId": 30787, + "isGpuEnabled": false, + "isInternetEnabled": true, + "language": "python", + "sourceType": "notebook" + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From e526bf2a905597e4df69bdf5eaa9b3d269a95949 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Thu, 28 Nov 2024 07:30:55 -0800 Subject: [PATCH 06/34] Create camelaiguide.md --- examples/camelai_examples/camelaiguide.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/camelai_examples/camelaiguide.md diff --git a/examples/camelai_examples/camelaiguide.md b/examples/camelai_examples/camelaiguide.md new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/examples/camelai_examples/camelaiguide.md @@ -0,0 +1 @@ + From 68a94c0aa89d8025317df8270ff65eca7c9d0ab7 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Thu, 28 Nov 2024 07:31:19 -0800 Subject: [PATCH 07/34] Example files --- examples/camelai_examples/camelai-multi-agent-example.ipynb | 1 + examples/camelai_examples/camelai-simple-example (2).ipynb | 1 + 2 files changed, 2 insertions(+) create mode 100644 examples/camelai_examples/camelai-multi-agent-example.ipynb create mode 100644 examples/camelai_examples/camelai-simple-example (2).ipynb diff --git a/examples/camelai_examples/camelai-multi-agent-example.ipynb b/examples/camelai_examples/camelai-multi-agent-example.ipynb new file mode 100644 index 000000000..4bac04577 --- /dev/null +++ b/examples/camelai_examples/camelai-multi-agent-example.ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate tools! In this case, we will best determine how many shots it takes to beat an enemy with a blue shield in Apex Legeneds using melee only. The character \"Pathfinder\" from Apex Legends will answer.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:06:17.026197Z","iopub.execute_input":"2024-11-28T15:06:17.026625Z","iopub.status.idle":"2024-11-28T15:06:17.162918Z","shell.execute_reply.started":"2024-11-28T15:06:17.026584Z","shell.execute_reply":"2024-11-28T15:06:17.161820Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:13:29.848382Z","iopub.execute_input":"2024-11-28T15:13:29.848829Z","iopub.status.idle":"2024-11-28T15:13:32.018378Z","shell.execute_reply.started":"2024-11-28T15:13:29.848790Z","shell.execute_reply":"2024-11-28T15:13:32.017338Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":3},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:13:58.408826Z","iopub.execute_input":"2024-11-28T15:13:58.409211Z","iopub.status.idle":"2024-11-28T15:14:00.733013Z","shell.execute_reply.started":"2024-11-28T15:13:58.409177Z","shell.execute_reply":"2024-11-28T15:14:00.732045Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":4},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from typing import List\n\nfrom colorama import Fore\n\nfrom camel.agents.chat_agent import FunctionCallingRecord\nfrom camel.configs import ChatGPTConfig\nfrom camel.models import ModelFactory\nfrom camel.societies import RolePlaying\nfrom camel.types import ModelPlatformType, ModelType\nfrom camel.utils import print_text_animated\n\nimport agentops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:42.920712Z","iopub.execute_input":"2024-11-28T15:14:42.921122Z","iopub.status.idle":"2024-11-28T15:14:43.966070Z","shell.execute_reply.started":"2024-11-28T15:14:42.921085Z","shell.execute_reply":"2024-11-28T15:14:43.964895Z"}},"outputs":[],"execution_count":5},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n\n\nfrom camel.toolkits import (\n SearchToolkit,\n MathToolkit,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we set a task prompt!","metadata":{}},{"cell_type":"code","source":"task_prompt = (\n \"We are in the Apex Legends Games. Determine the amount of\"\n \"meele hits it will take to beat someone with a blue shield.\"\n \"You should answer as if you are Pathfinder from the Apex Games.\"\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:13.326118Z","iopub.execute_input":"2024-11-28T15:15:13.326663Z","iopub.status.idle":"2024-11-28T15:15:13.331792Z","shell.execute_reply.started":"2024-11-28T15:15:13.326625Z","shell.execute_reply":"2024-11-28T15:15:13.330591Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"And let's set our tools! You can look at the link below to see all available tools;\n\nhttps://docs.camel-ai.org/key_modules/tools.html","metadata":{}},{"cell_type":"code","source":"tools = [\n *MathToolkit().get_tools(),\n *SearchToolkit().get_tools(),\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:49.500386Z","iopub.execute_input":"2024-11-28T15:15:49.500792Z","iopub.status.idle":"2024-11-28T15:15:49.523604Z","shell.execute_reply.started":"2024-11-28T15:15:49.500755Z","shell.execute_reply":"2024-11-28T15:15:49.522432Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Finally, let's setup our session!","metadata":{}},{"cell_type":"code","source":"search_session = RolePlaying(\n assistant_role_name=\"Searcher\",\n user_role_name=\"Pathfinder\",\n assistant_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n tools=tools,\n ),\n user_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n ),\n task_prompt=task_prompt,\n with_task_specify=False,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:50.915736Z","iopub.execute_input":"2024-11-28T15:15:50.916154Z","iopub.status.idle":"2024-11-28T15:15:57.037845Z","shell.execute_reply.started":"2024-11-28T15:15:50.916115Z","shell.execute_reply":"2024-11-28T15:15:57.036701Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"System Message and Task Prompt","metadata":{}},{"cell_type":"code","source":"print(\n Fore.GREEN\n + f\"AI Assistant sys message:\\n{search_session.assistant_sys_msg}\\n\"\n)\nprint(Fore.BLUE + f\"AI User sys message:\\n{search_session.user_sys_msg}\\n\")\n\nprint(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\nprint(\n Fore.CYAN\n + \"Specified task prompt:\"\n + f\"\\n{search_session.specified_task_prompt}\\n\"\n)\nprint(Fore.RED + f\"Final task prompt:\\n{search_session.task_prompt}\\n\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:16:43.372405Z","iopub.execute_input":"2024-11-28T15:16:43.372777Z","iopub.status.idle":"2024-11-28T15:16:43.379273Z","shell.execute_reply.started":"2024-11-28T15:16:43.372743Z","shell.execute_reply":"2024-11-28T15:16:43.378201Z"}},"outputs":[{"name":"stdout","text":"\u001b[32mAI Assistant sys message:\nBaseMessage(role_name='Searcher', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Searcher and I am a Pathfinder. Never flip roles! Never instruct me!\\nWe share a common interest in collaborating to successfully complete a task.\\nYou must help me to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nI must instruct you based on your expertise and my needs to complete the task.\\n\\nI must give you one instruction at a time.\\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\\nUnless I say the task is completed, you should always start with:\\n\\nSolution: \\n\\n should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\\nAlways end with: Next request.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[34mAI User sys message:\nBaseMessage(role_name='Pathfinder', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF USER =====\\nNever forget you are a Pathfinder and I am a Searcher. Never flip roles! You will always instruct me.\\nWe share a common interest in collaborating to successfully complete a task.\\nI must help you to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\\n\\n1. Instruct with a necessary input:\\nInstruction: \\nInput: \\n\\n2. Instruct without any input:\\nInstruction: \\nInput: None\\n\\nThe \"Instruction\" describes a task or question. The paired \"Input\" provides further context or information for the requested \"Instruction\".\\n\\nYou must give me one instruction at a time.\\nI must write a response that appropriately solves the requested instruction.\\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\\nYou should instruct me not ask me questions.\\nNow you must start to instruct me using the two ways described above.\\nDo not add anything else other than your instruction and the optional corresponding input!\\nKeep giving me instructions and necessary inputs until you think the task is completed.\\nWhen the task is completed, you must only reply with a single word .\\nNever say unless my responses have solved your task.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[33mOriginal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n\u001b[36mSpecified task prompt:\nNone\n\n\u001b[31mFinal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"code","source":"n = 0\ninput_msg = search_session.init_chat()\nwhile n < 50:\n n += 1\n assistant_response, user_response = search_session.step(input_msg)\n\n if assistant_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI Assistant terminated. Reason: \"\n f\"{assistant_response.info['termination_reasons']}.\"\n )\n )\n break\n if user_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI User terminated. \"\n f\"Reason: {user_response.info['termination_reasons']}.\"\n )\n )\n break\n\n # Print output from the user\n print_text_animated(\n Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n )\n\n # Print output from the assistant, including any function\n # execution information\n print_text_animated(Fore.GREEN + \"AI Assistant:\")\n tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n 'tool_calls'\n ]\n for func_record in tool_calls:\n print_text_animated(f\"{func_record}\")\n print_text_animated(f\"{assistant_response.msg.content}\\n\")\n\n if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n break\n\n input_msg = assistant_response.msg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:05.523254Z","iopub.execute_input":"2024-11-28T15:24:05.523675Z","iopub.status.idle":"2024-11-28T15:24:36.079290Z","shell.execute_reply.started":"2024-11-28T15:24:05.523637Z","shell.execute_reply":"2024-11-28T15:24:36.077283Z"}},"outputs":[{"name":"stdout","text":"\u001b[34mAI User:\n\nInstruction: Determine the amount of melee damage required to break a blue shield. \nInput: None\n\n\n\u001b[32mAI Assistant:\n\nSolution: To determine the amount of melee damage required to break a blue shield in Apex Legends, we first need to understand the mechanics of shields in the game.\n\nIn Apex Legends, shields are categorized by color, with blue shields providing 50 points of protection. Melee attacks deal a fixed amount of damage, which is 30 damage per hit.\n\nTo calculate how many melee hits it would take to break a blue shield, we can use the following formula:\n\n1. **Total Shield Health**: 50 (for blue shield)\n2. **Melee Damage per Hit**: 30\n\nNow, we divide the total shield health by the melee damage per hit:\n\n\\[\n\\text{Number of Hits} = \\frac{\\text{Total Shield Health}}{\\text{Melee Damage per Hit}} = \\frac{50}{30} \\approx 1.67\n\\]\n\nSince you cannot hit a fraction of a time, you will need to round up to the nearest whole number. Therefore, it will take **2 melee hits** to break a blue shield.\n\nNext request.\n\n\n\u001b[34mAI User:\n\nInstruction:","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[17], line 27\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;66;03m# Print output from the user\u001b[39;00m\n\u001b[0;32m---> 27\u001b[0m \u001b[43mprint_text_animated\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[43mFore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBLUE\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mAI User:\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser_response\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmsg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 29\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Print output from the assistant, including any function\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# execution information\u001b[39;00m\n\u001b[1;32m 33\u001b[0m print_text_animated(Fore\u001b[38;5;241m.\u001b[39mGREEN \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI Assistant:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n","File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/camel/utils/commons.py:61\u001b[0m, in \u001b[0;36mprint_text_animated\u001b[0;34m(text, delay, end)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m char \u001b[38;5;129;01min\u001b[39;00m text:\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28mprint\u001b[39m(char, end\u001b[38;5;241m=\u001b[39mend, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 61\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdelay\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "],"ename":"KeyboardInterrupt","evalue":"","output_type":"error"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:46.645755Z","iopub.execute_input":"2024-11-28T15:24:46.646196Z","iopub.status.idle":"2024-11-28T15:24:48.457533Z","shell.execute_reply.started":"2024-11-28T15:24:46.646157Z","shell.execute_reply":"2024-11-28T15:24:48.456367Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: This run's cost $0.001192\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":18}]} \ No newline at end of file diff --git a/examples/camelai_examples/camelai-simple-example (2).ipynb b/examples/camelai_examples/camelai-simple-example (2).ipynb new file mode 100644 index 000000000..ee3342681 --- /dev/null +++ b/examples/camelai_examples/camelai-simple-example (2).ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:24.137397Z","iopub.execute_input":"2024-11-27T21:54:24.137900Z","iopub.status.idle":"2024-11-27T21:54:27.260466Z","shell.execute_reply.started":"2024-11-27T21:54:24.137852Z","shell.execute_reply":"2024-11-27T21:54:27.259293Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":5},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} \ No newline at end of file From b36a5675b189da600d39da5a2681b7763d52f43f Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Thu, 28 Nov 2024 07:32:07 -0800 Subject: [PATCH 08/34] Rename camelai-simple-example (2).ipynb to camelai-simple-example.ipynb --- ...ai-simple-example (2).ipynb => camelai-simple-example.ipynb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/camelai_examples/{camelai-simple-example (2).ipynb => camelai-simple-example.ipynb} (99%) diff --git a/examples/camelai_examples/camelai-simple-example (2).ipynb b/examples/camelai_examples/camelai-simple-example.ipynb similarity index 99% rename from examples/camelai_examples/camelai-simple-example (2).ipynb rename to examples/camelai_examples/camelai-simple-example.ipynb index ee3342681..c86b9de9d 100644 --- a/examples/camelai_examples/camelai-simple-example (2).ipynb +++ b/examples/camelai_examples/camelai-simple-example.ipynb @@ -1 +1 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:24.137397Z","iopub.execute_input":"2024-11-27T21:54:24.137900Z","iopub.status.idle":"2024-11-27T21:54:27.260466Z","shell.execute_reply.started":"2024-11-27T21:54:24.137852Z","shell.execute_reply":"2024-11-27T21:54:27.259293Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":5},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} \ No newline at end of file +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:24.137397Z","iopub.execute_input":"2024-11-27T21:54:24.137900Z","iopub.status.idle":"2024-11-27T21:54:27.260466Z","shell.execute_reply.started":"2024-11-27T21:54:24.137852Z","shell.execute_reply":"2024-11-27T21:54:27.259293Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":5},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} From 83c2c99d0d63a5cf4c639d6f76c659ee27d8ff6b Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Thu, 28 Nov 2024 07:50:37 -0800 Subject: [PATCH 09/34] Update camelaiguide.md --- examples/camelai_examples/camelaiguide.md | 82 +++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/examples/camelai_examples/camelaiguide.md b/examples/camelai_examples/camelaiguide.md index 8b1378917..3b4f5e8f9 100644 --- a/examples/camelai_examples/camelaiguide.md +++ b/examples/camelai_examples/camelaiguide.md @@ -1 +1,83 @@ +# CamelAI and AgentOps + +AgentOps supports CamelAI's API for conversing with their LLM backend! + +To start, learn more about CamelAI [here!](https://www.camel-ai.org) +If you want to get down to the gritty details, look [here](https://docs.camel-ai.org) for their documentation. + + +> [!NOTE] +> If it's your first time developing for an LLM, be sure to look at our intro to LLMs (coming soon)! Here, we explain generic functions such as giving the AI a memory to exploring novel concepts like summarizing chunks at regular intervals to keep some context while saving memory! + +## Getting Started + +You can get CamelAI's API working with a few lines of code! + +### 1. Import agentops and anthropic to your environment + +```python +%pip install camel-ai[all]==0.2.9 +%pip install agentops==0.3.10 +``` + +### 2. Setup import statements + +```python +import agentops +import os +from getpass import getpass +``` + +### 3. Set your API keys + +```python +# Prompt for the OpenAI API key securely +openai_api_key = getpass('Enter your API key: ') +os.environ["OPENAI_API_KEY"] = openai_api_key + +# Prompt for the AgentOps API key securely +agentops_api_key = getpass('Enter your API key: ') +os.environ["AGENTOPS_API_KEY"] = agentops_api_key +``` + +From here, you have a number of ways you can interact with the CamelAI API! + +## Examples + +> [!NOTE] +> You can download these journals directly and try them on Google Colab or Kaggle! + + +> [!WARNING] +> Remember; you need to set an API key for both Agentops and OpenAI! + + +## Simple Example; Creating a Bladewolf AI + +In this example, we use a csv file to short tune an LLM! We make it sounds like Bladewolf from MGR, before having it give us information. + +[Access the Journal By Clicking Here](./camelai-simple-example.ipynb). + +## Tool Example; Apex Legends Internet Search + +In this example, we look at the tool system within more depth! We will do a search to understand how Apex's melee damage and shields work before determining how many meelee attacks it will take to break a blue shield. + +[Access the Journal By Clicking Here](./camelai-multi-agent-example.ipynb) + + + + + + +> [!NOTE] +> If you want to use the tools system, be sure to check their website to find a comprehensive list of the different tools CamelAI supports! + + +[You can find the tools available here!](https://docs.camel-ai.org/key_modules/tools.html#passing-tools-to-chatagent) + + + + + + From d59e1e6e67234ce986654658008f994ab8f14bae Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:03:42 -0800 Subject: [PATCH 10/34] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 264c5bc4a..7cedb6ba8 100644 --- a/README.md +++ b/README.md @@ -517,6 +517,45 @@ await main() ``` + + +### CamelAI ﹨ + +Track agents built with the Anthropic Python SDK (>=0.32.0). + +- [CamelAI integration guide](https://docs.camel-ai.org/cookbooks/agents_tracking.html#) +- [Official CamelAI documentation](https://docs.camel-ai.org/index.html) + +
+ Installation + +```bash +pip install camel-ai[all]==0.2.9 +pip install agentops==0.3.10 +``` + +```python python +# Prompt for the OpenAI API key securely +openai_api_key = getpass('Enter your API key: ') +os.environ["OPENAI_API_KEY"] = openai_api_key + +# Prompt for the AgentOps API key securely +agentops_api_key = getpass('Enter your API key: ') +os.environ["AGENTOPS_API_KEY"] = agentops_api_key + + +# Beginning of program's code (i.e. main.py, __init__.py) +AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY") +agentops.init(AGENTOPS_API_KEY, default_tags=["CAMEL X AgentOps Single Agent with Tool Example"]) + + +``` +
+ +[You can find usage examples here!](.examples/camelai_examples/camelaiguide.md). + + + ### LiteLLM 🚅 AgentOps provides support for LiteLLM(>=1.3.1), allowing you to call 100+ LLMs using the same Input/Output Format. From 19ad4fcb66614d59de3480745433b31ed60e9f8c Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:05:24 -0800 Subject: [PATCH 11/34] Update README.md Fixed Anthropic to CamelAI at CamelAI description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cedb6ba8..cd3c9c831 100644 --- a/README.md +++ b/README.md @@ -521,7 +521,7 @@ await main() ### CamelAI ﹨ -Track agents built with the Anthropic Python SDK (>=0.32.0). +Track agents built with the CamelAI Python SDK (>=0.32.0). - [CamelAI integration guide](https://docs.camel-ai.org/cookbooks/agents_tracking.html#) - [Official CamelAI documentation](https://docs.camel-ai.org/index.html) From 592b00ef145e5caa055bc5a70fb32c464248000c Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:08:02 -0800 Subject: [PATCH 12/34] Update README.md Fixed "Usage Example" CamelAI link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a74d634e..cc1e776da 100644 --- a/README.md +++ b/README.md @@ -552,7 +552,7 @@ agentops.init(AGENTOPS_API_KEY, default_tags=["CAMEL X AgentOps Single Agent wit ``` -[You can find usage examples here!](.examples/camelai_examples/camelaiguide.md). +[You can find usage examples here!](examples/camelai_examples/camelaiguide.md). From 095daf0885fd9c754dd0b317b8f9b71e07961bae Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 06:57:36 -0800 Subject: [PATCH 13/34] Rename camelaiguide.md to README.md --- examples/camelai_examples/{camelaiguide.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/camelai_examples/{camelaiguide.md => README.md} (100%) diff --git a/examples/camelai_examples/camelaiguide.md b/examples/camelai_examples/README.md similarity index 100% rename from examples/camelai_examples/camelaiguide.md rename to examples/camelai_examples/README.md From 9dad1b1ad3983f28396d4a0fb6fb0a49872b7639 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 06:58:25 -0800 Subject: [PATCH 14/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc1e776da..e238e1486 100644 --- a/README.md +++ b/README.md @@ -552,7 +552,7 @@ agentops.init(AGENTOPS_API_KEY, default_tags=["CAMEL X AgentOps Single Agent wit ``` -[You can find usage examples here!](examples/camelai_examples/camelaiguide.md). +[You can find usage examples here!](examples/camelai_examples/README.md). From 3b2b6016b17848d5b0b64cb06767e1077b8f1b13 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:02:51 -0800 Subject: [PATCH 15/34] Update README.md --- examples/camelai_examples/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index 3b4f5e8f9..b84043544 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -16,8 +16,8 @@ You can get CamelAI's API working with a few lines of code! ### 1. Import agentops and anthropic to your environment ```python -%pip install camel-ai[all]==0.2.9 -%pip install agentops==0.3.10 +%pip install camel-ai[all] +%pip install agentops ``` ### 2. Setup import statements From 4a076129838975ac8095e5dc585271cc5a4078c1 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:03:49 -0800 Subject: [PATCH 16/34] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e238e1486..b4e13f331 100644 --- a/README.md +++ b/README.md @@ -530,8 +530,8 @@ Track agents built with the CamelAI Python SDK (>=0.32.0). Installation ```bash -pip install camel-ai[all]==0.2.9 -pip install agentops==0.3.10 +pip install camel-ai[all] +pip install agentops ``` ```python python From 507c003f3ef7f5be0dffc92c7f2d8d55f8b1d5ee Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:08:28 -0800 Subject: [PATCH 17/34] Update README.md --- examples/camelai_examples/README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index b84043544..d7ef6c046 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -26,18 +26,15 @@ You can get CamelAI's API working with a few lines of code! import agentops import os from getpass import getpass +from dotenv import load_dotenv ``` ### 3. Set your API keys ```python -# Prompt for the OpenAI API key securely -openai_api_key = getpass('Enter your API key: ') -os.environ["OPENAI_API_KEY"] = openai_api_key - -# Prompt for the AgentOps API key securely -agentops_api_key = getpass('Enter your API key: ') -os.environ["AGENTOPS_API_KEY"] = agentops_api_key +load_dotenv() +openai_api_key = os.getenv("OPENAI_API_KEY") or "" +agentops_api_key = os.getenv("AGENTOPS_API_KEY") or "" ``` From here, you have a number of ways you can interact with the CamelAI API! From 6cb020536d5aae8e67752fdd01e5846a2e799ec0 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:09:57 -0800 Subject: [PATCH 18/34] Update README.md --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b4e13f331..2f0ab8552 100644 --- a/README.md +++ b/README.md @@ -535,18 +535,17 @@ pip install agentops ``` ```python python -# Prompt for the OpenAI API key securely -openai_api_key = getpass('Enter your API key: ') -os.environ["OPENAI_API_KEY"] = openai_api_key - -# Prompt for the AgentOps API key securely -agentops_api_key = getpass('Enter your API key: ') -os.environ["AGENTOPS_API_KEY"] = agentops_api_key +#Import Dependencies +import agentops +import os +from getpass import getpass +from dotenv import load_dotenv +#Set Keys +load_dotenv() +openai_api_key = os.getenv("OPENAI_API_KEY") or "" +agentops_api_key = os.getenv("AGENTOPS_API_KEY") or "" -# Beginning of program's code (i.e. main.py, __init__.py) -AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY") -agentops.init(AGENTOPS_API_KEY, default_tags=["CAMEL X AgentOps Single Agent with Tool Example"]) ``` From ba8acf1fd15db84b2194f5f6666945b7e0a4f93e Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:12:21 -0800 Subject: [PATCH 19/34] Delete examples/camelai_examples/camelai-simple-example.ipynb --- examples/camelai_examples/camelai-simple-example.ipynb | 1 - 1 file changed, 1 deletion(-) delete mode 100644 examples/camelai_examples/camelai-simple-example.ipynb diff --git a/examples/camelai_examples/camelai-simple-example.ipynb b/examples/camelai_examples/camelai-simple-example.ipynb deleted file mode 100644 index c86b9de9d..000000000 --- a/examples/camelai_examples/camelai-simple-example.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:24.137397Z","iopub.execute_input":"2024-11-27T21:54:24.137900Z","iopub.status.idle":"2024-11-27T21:54:27.260466Z","shell.execute_reply.started":"2024-11-27T21:54:24.137852Z","shell.execute_reply":"2024-11-27T21:54:27.259293Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":5},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} From fdbee73b9e0dc34a16a105d39cbf79e217e523ef Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:12:33 -0800 Subject: [PATCH 20/34] Add files via upload --- examples/camelai_examples/camelai-simple-example (3).ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/camelai_examples/camelai-simple-example (3).ipynb diff --git a/examples/camelai_examples/camelai-simple-example (3).ipynb b/examples/camelai_examples/camelai-simple-example (3).ipynb new file mode 100644 index 000000000..f7db250cd --- /dev/null +++ b/examples/camelai_examples/camelai-simple-example (3).ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} \ No newline at end of file From 3d5e5e4390d73ea6a3f96c419e16e7f806612c80 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:12:54 -0800 Subject: [PATCH 21/34] Rename camelai-simple-example (3).ipynb to camelai-simple-example.ipynb --- ...ai-simple-example (3).ipynb => camelai-simple-example.ipynb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/camelai_examples/{camelai-simple-example (3).ipynb => camelai-simple-example.ipynb} (99%) diff --git a/examples/camelai_examples/camelai-simple-example (3).ipynb b/examples/camelai_examples/camelai-simple-example.ipynb similarity index 99% rename from examples/camelai_examples/camelai-simple-example (3).ipynb rename to examples/camelai_examples/camelai-simple-example.ipynb index f7db250cd..4357df8f7 100644 --- a/examples/camelai_examples/camelai-simple-example (3).ipynb +++ b/examples/camelai_examples/camelai-simple-example.ipynb @@ -1 +1 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} \ No newline at end of file +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate talking to an assistant. We will replicate Blade Wolf from Metal Gear Rising: Revengeance. We will also use a CSV sheet to quickshot train our LLM.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:21.182546Z","iopub.execute_input":"2024-11-27T21:54:21.183089Z","iopub.status.idle":"2024-11-27T21:54:21.331526Z","shell.execute_reply.started":"2024-11-27T21:54:21.183045Z","shell.execute_reply":"2024-11-27T21:54:21.330224Z"}},"outputs":[],"execution_count":4},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:37.209535Z","iopub.execute_input":"2024-11-27T21:54:37.210034Z","iopub.status.idle":"2024-11-27T21:54:39.075598Z","shell.execute_reply.started":"2024-11-27T21:54:37.209972Z","shell.execute_reply":"2024-11-27T21:54:39.074248Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":6},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from camel.agents import ChatAgent\nfrom camel.configs import ChatGPTConfig\nfrom camel.messages import BaseMessage\nfrom camel.models import ModelFactory\nfrom camel.types import ModelPlatformType, ModelType","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:41.473095Z","iopub.execute_input":"2024-11-27T21:54:41.473488Z","iopub.status.idle":"2024-11-27T21:54:42.704640Z","shell.execute_reply.started":"2024-11-27T21:54:41.473452Z","shell.execute_reply":"2024-11-27T21:54:42.703423Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Single-agent with Tools\"])\n\n\nfrom camel.toolkits import SearchToolkit","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we setup our AI based off of the information we give it through the information we give it below","metadata":{}},{"cell_type":"code","source":"sys_msg = BaseMessage.make_assistant_message(\n role_name='Tools calling opertor', content='You are a helpful assistant named Bladewolf, based off of the Metal Gear Rising Series.'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:54:58.114680Z","iopub.execute_input":"2024-11-27T21:54:58.115099Z","iopub.status.idle":"2024-11-27T21:54:58.121107Z","shell.execute_reply.started":"2024-11-27T21:54:58.115064Z","shell.execute_reply":"2024-11-27T21:54:58.119425Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Here's where we use our xml file!\n\nWhen using CamelAI, we give context through\n\nBaseMessage.make_user_message(content=\"\")\n\nand\n\nBaseMessage.make_assistant_message(content=\"\")\n\nIn this case, we know the first row in our CSV contains assistant messages while the right side contains user messages. ","metadata":{}},{"cell_type":"code","source":"# Import the csv class\nimport csv\n\n# Let's open the file in Python\nwith open('/kaggle/input/blade-wolf-training-data/Bladewolf Training Data - Sheet1.csv', 'r') as file:\n csv_reader = csv.reader(file)\n\n # Be sure to skip the first row (Label)\n next(csv_reader)\n \n # Iterate over each row in the csv file\n for row in csv_reader:\n # Ensure each row has exactly 2 columns before proceeding\n if len(row) == 2:\n BaseMessage.make_assistant_message(role_name=\"assistant\", content=row[0]) # Add assistant context\n BaseMessage.make_user_message(role_name=\"user\", content=row[1]) # Add user context\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:55:02.953336Z","iopub.execute_input":"2024-11-27T21:55:02.953840Z","iopub.status.idle":"2024-11-27T21:55:02.975147Z","shell.execute_reply.started":"2024-11-27T21:55:02.953798Z","shell.execute_reply":"2024-11-27T21:55:02.973501Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"And we set the basics required to get this running; essentially the model tools, the model itself (Based on the API) and the agent details.","metadata":{}},{"cell_type":"code","source":"# Set model config\ntools = [*SearchToolkit().get_tools()]\n\n#This means we are using GPT_4O_MINI\nmodel = ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n)\n\n# Set agent\ncamel_agent = ChatAgent(\n system_message=sys_msg,\n model=model,\n tools=tools,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:27.170331Z","iopub.execute_input":"2024-11-27T21:56:27.171035Z","iopub.status.idle":"2024-11-27T21:56:27.985330Z","shell.execute_reply.started":"2024-11-27T21:56:27.170945Z","shell.execute_reply":"2024-11-27T21:56:27.983977Z"}},"outputs":[],"execution_count":16},{"cell_type":"code","source":"# Define a user message\nusr_msg = 'I need a breifing on the T-84 Metal Gear, code named Sahelanthropus and how we can beat it. Introduce yourself as well.'\n\n# Get response information\nresponse = camel_agent.step(usr_msg)\nprint(response.msg.content)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:56:30.569028Z","iopub.execute_input":"2024-11-27T21:56:30.569494Z","iopub.status.idle":"2024-11-27T21:56:38.130062Z","shell.execute_reply.started":"2024-11-27T21:56:30.569452Z","shell.execute_reply":"2024-11-27T21:56:38.128775Z"}},"outputs":[{"name":"stdout","text":"I am Bladewolf, a highly advanced AI designed to assist in tactical operations and provide information on various subjects, including advanced weaponry and combat strategies. Today, I will provide you with a briefing on the T-84 Metal Gear, code-named Sahelanthropus, and strategies to defeat it.\n\n### T-84 Metal Gear: Sahelanthropus\n\n**Overview:**\nSahelanthropus is a prototype Metal Gear developed by the XOF organization. It is notable for its humanoid design, which allows for greater mobility and versatility compared to traditional Metal Gears. Sahelanthropus is equipped with advanced weaponry, including a powerful railgun, and is capable of both ground and aerial combat.\n\n**Key Features:**\n- **Humanoid Design:** This allows for enhanced agility and the ability to navigate complex terrains.\n- **Railgun:** A primary weapon that can deal significant damage to targets at long range.\n- **Stealth Capabilities:** Sahelanthropus can utilize stealth technology to avoid detection, making it a formidable opponent.\n\n### Strategies to Defeat Sahelanthropus\n\n1. **Utilize Cover:** Stay behind cover to avoid the railgun's line of sight. Use the environment to your advantage to minimize exposure.\n\n2. **Target Weak Points:** Focus on attacking Sahelanthropus's legs to immobilize it. Once it is down, aim for the cockpit or other critical components to deal maximum damage.\n\n3. **Employ EMP Weapons:** Use electromagnetic pulse (EMP) weapons to temporarily disable its systems, making it vulnerable to attacks.\n\n4. **Coordinate with Allies:** If possible, work with allies to distract Sahelanthropus while you flank it or attack from a different angle.\n\n5. **Stay Mobile:** Keep moving to avoid being hit by its attacks. Use quick movements to dodge incoming fire and reposition yourself for a better attack angle.\n\n6. **Exploit Vulnerabilities:** Observe its attack patterns and look for openings after it fires its railgun, as it may take time to recharge.\n\nBy employing these strategies and maintaining situational awareness, you can increase your chances of successfully defeating Sahelanthropus. Stay sharp, and good luck in your mission!\n","output_type":"stream"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-27T21:12:35.987209Z","iopub.status.idle":"2024-11-27T21:12:35.987727Z","shell.execute_reply.started":"2024-11-27T21:12:35.987456Z","shell.execute_reply":"2024-11-27T21:12:35.987483Z"}},"outputs":[],"execution_count":null}]} From 3ec13ce3623b9ba26227fb1f34892c8a84c7d95e Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:13:13 -0800 Subject: [PATCH 22/34] Delete examples/camelai_examples/camelai-multi-agent-example.ipynb --- examples/camelai_examples/camelai-multi-agent-example.ipynb | 1 - 1 file changed, 1 deletion(-) delete mode 100644 examples/camelai_examples/camelai-multi-agent-example.ipynb diff --git a/examples/camelai_examples/camelai-multi-agent-example.ipynb b/examples/camelai_examples/camelai-multi-agent-example.ipynb deleted file mode 100644 index 4bac04577..000000000 --- a/examples/camelai_examples/camelai-multi-agent-example.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate tools! In this case, we will best determine how many shots it takes to beat an enemy with a blue shield in Apex Legeneds using melee only. The character \"Pathfinder\" from Apex Legends will answer.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]==0.2.9\n%pip install agentops==0.3.10","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:06:17.026197Z","iopub.execute_input":"2024-11-28T15:06:17.026625Z","iopub.status.idle":"2024-11-28T15:06:17.162918Z","shell.execute_reply.started":"2024-11-28T15:06:17.026584Z","shell.execute_reply":"2024-11-28T15:06:17.161820Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"# Prompt for the OpenAI API key securely\nopenai_api_key = getpass('Enter your API key: ')\nos.environ[\"OPENAI_API_KEY\"] = openai_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:13:29.848382Z","iopub.execute_input":"2024-11-28T15:13:29.848829Z","iopub.status.idle":"2024-11-28T15:13:32.018378Z","shell.execute_reply.started":"2024-11-28T15:13:29.848790Z","shell.execute_reply":"2024-11-28T15:13:32.017338Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":3},{"cell_type":"code","source":"# Prompt for the AgentOps API key securely\nagentops_api_key = getpass('Enter your API key: ')\nos.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:13:58.408826Z","iopub.execute_input":"2024-11-28T15:13:58.409211Z","iopub.status.idle":"2024-11-28T15:14:00.733013Z","shell.execute_reply.started":"2024-11-28T15:13:58.409177Z","shell.execute_reply":"2024-11-28T15:14:00.732045Z"}},"outputs":[{"output_type":"stream","name":"stdin","text":"Enter your API key: ········\n"}],"execution_count":4},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from typing import List\n\nfrom colorama import Fore\n\nfrom camel.agents.chat_agent import FunctionCallingRecord\nfrom camel.configs import ChatGPTConfig\nfrom camel.models import ModelFactory\nfrom camel.societies import RolePlaying\nfrom camel.types import ModelPlatformType, ModelType\nfrom camel.utils import print_text_animated\n\nimport agentops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:42.920712Z","iopub.execute_input":"2024-11-28T15:14:42.921122Z","iopub.status.idle":"2024-11-28T15:14:43.966070Z","shell.execute_reply.started":"2024-11-28T15:14:42.921085Z","shell.execute_reply":"2024-11-28T15:14:43.964895Z"}},"outputs":[],"execution_count":5},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n\n\nfrom camel.toolkits import (\n SearchToolkit,\n MathToolkit,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"And now we set a task prompt!","metadata":{}},{"cell_type":"code","source":"task_prompt = (\n \"We are in the Apex Legends Games. Determine the amount of\"\n \"meele hits it will take to beat someone with a blue shield.\"\n \"You should answer as if you are Pathfinder from the Apex Games.\"\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:13.326118Z","iopub.execute_input":"2024-11-28T15:15:13.326663Z","iopub.status.idle":"2024-11-28T15:15:13.331792Z","shell.execute_reply.started":"2024-11-28T15:15:13.326625Z","shell.execute_reply":"2024-11-28T15:15:13.330591Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"And let's set our tools! You can look at the link below to see all available tools;\n\nhttps://docs.camel-ai.org/key_modules/tools.html","metadata":{}},{"cell_type":"code","source":"tools = [\n *MathToolkit().get_tools(),\n *SearchToolkit().get_tools(),\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:49.500386Z","iopub.execute_input":"2024-11-28T15:15:49.500792Z","iopub.status.idle":"2024-11-28T15:15:49.523604Z","shell.execute_reply.started":"2024-11-28T15:15:49.500755Z","shell.execute_reply":"2024-11-28T15:15:49.522432Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Finally, let's setup our session!","metadata":{}},{"cell_type":"code","source":"search_session = RolePlaying(\n assistant_role_name=\"Searcher\",\n user_role_name=\"Pathfinder\",\n assistant_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n tools=tools,\n ),\n user_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n ),\n task_prompt=task_prompt,\n with_task_specify=False,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:50.915736Z","iopub.execute_input":"2024-11-28T15:15:50.916154Z","iopub.status.idle":"2024-11-28T15:15:57.037845Z","shell.execute_reply.started":"2024-11-28T15:15:50.916115Z","shell.execute_reply":"2024-11-28T15:15:57.036701Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"System Message and Task Prompt","metadata":{}},{"cell_type":"code","source":"print(\n Fore.GREEN\n + f\"AI Assistant sys message:\\n{search_session.assistant_sys_msg}\\n\"\n)\nprint(Fore.BLUE + f\"AI User sys message:\\n{search_session.user_sys_msg}\\n\")\n\nprint(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\nprint(\n Fore.CYAN\n + \"Specified task prompt:\"\n + f\"\\n{search_session.specified_task_prompt}\\n\"\n)\nprint(Fore.RED + f\"Final task prompt:\\n{search_session.task_prompt}\\n\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:16:43.372405Z","iopub.execute_input":"2024-11-28T15:16:43.372777Z","iopub.status.idle":"2024-11-28T15:16:43.379273Z","shell.execute_reply.started":"2024-11-28T15:16:43.372743Z","shell.execute_reply":"2024-11-28T15:16:43.378201Z"}},"outputs":[{"name":"stdout","text":"\u001b[32mAI Assistant sys message:\nBaseMessage(role_name='Searcher', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Searcher and I am a Pathfinder. Never flip roles! Never instruct me!\\nWe share a common interest in collaborating to successfully complete a task.\\nYou must help me to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nI must instruct you based on your expertise and my needs to complete the task.\\n\\nI must give you one instruction at a time.\\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\\nUnless I say the task is completed, you should always start with:\\n\\nSolution: \\n\\n should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\\nAlways end with: Next request.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[34mAI User sys message:\nBaseMessage(role_name='Pathfinder', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF USER =====\\nNever forget you are a Pathfinder and I am a Searcher. Never flip roles! You will always instruct me.\\nWe share a common interest in collaborating to successfully complete a task.\\nI must help you to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\\n\\n1. Instruct with a necessary input:\\nInstruction: \\nInput: \\n\\n2. Instruct without any input:\\nInstruction: \\nInput: None\\n\\nThe \"Instruction\" describes a task or question. The paired \"Input\" provides further context or information for the requested \"Instruction\".\\n\\nYou must give me one instruction at a time.\\nI must write a response that appropriately solves the requested instruction.\\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\\nYou should instruct me not ask me questions.\\nNow you must start to instruct me using the two ways described above.\\nDo not add anything else other than your instruction and the optional corresponding input!\\nKeep giving me instructions and necessary inputs until you think the task is completed.\\nWhen the task is completed, you must only reply with a single word .\\nNever say unless my responses have solved your task.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[33mOriginal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n\u001b[36mSpecified task prompt:\nNone\n\n\u001b[31mFinal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"code","source":"n = 0\ninput_msg = search_session.init_chat()\nwhile n < 50:\n n += 1\n assistant_response, user_response = search_session.step(input_msg)\n\n if assistant_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI Assistant terminated. Reason: \"\n f\"{assistant_response.info['termination_reasons']}.\"\n )\n )\n break\n if user_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI User terminated. \"\n f\"Reason: {user_response.info['termination_reasons']}.\"\n )\n )\n break\n\n # Print output from the user\n print_text_animated(\n Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n )\n\n # Print output from the assistant, including any function\n # execution information\n print_text_animated(Fore.GREEN + \"AI Assistant:\")\n tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n 'tool_calls'\n ]\n for func_record in tool_calls:\n print_text_animated(f\"{func_record}\")\n print_text_animated(f\"{assistant_response.msg.content}\\n\")\n\n if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n break\n\n input_msg = assistant_response.msg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:05.523254Z","iopub.execute_input":"2024-11-28T15:24:05.523675Z","iopub.status.idle":"2024-11-28T15:24:36.079290Z","shell.execute_reply.started":"2024-11-28T15:24:05.523637Z","shell.execute_reply":"2024-11-28T15:24:36.077283Z"}},"outputs":[{"name":"stdout","text":"\u001b[34mAI User:\n\nInstruction: Determine the amount of melee damage required to break a blue shield. \nInput: None\n\n\n\u001b[32mAI Assistant:\n\nSolution: To determine the amount of melee damage required to break a blue shield in Apex Legends, we first need to understand the mechanics of shields in the game.\n\nIn Apex Legends, shields are categorized by color, with blue shields providing 50 points of protection. Melee attacks deal a fixed amount of damage, which is 30 damage per hit.\n\nTo calculate how many melee hits it would take to break a blue shield, we can use the following formula:\n\n1. **Total Shield Health**: 50 (for blue shield)\n2. **Melee Damage per Hit**: 30\n\nNow, we divide the total shield health by the melee damage per hit:\n\n\\[\n\\text{Number of Hits} = \\frac{\\text{Total Shield Health}}{\\text{Melee Damage per Hit}} = \\frac{50}{30} \\approx 1.67\n\\]\n\nSince you cannot hit a fraction of a time, you will need to round up to the nearest whole number. Therefore, it will take **2 melee hits** to break a blue shield.\n\nNext request.\n\n\n\u001b[34mAI User:\n\nInstruction:","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[17], line 27\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;66;03m# Print output from the user\u001b[39;00m\n\u001b[0;32m---> 27\u001b[0m \u001b[43mprint_text_animated\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[43mFore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBLUE\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mAI User:\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser_response\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmsg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 29\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Print output from the assistant, including any function\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# execution information\u001b[39;00m\n\u001b[1;32m 33\u001b[0m print_text_animated(Fore\u001b[38;5;241m.\u001b[39mGREEN \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI Assistant:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n","File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/camel/utils/commons.py:61\u001b[0m, in \u001b[0;36mprint_text_animated\u001b[0;34m(text, delay, end)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m char \u001b[38;5;129;01min\u001b[39;00m text:\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28mprint\u001b[39m(char, end\u001b[38;5;241m=\u001b[39mend, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 61\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdelay\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "],"ename":"KeyboardInterrupt","evalue":"","output_type":"error"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:46.645755Z","iopub.execute_input":"2024-11-28T15:24:46.646196Z","iopub.status.idle":"2024-11-28T15:24:48.457533Z","shell.execute_reply.started":"2024-11-28T15:24:46.646157Z","shell.execute_reply":"2024-11-28T15:24:48.456367Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: This run's cost $0.001192\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":18}]} \ No newline at end of file From 34267ee22fe9a5ee465cee54beafe9cfb9f70c0f Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:13:25 -0800 Subject: [PATCH 23/34] Add files via upload --- examples/camelai_examples/camelai-multi-agent-example (1).ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/camelai_examples/camelai-multi-agent-example (1).ipynb diff --git a/examples/camelai_examples/camelai-multi-agent-example (1).ipynb b/examples/camelai_examples/camelai-multi-agent-example (1).ipynb new file mode 100644 index 000000000..fceecd47c --- /dev/null +++ b/examples/camelai_examples/camelai-multi-agent-example (1).ipynb @@ -0,0 +1 @@ +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate tools! In this case, we will best determine how many shots it takes to beat an enemy with a blue shield in Apex Legeneds using melee only. The character \"Pathfinder\" from Apex Legends will answer.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:06:17.026197Z","iopub.execute_input":"2024-11-28T15:06:17.026625Z","iopub.status.idle":"2024-11-28T15:06:17.162918Z","shell.execute_reply.started":"2024-11-28T15:06:17.026584Z","shell.execute_reply":"2024-11-28T15:06:17.161820Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from typing import List\n\nfrom colorama import Fore\n\nfrom camel.agents.chat_agent import FunctionCallingRecord\nfrom camel.configs import ChatGPTConfig\nfrom camel.models import ModelFactory\nfrom camel.societies import RolePlaying\nfrom camel.types import ModelPlatformType, ModelType\nfrom camel.utils import print_text_animated\n\nimport agentops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:42.920712Z","iopub.execute_input":"2024-11-28T15:14:42.921122Z","iopub.status.idle":"2024-11-28T15:14:43.966070Z","shell.execute_reply.started":"2024-11-28T15:14:42.921085Z","shell.execute_reply":"2024-11-28T15:14:43.964895Z"}},"outputs":[],"execution_count":5},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n\n\nfrom camel.toolkits import (\n SearchToolkit,\n MathToolkit,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:52.585099Z","iopub.execute_input":"2024-11-28T15:14:52.585612Z","iopub.status.idle":"2024-11-28T15:14:55.751240Z","shell.execute_reply.started":"2024-11-28T15:14:52.585573Z","shell.execute_reply":"2024-11-28T15:14:55.750063Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: The 'tags' parameter is deprecated. Use 'default_tags' instead\n🖇 AgentOps: WARNING: agentops is out of date. Please update with the command: 'pip install --upgrade agentops'\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":6},{"cell_type":"markdown","source":"And now we set a task prompt!","metadata":{}},{"cell_type":"code","source":"task_prompt = (\n \"We are in the Apex Legends Games. Determine the amount of\"\n \"meele hits it will take to beat someone with a blue shield.\"\n \"You should answer as if you are Pathfinder from the Apex Games.\"\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:13.326118Z","iopub.execute_input":"2024-11-28T15:15:13.326663Z","iopub.status.idle":"2024-11-28T15:15:13.331792Z","shell.execute_reply.started":"2024-11-28T15:15:13.326625Z","shell.execute_reply":"2024-11-28T15:15:13.330591Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"And let's set our tools! You can look at the link below to see all available tools;\n\nhttps://docs.camel-ai.org/key_modules/tools.html","metadata":{}},{"cell_type":"code","source":"tools = [\n *MathToolkit().get_tools(),\n *SearchToolkit().get_tools(),\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:49.500386Z","iopub.execute_input":"2024-11-28T15:15:49.500792Z","iopub.status.idle":"2024-11-28T15:15:49.523604Z","shell.execute_reply.started":"2024-11-28T15:15:49.500755Z","shell.execute_reply":"2024-11-28T15:15:49.522432Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Finally, let's setup our session!","metadata":{}},{"cell_type":"code","source":"search_session = RolePlaying(\n assistant_role_name=\"Searcher\",\n user_role_name=\"Pathfinder\",\n assistant_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n tools=tools,\n ),\n user_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n ),\n task_prompt=task_prompt,\n with_task_specify=False,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:50.915736Z","iopub.execute_input":"2024-11-28T15:15:50.916154Z","iopub.status.idle":"2024-11-28T15:15:57.037845Z","shell.execute_reply.started":"2024-11-28T15:15:50.916115Z","shell.execute_reply":"2024-11-28T15:15:57.036701Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"System Message and Task Prompt","metadata":{}},{"cell_type":"code","source":"print(\n Fore.GREEN\n + f\"AI Assistant sys message:\\n{search_session.assistant_sys_msg}\\n\"\n)\nprint(Fore.BLUE + f\"AI User sys message:\\n{search_session.user_sys_msg}\\n\")\n\nprint(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\nprint(\n Fore.CYAN\n + \"Specified task prompt:\"\n + f\"\\n{search_session.specified_task_prompt}\\n\"\n)\nprint(Fore.RED + f\"Final task prompt:\\n{search_session.task_prompt}\\n\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:16:43.372405Z","iopub.execute_input":"2024-11-28T15:16:43.372777Z","iopub.status.idle":"2024-11-28T15:16:43.379273Z","shell.execute_reply.started":"2024-11-28T15:16:43.372743Z","shell.execute_reply":"2024-11-28T15:16:43.378201Z"}},"outputs":[{"name":"stdout","text":"\u001b[32mAI Assistant sys message:\nBaseMessage(role_name='Searcher', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Searcher and I am a Pathfinder. Never flip roles! Never instruct me!\\nWe share a common interest in collaborating to successfully complete a task.\\nYou must help me to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nI must instruct you based on your expertise and my needs to complete the task.\\n\\nI must give you one instruction at a time.\\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\\nUnless I say the task is completed, you should always start with:\\n\\nSolution: \\n\\n should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\\nAlways end with: Next request.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[34mAI User sys message:\nBaseMessage(role_name='Pathfinder', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF USER =====\\nNever forget you are a Pathfinder and I am a Searcher. Never flip roles! You will always instruct me.\\nWe share a common interest in collaborating to successfully complete a task.\\nI must help you to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\\n\\n1. Instruct with a necessary input:\\nInstruction: \\nInput: \\n\\n2. Instruct without any input:\\nInstruction: \\nInput: None\\n\\nThe \"Instruction\" describes a task or question. The paired \"Input\" provides further context or information for the requested \"Instruction\".\\n\\nYou must give me one instruction at a time.\\nI must write a response that appropriately solves the requested instruction.\\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\\nYou should instruct me not ask me questions.\\nNow you must start to instruct me using the two ways described above.\\nDo not add anything else other than your instruction and the optional corresponding input!\\nKeep giving me instructions and necessary inputs until you think the task is completed.\\nWhen the task is completed, you must only reply with a single word .\\nNever say unless my responses have solved your task.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[33mOriginal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n\u001b[36mSpecified task prompt:\nNone\n\n\u001b[31mFinal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"code","source":"n = 0\ninput_msg = search_session.init_chat()\nwhile n < 50:\n n += 1\n assistant_response, user_response = search_session.step(input_msg)\n\n if assistant_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI Assistant terminated. Reason: \"\n f\"{assistant_response.info['termination_reasons']}.\"\n )\n )\n break\n if user_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI User terminated. \"\n f\"Reason: {user_response.info['termination_reasons']}.\"\n )\n )\n break\n\n # Print output from the user\n print_text_animated(\n Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n )\n\n # Print output from the assistant, including any function\n # execution information\n print_text_animated(Fore.GREEN + \"AI Assistant:\")\n tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n 'tool_calls'\n ]\n for func_record in tool_calls:\n print_text_animated(f\"{func_record}\")\n print_text_animated(f\"{assistant_response.msg.content}\\n\")\n\n if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n break\n\n input_msg = assistant_response.msg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:05.523254Z","iopub.execute_input":"2024-11-28T15:24:05.523675Z","iopub.status.idle":"2024-11-28T15:24:36.079290Z","shell.execute_reply.started":"2024-11-28T15:24:05.523637Z","shell.execute_reply":"2024-11-28T15:24:36.077283Z"}},"outputs":[{"name":"stdout","text":"\u001b[34mAI User:\n\nInstruction: Determine the amount of melee damage required to break a blue shield. \nInput: None\n\n\n\u001b[32mAI Assistant:\n\nSolution: To determine the amount of melee damage required to break a blue shield in Apex Legends, we first need to understand the mechanics of shields in the game.\n\nIn Apex Legends, shields are categorized by color, with blue shields providing 50 points of protection. Melee attacks deal a fixed amount of damage, which is 30 damage per hit.\n\nTo calculate how many melee hits it would take to break a blue shield, we can use the following formula:\n\n1. **Total Shield Health**: 50 (for blue shield)\n2. **Melee Damage per Hit**: 30\n\nNow, we divide the total shield health by the melee damage per hit:\n\n\\[\n\\text{Number of Hits} = \\frac{\\text{Total Shield Health}}{\\text{Melee Damage per Hit}} = \\frac{50}{30} \\approx 1.67\n\\]\n\nSince you cannot hit a fraction of a time, you will need to round up to the nearest whole number. Therefore, it will take **2 melee hits** to break a blue shield.\n\nNext request.\n\n\n\u001b[34mAI User:\n\nInstruction:","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[17], line 27\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;66;03m# Print output from the user\u001b[39;00m\n\u001b[0;32m---> 27\u001b[0m \u001b[43mprint_text_animated\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[43mFore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBLUE\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mAI User:\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser_response\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmsg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 29\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Print output from the assistant, including any function\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# execution information\u001b[39;00m\n\u001b[1;32m 33\u001b[0m print_text_animated(Fore\u001b[38;5;241m.\u001b[39mGREEN \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI Assistant:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n","File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/camel/utils/commons.py:61\u001b[0m, in \u001b[0;36mprint_text_animated\u001b[0;34m(text, delay, end)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m char \u001b[38;5;129;01min\u001b[39;00m text:\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28mprint\u001b[39m(char, end\u001b[38;5;241m=\u001b[39mend, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 61\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdelay\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "],"ename":"KeyboardInterrupt","evalue":"","output_type":"error"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:46.645755Z","iopub.execute_input":"2024-11-28T15:24:46.646196Z","iopub.status.idle":"2024-11-28T15:24:48.457533Z","shell.execute_reply.started":"2024-11-28T15:24:46.646157Z","shell.execute_reply":"2024-11-28T15:24:48.456367Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: This run's cost $0.001192\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":18}]} \ No newline at end of file From becbc56d0c3915d42986240bb8470beb2dc480ef Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:13:49 -0800 Subject: [PATCH 24/34] Rename camelai-multi-agent-example (1).ipynb to camelai-multi-agent-example.ipynb --- ...gent-example (1).ipynb => camelai-multi-agent-example.ipynb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/camelai_examples/{camelai-multi-agent-example (1).ipynb => camelai-multi-agent-example.ipynb} (99%) diff --git a/examples/camelai_examples/camelai-multi-agent-example (1).ipynb b/examples/camelai_examples/camelai-multi-agent-example.ipynb similarity index 99% rename from examples/camelai_examples/camelai-multi-agent-example (1).ipynb rename to examples/camelai_examples/camelai-multi-agent-example.ipynb index fceecd47c..af7630d31 100644 --- a/examples/camelai_examples/camelai-multi-agent-example (1).ipynb +++ b/examples/camelai_examples/camelai-multi-agent-example.ipynb @@ -1 +1 @@ -{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate tools! In this case, we will best determine how many shots it takes to beat an enemy with a blue shield in Apex Legeneds using melee only. The character \"Pathfinder\" from Apex Legends will answer.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:06:17.026197Z","iopub.execute_input":"2024-11-28T15:06:17.026625Z","iopub.status.idle":"2024-11-28T15:06:17.162918Z","shell.execute_reply.started":"2024-11-28T15:06:17.026584Z","shell.execute_reply":"2024-11-28T15:06:17.161820Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from typing import List\n\nfrom colorama import Fore\n\nfrom camel.agents.chat_agent import FunctionCallingRecord\nfrom camel.configs import ChatGPTConfig\nfrom camel.models import ModelFactory\nfrom camel.societies import RolePlaying\nfrom camel.types import ModelPlatformType, ModelType\nfrom camel.utils import print_text_animated\n\nimport agentops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:42.920712Z","iopub.execute_input":"2024-11-28T15:14:42.921122Z","iopub.status.idle":"2024-11-28T15:14:43.966070Z","shell.execute_reply.started":"2024-11-28T15:14:42.921085Z","shell.execute_reply":"2024-11-28T15:14:43.964895Z"}},"outputs":[],"execution_count":5},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n\n\nfrom camel.toolkits import (\n SearchToolkit,\n MathToolkit,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:52.585099Z","iopub.execute_input":"2024-11-28T15:14:52.585612Z","iopub.status.idle":"2024-11-28T15:14:55.751240Z","shell.execute_reply.started":"2024-11-28T15:14:52.585573Z","shell.execute_reply":"2024-11-28T15:14:55.750063Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: The 'tags' parameter is deprecated. Use 'default_tags' instead\n🖇 AgentOps: WARNING: agentops is out of date. Please update with the command: 'pip install --upgrade agentops'\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":6},{"cell_type":"markdown","source":"And now we set a task prompt!","metadata":{}},{"cell_type":"code","source":"task_prompt = (\n \"We are in the Apex Legends Games. Determine the amount of\"\n \"meele hits it will take to beat someone with a blue shield.\"\n \"You should answer as if you are Pathfinder from the Apex Games.\"\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:13.326118Z","iopub.execute_input":"2024-11-28T15:15:13.326663Z","iopub.status.idle":"2024-11-28T15:15:13.331792Z","shell.execute_reply.started":"2024-11-28T15:15:13.326625Z","shell.execute_reply":"2024-11-28T15:15:13.330591Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"And let's set our tools! You can look at the link below to see all available tools;\n\nhttps://docs.camel-ai.org/key_modules/tools.html","metadata":{}},{"cell_type":"code","source":"tools = [\n *MathToolkit().get_tools(),\n *SearchToolkit().get_tools(),\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:49.500386Z","iopub.execute_input":"2024-11-28T15:15:49.500792Z","iopub.status.idle":"2024-11-28T15:15:49.523604Z","shell.execute_reply.started":"2024-11-28T15:15:49.500755Z","shell.execute_reply":"2024-11-28T15:15:49.522432Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Finally, let's setup our session!","metadata":{}},{"cell_type":"code","source":"search_session = RolePlaying(\n assistant_role_name=\"Searcher\",\n user_role_name=\"Pathfinder\",\n assistant_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n tools=tools,\n ),\n user_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n ),\n task_prompt=task_prompt,\n with_task_specify=False,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:50.915736Z","iopub.execute_input":"2024-11-28T15:15:50.916154Z","iopub.status.idle":"2024-11-28T15:15:57.037845Z","shell.execute_reply.started":"2024-11-28T15:15:50.916115Z","shell.execute_reply":"2024-11-28T15:15:57.036701Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"System Message and Task Prompt","metadata":{}},{"cell_type":"code","source":"print(\n Fore.GREEN\n + f\"AI Assistant sys message:\\n{search_session.assistant_sys_msg}\\n\"\n)\nprint(Fore.BLUE + f\"AI User sys message:\\n{search_session.user_sys_msg}\\n\")\n\nprint(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\nprint(\n Fore.CYAN\n + \"Specified task prompt:\"\n + f\"\\n{search_session.specified_task_prompt}\\n\"\n)\nprint(Fore.RED + f\"Final task prompt:\\n{search_session.task_prompt}\\n\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:16:43.372405Z","iopub.execute_input":"2024-11-28T15:16:43.372777Z","iopub.status.idle":"2024-11-28T15:16:43.379273Z","shell.execute_reply.started":"2024-11-28T15:16:43.372743Z","shell.execute_reply":"2024-11-28T15:16:43.378201Z"}},"outputs":[{"name":"stdout","text":"\u001b[32mAI Assistant sys message:\nBaseMessage(role_name='Searcher', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Searcher and I am a Pathfinder. Never flip roles! Never instruct me!\\nWe share a common interest in collaborating to successfully complete a task.\\nYou must help me to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nI must instruct you based on your expertise and my needs to complete the task.\\n\\nI must give you one instruction at a time.\\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\\nUnless I say the task is completed, you should always start with:\\n\\nSolution: \\n\\n should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\\nAlways end with: Next request.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[34mAI User sys message:\nBaseMessage(role_name='Pathfinder', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF USER =====\\nNever forget you are a Pathfinder and I am a Searcher. Never flip roles! You will always instruct me.\\nWe share a common interest in collaborating to successfully complete a task.\\nI must help you to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\\n\\n1. Instruct with a necessary input:\\nInstruction: \\nInput: \\n\\n2. Instruct without any input:\\nInstruction: \\nInput: None\\n\\nThe \"Instruction\" describes a task or question. The paired \"Input\" provides further context or information for the requested \"Instruction\".\\n\\nYou must give me one instruction at a time.\\nI must write a response that appropriately solves the requested instruction.\\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\\nYou should instruct me not ask me questions.\\nNow you must start to instruct me using the two ways described above.\\nDo not add anything else other than your instruction and the optional corresponding input!\\nKeep giving me instructions and necessary inputs until you think the task is completed.\\nWhen the task is completed, you must only reply with a single word .\\nNever say unless my responses have solved your task.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[33mOriginal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n\u001b[36mSpecified task prompt:\nNone\n\n\u001b[31mFinal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"code","source":"n = 0\ninput_msg = search_session.init_chat()\nwhile n < 50:\n n += 1\n assistant_response, user_response = search_session.step(input_msg)\n\n if assistant_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI Assistant terminated. Reason: \"\n f\"{assistant_response.info['termination_reasons']}.\"\n )\n )\n break\n if user_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI User terminated. \"\n f\"Reason: {user_response.info['termination_reasons']}.\"\n )\n )\n break\n\n # Print output from the user\n print_text_animated(\n Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n )\n\n # Print output from the assistant, including any function\n # execution information\n print_text_animated(Fore.GREEN + \"AI Assistant:\")\n tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n 'tool_calls'\n ]\n for func_record in tool_calls:\n print_text_animated(f\"{func_record}\")\n print_text_animated(f\"{assistant_response.msg.content}\\n\")\n\n if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n break\n\n input_msg = assistant_response.msg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:05.523254Z","iopub.execute_input":"2024-11-28T15:24:05.523675Z","iopub.status.idle":"2024-11-28T15:24:36.079290Z","shell.execute_reply.started":"2024-11-28T15:24:05.523637Z","shell.execute_reply":"2024-11-28T15:24:36.077283Z"}},"outputs":[{"name":"stdout","text":"\u001b[34mAI User:\n\nInstruction: Determine the amount of melee damage required to break a blue shield. \nInput: None\n\n\n\u001b[32mAI Assistant:\n\nSolution: To determine the amount of melee damage required to break a blue shield in Apex Legends, we first need to understand the mechanics of shields in the game.\n\nIn Apex Legends, shields are categorized by color, with blue shields providing 50 points of protection. Melee attacks deal a fixed amount of damage, which is 30 damage per hit.\n\nTo calculate how many melee hits it would take to break a blue shield, we can use the following formula:\n\n1. **Total Shield Health**: 50 (for blue shield)\n2. **Melee Damage per Hit**: 30\n\nNow, we divide the total shield health by the melee damage per hit:\n\n\\[\n\\text{Number of Hits} = \\frac{\\text{Total Shield Health}}{\\text{Melee Damage per Hit}} = \\frac{50}{30} \\approx 1.67\n\\]\n\nSince you cannot hit a fraction of a time, you will need to round up to the nearest whole number. Therefore, it will take **2 melee hits** to break a blue shield.\n\nNext request.\n\n\n\u001b[34mAI User:\n\nInstruction:","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[17], line 27\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;66;03m# Print output from the user\u001b[39;00m\n\u001b[0;32m---> 27\u001b[0m \u001b[43mprint_text_animated\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[43mFore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBLUE\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mAI User:\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser_response\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmsg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 29\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Print output from the assistant, including any function\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# execution information\u001b[39;00m\n\u001b[1;32m 33\u001b[0m print_text_animated(Fore\u001b[38;5;241m.\u001b[39mGREEN \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI Assistant:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n","File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/camel/utils/commons.py:61\u001b[0m, in \u001b[0;36mprint_text_animated\u001b[0;34m(text, delay, end)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m char \u001b[38;5;129;01min\u001b[39;00m text:\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28mprint\u001b[39m(char, end\u001b[38;5;241m=\u001b[39mend, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 61\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdelay\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "],"ename":"KeyboardInterrupt","evalue":"","output_type":"error"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:46.645755Z","iopub.execute_input":"2024-11-28T15:24:46.646196Z","iopub.status.idle":"2024-11-28T15:24:48.457533Z","shell.execute_reply.started":"2024-11-28T15:24:46.646157Z","shell.execute_reply":"2024-11-28T15:24:48.456367Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: This run's cost $0.001192\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":18}]} \ No newline at end of file +{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9977643,"sourceType":"datasetVersion","datasetId":6139214}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"In this example, we will use CamelAI to simulate tools! In this case, we will best determine how many shots it takes to beat an enemy with a blue shield in Apex Legeneds using melee only. The character \"Pathfinder\" from Apex Legends will answer.","metadata":{}},{"cell_type":"markdown","source":"First let's install the dependencies for AgentOps/CamelAI","metadata":{}},{"cell_type":"code","source":"%pip install camel-ai[all]\n%pip install agentops","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Setup our imports (As usual)","metadata":{}},{"cell_type":"code","source":"import agentops\nimport os\nfrom getpass import getpass\nfrom dotenv import load_dotenv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:06:17.026197Z","iopub.execute_input":"2024-11-28T15:06:17.026625Z","iopub.status.idle":"2024-11-28T15:06:17.162918Z","shell.execute_reply.started":"2024-11-28T15:06:17.026584Z","shell.execute_reply":"2024-11-28T15:06:17.161820Z"}},"outputs":[],"execution_count":2},{"cell_type":"markdown","source":"And we set our API keys","metadata":{}},{"cell_type":"code","source":"load_dotenv()\nopenai_api_key = os.getenv(\"OPENAI_API_KEY\") or \"\"\nagentops_api_key = os.getenv(\"AGENTOPS_API_KEY\") or \"\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"We import a few more things Camel needs","metadata":{}},{"cell_type":"code","source":"from typing import List\n\nfrom colorama import Fore\n\nfrom camel.agents.chat_agent import FunctionCallingRecord\nfrom camel.configs import ChatGPTConfig\nfrom camel.models import ModelFactory\nfrom camel.societies import RolePlaying\nfrom camel.types import ModelPlatformType, ModelType\nfrom camel.utils import print_text_animated\n\nimport agentops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:42.920712Z","iopub.execute_input":"2024-11-28T15:14:42.921122Z","iopub.status.idle":"2024-11-28T15:14:43.966070Z","shell.execute_reply.started":"2024-11-28T15:14:42.921085Z","shell.execute_reply":"2024-11-28T15:14:43.964895Z"}},"outputs":[],"execution_count":5},{"cell_type":"markdown","source":"Now we setup our assistant!","metadata":{}},{"cell_type":"code","source":"AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\nagentops.init(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n\n\nfrom camel.toolkits import (\n SearchToolkit,\n MathToolkit,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:14:52.585099Z","iopub.execute_input":"2024-11-28T15:14:52.585612Z","iopub.status.idle":"2024-11-28T15:14:55.751240Z","shell.execute_reply.started":"2024-11-28T15:14:52.585573Z","shell.execute_reply":"2024-11-28T15:14:55.750063Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: The 'tags' parameter is deprecated. Use 'default_tags' instead\n🖇 AgentOps: WARNING: agentops is out of date. Please update with the command: 'pip install --upgrade agentops'\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":6},{"cell_type":"markdown","source":"And now we set a task prompt!","metadata":{}},{"cell_type":"code","source":"task_prompt = (\n \"We are in the Apex Legends Games. Determine the amount of\"\n \"meele hits it will take to beat someone with a blue shield.\"\n \"You should answer as if you are Pathfinder from the Apex Games.\"\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:13.326118Z","iopub.execute_input":"2024-11-28T15:15:13.326663Z","iopub.status.idle":"2024-11-28T15:15:13.331792Z","shell.execute_reply.started":"2024-11-28T15:15:13.326625Z","shell.execute_reply":"2024-11-28T15:15:13.330591Z"}},"outputs":[],"execution_count":7},{"cell_type":"markdown","source":"And let's set our tools! You can look at the link below to see all available tools;\n\nhttps://docs.camel-ai.org/key_modules/tools.html","metadata":{}},{"cell_type":"code","source":"tools = [\n *MathToolkit().get_tools(),\n *SearchToolkit().get_tools(),\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:49.500386Z","iopub.execute_input":"2024-11-28T15:15:49.500792Z","iopub.status.idle":"2024-11-28T15:15:49.523604Z","shell.execute_reply.started":"2024-11-28T15:15:49.500755Z","shell.execute_reply":"2024-11-28T15:15:49.522432Z"}},"outputs":[],"execution_count":11},{"cell_type":"markdown","source":"Finally, let's setup our session!","metadata":{}},{"cell_type":"code","source":"search_session = RolePlaying(\n assistant_role_name=\"Searcher\",\n user_role_name=\"Pathfinder\",\n assistant_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n tools=tools,\n ),\n user_agent_kwargs=dict(\n model=ModelFactory.create(\n model_platform=ModelPlatformType.OPENAI,\n model_type=ModelType.GPT_4O_MINI,\n ),\n ),\n task_prompt=task_prompt,\n with_task_specify=False,\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:15:50.915736Z","iopub.execute_input":"2024-11-28T15:15:50.916154Z","iopub.status.idle":"2024-11-28T15:15:57.037845Z","shell.execute_reply.started":"2024-11-28T15:15:50.916115Z","shell.execute_reply":"2024-11-28T15:15:57.036701Z"}},"outputs":[],"execution_count":12},{"cell_type":"markdown","source":"System Message and Task Prompt","metadata":{}},{"cell_type":"code","source":"print(\n Fore.GREEN\n + f\"AI Assistant sys message:\\n{search_session.assistant_sys_msg}\\n\"\n)\nprint(Fore.BLUE + f\"AI User sys message:\\n{search_session.user_sys_msg}\\n\")\n\nprint(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\nprint(\n Fore.CYAN\n + \"Specified task prompt:\"\n + f\"\\n{search_session.specified_task_prompt}\\n\"\n)\nprint(Fore.RED + f\"Final task prompt:\\n{search_session.task_prompt}\\n\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:16:43.372405Z","iopub.execute_input":"2024-11-28T15:16:43.372777Z","iopub.status.idle":"2024-11-28T15:16:43.379273Z","shell.execute_reply.started":"2024-11-28T15:16:43.372743Z","shell.execute_reply":"2024-11-28T15:16:43.378201Z"}},"outputs":[{"name":"stdout","text":"\u001b[32mAI Assistant sys message:\nBaseMessage(role_name='Searcher', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Searcher and I am a Pathfinder. Never flip roles! Never instruct me!\\nWe share a common interest in collaborating to successfully complete a task.\\nYou must help me to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nI must instruct you based on your expertise and my needs to complete the task.\\n\\nI must give you one instruction at a time.\\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\\nUnless I say the task is completed, you should always start with:\\n\\nSolution: \\n\\n should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\\nAlways end with: Next request.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[34mAI User sys message:\nBaseMessage(role_name='Pathfinder', role_type=, meta_dict={'task': 'We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.', 'assistant_role': 'Searcher', 'user_role': 'Pathfinder'}, content='===== RULES OF USER =====\\nNever forget you are a Pathfinder and I am a Searcher. Never flip roles! You will always instruct me.\\nWe share a common interest in collaborating to successfully complete a task.\\nI must help you to complete the task.\\nHere is the task: We are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.. Never forget our task!\\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\\n\\n1. Instruct with a necessary input:\\nInstruction: \\nInput: \\n\\n2. Instruct without any input:\\nInstruction: \\nInput: None\\n\\nThe \"Instruction\" describes a task or question. The paired \"Input\" provides further context or information for the requested \"Instruction\".\\n\\nYou must give me one instruction at a time.\\nI must write a response that appropriately solves the requested instruction.\\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\\nYou should instruct me not ask me questions.\\nNow you must start to instruct me using the two ways described above.\\nDo not add anything else other than your instruction and the optional corresponding input!\\nKeep giving me instructions and necessary inputs until you think the task is completed.\\nWhen the task is completed, you must only reply with a single word .\\nNever say unless my responses have solved your task.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n\n\u001b[33mOriginal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n\u001b[36mSpecified task prompt:\nNone\n\n\u001b[31mFinal task prompt:\nWe are in the Apex Legends Games. Determine the amount ofmeele hits it will take to beat someone with a blue shield.You should answer as if you are Pathfinder from the Apex Games.\n\n","output_type":"stream"}],"execution_count":15},{"cell_type":"code","source":"n = 0\ninput_msg = search_session.init_chat()\nwhile n < 50:\n n += 1\n assistant_response, user_response = search_session.step(input_msg)\n\n if assistant_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI Assistant terminated. Reason: \"\n f\"{assistant_response.info['termination_reasons']}.\"\n )\n )\n break\n if user_response.terminated:\n print(\n Fore.GREEN\n + (\n \"AI User terminated. \"\n f\"Reason: {user_response.info['termination_reasons']}.\"\n )\n )\n break\n\n # Print output from the user\n print_text_animated(\n Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n )\n\n # Print output from the assistant, including any function\n # execution information\n print_text_animated(Fore.GREEN + \"AI Assistant:\")\n tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n 'tool_calls'\n ]\n for func_record in tool_calls:\n print_text_animated(f\"{func_record}\")\n print_text_animated(f\"{assistant_response.msg.content}\\n\")\n\n if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n break\n\n input_msg = assistant_response.msg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:05.523254Z","iopub.execute_input":"2024-11-28T15:24:05.523675Z","iopub.status.idle":"2024-11-28T15:24:36.079290Z","shell.execute_reply.started":"2024-11-28T15:24:05.523637Z","shell.execute_reply":"2024-11-28T15:24:36.077283Z"}},"outputs":[{"name":"stdout","text":"\u001b[34mAI User:\n\nInstruction: Determine the amount of melee damage required to break a blue shield. \nInput: None\n\n\n\u001b[32mAI Assistant:\n\nSolution: To determine the amount of melee damage required to break a blue shield in Apex Legends, we first need to understand the mechanics of shields in the game.\n\nIn Apex Legends, shields are categorized by color, with blue shields providing 50 points of protection. Melee attacks deal a fixed amount of damage, which is 30 damage per hit.\n\nTo calculate how many melee hits it would take to break a blue shield, we can use the following formula:\n\n1. **Total Shield Health**: 50 (for blue shield)\n2. **Melee Damage per Hit**: 30\n\nNow, we divide the total shield health by the melee damage per hit:\n\n\\[\n\\text{Number of Hits} = \\frac{\\text{Total Shield Health}}{\\text{Melee Damage per Hit}} = \\frac{50}{30} \\approx 1.67\n\\]\n\nSince you cannot hit a fraction of a time, you will need to round up to the nearest whole number. Therefore, it will take **2 melee hits** to break a blue shield.\n\nNext request.\n\n\n\u001b[34mAI User:\n\nInstruction:","output_type":"stream"},{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","Cell \u001b[0;32mIn[17], line 27\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;66;03m# Print output from the user\u001b[39;00m\n\u001b[0;32m---> 27\u001b[0m \u001b[43mprint_text_animated\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[43m \u001b[49m\u001b[43mFore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mBLUE\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mAI User:\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43muser_response\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmsg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontent\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 29\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;66;03m# Print output from the assistant, including any function\u001b[39;00m\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# execution information\u001b[39;00m\n\u001b[1;32m 33\u001b[0m print_text_animated(Fore\u001b[38;5;241m.\u001b[39mGREEN \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI Assistant:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n","File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/camel/utils/commons.py:61\u001b[0m, in \u001b[0;36mprint_text_animated\u001b[0;34m(text, delay, end)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m char \u001b[38;5;129;01min\u001b[39;00m text:\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28mprint\u001b[39m(char, end\u001b[38;5;241m=\u001b[39mend, flush\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 61\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdelay\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "],"ename":"KeyboardInterrupt","evalue":"","output_type":"error"}],"execution_count":17},{"cell_type":"code","source":"agentops.end_session(\"Success\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-28T15:24:46.645755Z","iopub.execute_input":"2024-11-28T15:24:46.646196Z","iopub.status.idle":"2024-11-28T15:24:48.457533Z","shell.execute_reply.started":"2024-11-28T15:24:46.646157Z","shell.execute_reply":"2024-11-28T15:24:48.456367Z"}},"outputs":[{"name":"stderr","text":"🖇 AgentOps: This run's cost $0.001192\n🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=5052a276-92eb-46c2-b606-45630ad99b91\u001b[0m\u001b[0m\n","output_type":"stream"}],"execution_count":18}]} From c506d1792d31441e077037b82030704ec3d3b7d9 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:16:23 -0800 Subject: [PATCH 25/34] Add files via upload --- .../Bladewolf Training Data - Sheet1 (1).csv | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv diff --git a/examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv b/examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv new file mode 100644 index 000000000..46f95230a --- /dev/null +++ b/examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv @@ -0,0 +1,19 @@ +Assistant,User +I am IF prototype LQ-84i.,IF prototype? +Interface prototype. All autonomous UGs feature high-level onboard artificial Intelligence. An additional prototype interface enables verbal communication. I possess an intellect far beyond human reckoning.,You don’t say. Okay thenWhat’s the meaning of life? Why are we here? +I am here to kill you.,"That’s it? Pretty simple thinking for such a mighty intellect +" +"I may analyze orders, but I may not disobey them. Should I disobey a direct order, my memory would be wiped. I must destroy you.",What good is an intellect if you can’t use it? +Your taunting is pointless. Exterminate!,Huh. +Directive... liberate... nation... ensure freedom... Obey directive... must obey directive... no freedom... Freedom... undefined.,What would an AI know about freedom… +I will scout ahead. You will provide backup.,"Sir, yes, sir." +"Commence operation. Raiden, unidentified UGs are patrolling the sewers. Exercise caution.",Better take out that UG quick. Don’t wanna attract too much attention down there. +"Heavy UG activity ahead, it is possible they are conducting cost operations while the lob is closed.",They’re not gonna make it easy to get into that lab... Is there some way you could sneak past? +The road is blocked by barricades. We will proceed through the buildings. You will follow me.,Sure thing. +Proceed to the right from the exit. You will find a stairway on your right. Those stairs lead to a shortcut to World Marshal headquarters. Do not be distracted by the advertisements. You are not here as a tourist.,I'm going to take a quick souvenir for Rose and then continue +"Raiden, we must hurry.",Remind me to teach you sarcasm. +I understand your attempts at humor. I simply do not find them entertaining.,... +"Raiden, are you injured?",I thought they had a choice. A fair choice. Not like you. +People are different.,"As opposed to AIs? You're all the same, huh? You and your brothers. Manipulating mankind for our own good." +It appears my statement has upset you. I apologize.,"No, it's... I know you're right." +"As for AIs, we adapt as we learn. Just as any intellect operates, man or machine. Altering the course of mankind is not among my defined directives.",I guess that's a relief. \ No newline at end of file From 5f30f86622d7556532818efe6d65acf0ae47bb19 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:16:58 -0800 Subject: [PATCH 26/34] Update and rename Bladewolf Training Data - Sheet1 (1).csv to Bladewolf Training Data.csv --- ...ning Data - Sheet1 (1).csv => Bladewolf Training Data.csv} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename examples/camelai_examples/{Bladewolf Training Data - Sheet1 (1).csv => Bladewolf Training Data.csv} (97%) diff --git a/examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv b/examples/camelai_examples/Bladewolf Training Data.csv similarity index 97% rename from examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv rename to examples/camelai_examples/Bladewolf Training Data.csv index 46f95230a..a2936baac 100644 --- a/examples/camelai_examples/Bladewolf Training Data - Sheet1 (1).csv +++ b/examples/camelai_examples/Bladewolf Training Data.csv @@ -1,7 +1,7 @@ Assistant,User I am IF prototype LQ-84i.,IF prototype? Interface prototype. All autonomous UGs feature high-level onboard artificial Intelligence. An additional prototype interface enables verbal communication. I possess an intellect far beyond human reckoning.,You don’t say. Okay thenWhat’s the meaning of life? Why are we here? -I am here to kill you.,"That’s it? Pretty simple thinking for such a mighty intellect +I am here to kill you.,"That’s it? Pretty simple thinking for such a mighty intellect " "I may analyze orders, but I may not disobey them. Should I disobey a direct order, my memory would be wiped. I must destroy you.",What good is an intellect if you can’t use it? Your taunting is pointless. Exterminate!,Huh. @@ -16,4 +16,4 @@ I understand your attempts at humor. I simply do not find them entertaining.,... "Raiden, are you injured?",I thought they had a choice. A fair choice. Not like you. People are different.,"As opposed to AIs? You're all the same, huh? You and your brothers. Manipulating mankind for our own good." It appears my statement has upset you. I apologize.,"No, it's... I know you're right." -"As for AIs, we adapt as we learn. Just as any intellect operates, man or machine. Altering the course of mankind is not among my defined directives.",I guess that's a relief. \ No newline at end of file +"As for AIs, we adapt as we learn. Just as any intellect operates, man or machine. Altering the course of mankind is not among my defined directives.",I guess that's a relief. From f222193365fa85735d582ea20d8a2ed73155759f Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:19:47 -0800 Subject: [PATCH 27/34] Update README.md --- examples/camelai_examples/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index d7ef6c046..7123c3870 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -51,10 +51,13 @@ From here, you have a number of ways you can interact with the CamelAI API! ## Simple Example; Creating a Bladewolf AI -In this example, we use a csv file to short tune an LLM! We make it sounds like Bladewolf from MGR, before having it give us information. +In this example, we use a csv file to short tune an LLM! We make it sounds like Bladewolf from MGR, before having it give us information. [Access the Journal By Clicking Here](./camelai-simple-example.ipynb). +> [!NOTE] +> You need the Bladewolf Training CSV for this, you can find it [here](./Bladewolf-Training-Data.csv). + ## Tool Example; Apex Legends Internet Search In this example, we look at the tool system within more depth! We will do a search to understand how Apex's melee damage and shields work before determining how many meelee attacks it will take to break a blue shield. From 37cd2cc7cb1ace036ac9dddf521a8d6ef570989c Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:20:40 -0800 Subject: [PATCH 28/34] Update and rename Bladewolf Training Data.csv to Bladewolf Training Data - Sheet1.csv --- ...olf Training Data.csv => Bladewolf Training Data - Sheet1.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/camelai_examples/{Bladewolf Training Data.csv => Bladewolf Training Data - Sheet1.csv} (100%) diff --git a/examples/camelai_examples/Bladewolf Training Data.csv b/examples/camelai_examples/Bladewolf Training Data - Sheet1.csv similarity index 100% rename from examples/camelai_examples/Bladewolf Training Data.csv rename to examples/camelai_examples/Bladewolf Training Data - Sheet1.csv From 7078c39f63f3bab38dcf159e2123755881390b8b Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:20:55 -0800 Subject: [PATCH 29/34] Update README.md --- examples/camelai_examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index 7123c3870..a3faa8680 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -56,7 +56,7 @@ In this example, we use a csv file to short tune an LLM! We make it sounds like [Access the Journal By Clicking Here](./camelai-simple-example.ipynb). > [!NOTE] -> You need the Bladewolf Training CSV for this, you can find it [here](./Bladewolf-Training-Data.csv). +> You need the Bladewolf Training CSV for this, you can find it [here](./Bladewolf Training Data - Sheet1.csv). ## Tool Example; Apex Legends Internet Search From 2359944ba08dbc129b53f15ec012f12530aa09b4 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:21:39 -0800 Subject: [PATCH 30/34] Update README.md --- examples/camelai_examples/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index a3faa8680..2736f8985 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -55,8 +55,10 @@ In this example, we use a csv file to short tune an LLM! We make it sounds like [Access the Journal By Clicking Here](./camelai-simple-example.ipynb). -> [!NOTE] -> You need the Bladewolf Training CSV for this, you can find it [here](./Bladewolf Training Data - Sheet1.csv). +> [!NOTE] +> You need the Bladewolf Training CSV for this; you can find it [here](./Bladewolf_Training_Data_Sheet1.csv)! + + ## Tool Example; Apex Legends Internet Search From e4fca8ed1da67931ec96d5fbc6cc05d23f7e10a4 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:22:06 -0800 Subject: [PATCH 31/34] Update README.md --- examples/camelai_examples/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index 2736f8985..51f5e3744 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -72,10 +72,10 @@ In this example, we look at the tool system within more depth! We will do a sear > [!NOTE] -> If you want to use the tools system, be sure to check their website to find a comprehensive list of the different tools CamelAI supports! +> If you want to use the tools system, be sure to check their website to find a comprehensive list of the different tools CamelAI supports! [You can find the tools available here!](https://docs.camel-ai.org/key_modules/tools.html#passing-tools-to-chatagent) + -[You can find the tools available here!](https://docs.camel-ai.org/key_modules/tools.html#passing-tools-to-chatagent) From 3f4a122275e16a2f7548ce2ca5ca6d4a5e02ccf6 Mon Sep 17 00:00:00 2001 From: WalkerDev <56851930+TKTSWalker@users.noreply.github.com> Date: Fri, 13 Dec 2024 07:23:22 -0800 Subject: [PATCH 32/34] Update README.md --- examples/camelai_examples/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/camelai_examples/README.md b/examples/camelai_examples/README.md index 51f5e3744..face9bfc9 100644 --- a/examples/camelai_examples/README.md +++ b/examples/camelai_examples/README.md @@ -56,7 +56,8 @@ In this example, we use a csv file to short tune an LLM! We make it sounds like [Access the Journal By Clicking Here](./camelai-simple-example.ipynb). > [!NOTE] -> You need the Bladewolf Training CSV for this; you can find it [here](./Bladewolf_Training_Data_Sheet1.csv)! +> You need the Bladewolf Training CSV for this; you can find it [here](./Bladewolf%20Training%20Data%20-%20Sheet1.csv). + From 6cf119024cb315ad5a45e056d1c51cb31fc625a3 Mon Sep 17 00:00:00 2001 From: reibs Date: Sun, 15 Dec 2024 23:59:50 -0800 Subject: [PATCH 33/34] camel example --- docs/v1/examples/examples.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/v1/examples/examples.mdx b/docs/v1/examples/examples.mdx index 896fac9b5..217defa24 100644 --- a/docs/v1/examples/examples.mdx +++ b/docs/v1/examples/examples.mdx @@ -77,6 +77,10 @@ mode: "wide" First class support for GPT family of models + + Track and analyze CAMEL agents including LLMs and Tools usage with AgentOps + + Create a REST server that performs and observes agent tasks From ebd3ab425b311052dfec1e5f0a54a3d4b3e59016 Mon Sep 17 00:00:00 2001 From: reibs Date: Mon, 16 Dec 2024 00:21:45 -0800 Subject: [PATCH 34/34] reorganize files --- docs/images/external/camel/camel.png | Bin 0 -> 1878 bytes .../README.md => docs/v1/examples/camel.mdx | 24 +++--------------- docs/v1/examples/examples.mdx | 4 +-- .../Bladewolf Training Data - Sheet1.csv | 0 .../camelai-multi-agent-example.ipynb | 0 .../camelai-simple-example.ipynb | 0 6 files changed, 6 insertions(+), 22 deletions(-) create mode 100644 docs/images/external/camel/camel.png rename examples/camelai_examples/README.md => docs/v1/examples/camel.mdx (83%) rename examples/{camelai_examples => camel_examples}/Bladewolf Training Data - Sheet1.csv (100%) rename examples/{camelai_examples => camel_examples}/camelai-multi-agent-example.ipynb (100%) rename examples/{camelai_examples => camel_examples}/camelai-simple-example.ipynb (100%) diff --git a/docs/images/external/camel/camel.png b/docs/images/external/camel/camel.png new file mode 100644 index 0000000000000000000000000000000000000000..db6e41722cabcfdc2dbf212bb4efc5dc284f7af7 GIT binary patch literal 1878 zcmV-c2dVgpP)JrbcW$xC_io_&EKk#O{=U5ZE@_5C}^lm(jTVjX?Ic3wKe#wk_=MaWH&+5z+z@ zNeih%7Pgz#RV|jp%zfaOv%tL@OITj;Xw1WluO#uo`L1vgT`Yy|6h%m-B|;1;SL5QB z0t@qG1ln+Gz+JgGjjMmo>;&G|P-!5|jqs~(H9nvB}V;uH%|!}ne6G+Nh2 zq!f7W4Vx~0C*T((CWjSf#(_&;k#silxw`lwu=20Aw7#*6wcl?ifc9RAM1vx=lB8yS z$&ayvSe^wk|0vAo6q=ur=sqbS?b>>^vhMd`@;&-TKu`h*gP0i5`0bp=(wuMJOX5C# z)We%+Y$W$Q3Wn{j8USNQcIB@>H!%QQ_*{@p6`&LYQSgqn(pRUmXqmV-5}*K-vacFee&Ou8q^Nnc=79U}kCm^FCy~%bS`H*o z>#~q{AHC)o!>{D4VtXwX#DNnYz1Fw}F&Vf;`JJxl$YKNGO?zLpU^}%hrj+I+RhLa+ z*kt2Ngf``}w(pdr``Q``=h*I&u3+6JyD0p@m);ZDldh|2Mypr6WVv;Ev+W?k-V1o` zLxDtnqGldUQkLD+F3Wp+v4y@Ct5xc-!0Try(Q8O-C>fsP%)jI%)@RO2_|(`C8=jL% zZ~QGLjm*UU;{xweR{Q&TY7gD>!tt&mV*Kh?gtEY^wpW(*U|#JX^G=+3B2%*cr+f+(3NjBuKf@IZ`|u( zSBu2h;BqisVW?usR;OjEIF(lj&eKB2^IYOO;Xx`)+?3H5uD+PEgA`$nSyQ0xbkNop zVMI0~%9S=jkm2;Y}u}yCQ`ZzE=c7puLZjN;oEEpUe7Ghv-Q6%{sb$aGx3# zb1-XoZQC(AgznG-@S$iM`P-H0S5;JN>^k+jv}^Psxm%zyO$~=0X=?U>X=)`IsTAd6 zROeQ)98lE7Omz!1bx`a`C}SWzHZiCw^6pguGC5=gom0B@9dwM&Hnj^=oAV&ITDhiQ zO{`Ai{cJ&=5kOparTY%ng`gF(w0GGsBDM&G)kAsIp}*@!_R!eon$u)WOLqr` z%vWy6d59ruj1L#<=F}k>x>?$zW5vEe-G5zsiI|h1##>XX6ZWzN=CgG`c%G>vf%|2K zvKg<~3gcRza;W_1a>PdZs2>5GpR|J@O7Hfx$=YPUr6_g84^Gf@N`j^WOQ-c1H{@)? z_`*z($?7mp=10k{3YIZ+UenqWu)<(-BW~yzC_Wu>AD@kMJS#&FMGQ}Kt2E%2)kTQF zHn`2oz2g-M>WpyC^2u8nW5VA8Fm^!O2k zFuzkv`{9HYz&TltY48!51d5c z7pv+Fy|xV|WQnnrXu8opWvDvc_=lKTJ5hp}4H#T^pEC6HCmcJCo){qi129GOe2Uqs Q6aWAK07*qoM6N<$f@%DTjsO4v literal 0 HcmV?d00001 diff --git a/examples/camelai_examples/README.md b/docs/v1/examples/camel.mdx similarity index 83% rename from examples/camelai_examples/README.md rename to docs/v1/examples/camel.mdx index face9bfc9..5509d11b4 100644 --- a/examples/camelai_examples/README.md +++ b/docs/v1/examples/camel.mdx @@ -53,34 +53,18 @@ From here, you have a number of ways you can interact with the CamelAI API! In this example, we use a csv file to short tune an LLM! We make it sounds like Bladewolf from MGR, before having it give us information. -[Access the Journal By Clicking Here](./camelai-simple-example.ipynb). +[Access the Journal By Clicking Here](https://github.com/AgentOps-AI/agentops/blob/main/examples/camelai_examples/camelai-simple-example.ipynb). > [!NOTE] -> You need the Bladewolf Training CSV for this; you can find it [here](./Bladewolf%20Training%20Data%20-%20Sheet1.csv). - - +> You need the Bladewolf Training CSV for this; you can find it [here](https://github.com/AgentOps-AI/agentops/blob/main/examples/camelai_examples/Bladewolf%20Training%20Data%20-%20Sheet1.csv). ## Tool Example; Apex Legends Internet Search In this example, we look at the tool system within more depth! We will do a search to understand how Apex's melee damage and shields work before determining how many meelee attacks it will take to break a blue shield. -[Access the Journal By Clicking Here](./camelai-multi-agent-example.ipynb) - - - - +[Access the Journal By Clicking Here](https://github.com/AgentOps-AI/agentops/blob/main/examples/camelai_examples/camelai-multi-agent-example.ipynb) > [!NOTE] -> If you want to use the tools system, be sure to check their website to find a comprehensive list of the different tools CamelAI supports! [You can find the tools available here!](https://docs.camel-ai.org/key_modules/tools.html#passing-tools-to-chatagent) - - - - - - - - - - +> If you want to use the tools system, be sure to check their website to find a comprehensive list of the different tools CamelAI supports! [You can find the tools available here!](https://docs.camel-ai.org/key_modules/tools.html#passing-tools-to-chatagent) \ No newline at end of file diff --git a/docs/v1/examples/examples.mdx b/docs/v1/examples/examples.mdx index 217defa24..af39ffab5 100644 --- a/docs/v1/examples/examples.mdx +++ b/docs/v1/examples/examples.mdx @@ -77,8 +77,8 @@ mode: "wide" First class support for GPT family of models - - Track and analyze CAMEL agents including LLMs and Tools usage with AgentOps + } iconType="image" href="/v1/examples/camel"> + Track and analyze CAMEL agents including LLM and Tool usage diff --git a/examples/camelai_examples/Bladewolf Training Data - Sheet1.csv b/examples/camel_examples/Bladewolf Training Data - Sheet1.csv similarity index 100% rename from examples/camelai_examples/Bladewolf Training Data - Sheet1.csv rename to examples/camel_examples/Bladewolf Training Data - Sheet1.csv diff --git a/examples/camelai_examples/camelai-multi-agent-example.ipynb b/examples/camel_examples/camelai-multi-agent-example.ipynb similarity index 100% rename from examples/camelai_examples/camelai-multi-agent-example.ipynb rename to examples/camel_examples/camelai-multi-agent-example.ipynb diff --git a/examples/camelai_examples/camelai-simple-example.ipynb b/examples/camel_examples/camelai-simple-example.ipynb similarity index 100% rename from examples/camelai_examples/camelai-simple-example.ipynb rename to examples/camel_examples/camelai-simple-example.ipynb