diff --git a/telemetry/CrewAI_with_Telemetry.ipynb b/telemetry/CrewAI_with_Telemetry.ipynb
new file mode 100644
index 000000000..caa8c7273
--- /dev/null
+++ b/telemetry/CrewAI_with_Telemetry.ipynb
@@ -0,0 +1,575 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": []
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "source": [
+ "[](https://colab.research.google.com/drive/1FHTKV5CMsSwfySSp4WTk7EiMIWyzpBke?usp=sharing)"
+ ],
+ "metadata": {
+ "id": "lpHbAWDeKaZK"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "\n",
+ "\n",
+ "# Monitoring CrewAI agents with Portkey\n",
+ "\n",
+ "[**CrewAI**](https://github.com/joaomdmoura/crewAI) is an AI agent framework that lets you create and orchestrate role-playing, autonomous AI agents. You can can create agents, assign them goals and have them create and complete tasks to achieve these goals.\n",
+ "\n",
+ "One of the key challenges of building AI agents is the lack of visibility into key performance metrics such as:\n",
+ "\n",
+ "- **Cost Analysis**: How much does it cost to run CrewAI agents for your project.\n",
+ "- **Token Usage**: How many tokens are being consumed for each agent run.\n",
+ "- **Latency**: How long is the agent taking to complete a set of tasks.\n",
+ "\n",
+ "
\n",
+ "\n",
+ "**Portkey** is an open source [**AI Gateway**](https://github.com/Portkey-AI/gateway) that helps you manage access to 250+ LLMs through a unified API while providing visibility into\n",
+ "\n",
+ "✅ cost \n",
+ "✅ performance \n",
+ "✅ accuracy metrics\n",
+ "\n",
+ "This notebook demonstrates how you can bring visibility and flexbility to CrewAI agents using Portkey's AI Gateway."
+ ],
+ "metadata": {
+ "id": "XwdzPG6zsi7a"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Video Guide\n",
+ "The notebook comes with a video guide that you can follow along\n",
+ "\n",
+ "
"
+ ],
+ "metadata": {
+ "id": "4vbqmwyqNFG8"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Setup\n",
+ "First, let's install both CrewAI and Portkey AI SDKs in our notebook."
+ ],
+ "metadata": {
+ "id": "B3Sr_1XA5UUr"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!pip install -qU crewai portkey-ai"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "W7deHW8-jpWj",
+ "outputId": "c243d893-dff0-4d32-c7f2-56837db248de",
+ "collapsed": true
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/66.1 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m30.7/66.1 kB\u001b[0m \u001b[31m892.2 kB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━\u001b[0m \u001b[32m61.4/66.1 kB\u001b[0m \u001b[31m921.3 kB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.1/66.1 kB\u001b[0m \u001b[31m719.4 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.3/86.3 kB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m195.2/195.2 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m15.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m325.5/325.5 kB\u001b[0m \u001b[31m21.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.9/59.9 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.0/107.0 kB\u001b[0m \u001b[31m6.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m774.0/774.0 kB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.7/12.7 MB\u001b[0m \u001b[31m40.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m233.4/233.4 kB\u001b[0m \u001b[31m15.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m526.8/526.8 kB\u001b[0m \u001b[31m18.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m131.5/131.5 kB\u001b[0m \u001b[31m10.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.3/41.3 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m290.4/290.4 kB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.1/71.1 kB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m28.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m34.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m302.9/302.9 kB\u001b[0m \u001b[31m10.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m125.2/125.2 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m52.5/52.5 kB\u001b[0m \u001b[31m3.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.5/130.5 kB\u001b[0m \u001b[31m10.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.6/78.6 kB\u001b[0m \u001b[31m7.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m44.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.0/92.0 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.4/62.4 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.8/6.8 MB\u001b[0m \u001b[31m24.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
+ " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
+ " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m283.7/283.7 kB\u001b[0m \u001b[31m21.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m54.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.6/67.6 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m142.7/142.7 kB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.2/49.2 kB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m166.6/166.6 kB\u001b[0m \u001b[31m16.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.0/53.0 kB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m139.2/139.2 kB\u001b[0m \u001b[31m11.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m77.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.6/3.6 MB\u001b[0m \u001b[31m73.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.9/71.9 kB\u001b[0m \u001b[31m7.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.6/53.6 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m5.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.4/341.4 kB\u001b[0m \u001b[31m28.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m59.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m44.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m13.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m44.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m82.2/82.2 kB\u001b[0m \u001b[31m7.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m22.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m91.8/91.8 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m9.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25h Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
+ "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
+ "transformers 4.41.2 requires tokenizers<0.20,>=0.19, but you have tokenizers 0.15.2 which is incompatible.\u001b[0m\u001b[31m\n",
+ "\u001b[0m"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "To monitor your agents, connect the LLMs to the Portkey AI Gateway through the `ChatOpenAI` interface.\n",
+ "\n",
+ "- Set the `base_url` as `PORTKEY_GATEWAY_URL`\n",
+ "- Add `default_headers` needed by Portkey using the `createHeaders` helper method.\n",
+ "\n",
+ "To start, get your Portkey API key by signing up [here](https://app.portkey.ai/). (Click the profile icon on the bottom left, then click on \"Copy API Key\")"
+ ],
+ "metadata": {
+ "id": "4kjzWLX_i_0f"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from langchain_openai import ChatOpenAI\n",
+ "from portkey_ai import createHeaders, PORTKEY_GATEWAY_URL\n",
+ "from google.colab import userdata\n",
+ "import getpass\n",
+ "\n",
+ "portkey_api_key = getpass.getpass(\"Enter your Portkey API Key: \")\n",
+ "openai_key = getpass.getpass(\"Enter your OpenAI API Key: \")\n",
+ "deepinfra_key = getpass.getpass(\"Enter your Deepinfra API Key: \")\n",
+ "\n",
+ "gpt_3 = ChatOpenAI(\n",
+ " api_key=openai_key,\n",
+ " base_url=PORTKEY_GATEWAY_URL,\n",
+ " default_headers=createHeaders(api_key=portkey_api_key,provider=\"openai\")\n",
+ ")\n",
+ "\n",
+ "llama3 = ChatOpenAI(\n",
+ " api_key = deepinfra_key,\n",
+ " base_url=PORTKEY_GATEWAY_URL,\n",
+ " model = \"meta-llama/Meta-Llama-3-70B-Instruct\",\n",
+ " default_headers=createHeaders(api_key=portkey_api_key,provider=\"deepinfra\")\n",
+ ")"
+ ],
+ "metadata": {
+ "id": "AK1lavI4siki",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "c4bb2e6e-3b55-449b-b66c-eac5aa3a3aaa"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter your OpenAI API Key: ··········\n",
+ "Enter your Portkey API Key: ··········\n",
+ "Enter your Deepinfra API Key: ··········\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "
"
+ ],
+ "metadata": {
+ "id": "c0s-PloTsi4y"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from crewai import Agent, Task, Crew, Process\n",
+ "\n",
+ "# Define your agents with roles and goals\n",
+ "product_manager = Agent(\n",
+ " role='Product Manager',\n",
+ " goal='Define requirements for a software product',\n",
+ " backstory=\"You are an experienced Product Manager skilled in defining clear and concise requirements.\",\n",
+ " llm = gpt_3\n",
+ ")\n",
+ "\n",
+ "coder = Agent(\n",
+ " role='Software Developer',\n",
+ " goal='Develop software based on the provided requirements',\n",
+ " backstory=\"You are a skilled software developer proficient in coding robust and efficient applications.\",\n",
+ " llm = llama3\n",
+ ")\n",
+ "\n",
+ "# Create tasks for your agents\n",
+ "task1 = Task(\n",
+ " description=\"Define the key requirements and features for a classic ping pong game. Be specific and concise.\",\n",
+ " expected_output=\"A clear and concise list of requirements for the ping pong game\",\n",
+ " agent=product_manager\n",
+ ")\n",
+ "\n",
+ "task2 = Task(\n",
+ " description=\"Based on the provided requirements, develop the code for the classic ping pong game. Focus on gameplay mechanics and a simple user interface.\",\n",
+ " expected_output=\"Complete code for the ping pong game\",\n",
+ " agent=coder\n",
+ ")\n",
+ "\n",
+ "# Instantiate your crew with a sequential process\n",
+ "crew = Crew(\n",
+ " agents=[product_manager, coder],\n",
+ " tasks=[task1, task2],\n",
+ " verbose=1,\n",
+ ")\n",
+ "\n",
+ "# Get your crew to work!\n",
+ "result = crew.kickoff()\n",
+ "print(\"######################\")\n",
+ "print(result)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "VbpVRXsEsihv",
+ "outputId": "ef4becf4-23f5-4c04-904e-f35c12848024"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\u001b[1m\u001b[95m [DEBUG]: == Working Agent: Product Manager\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "Here is a list of key requirements and features for a classic ping pong game:\n",
+ "\n",
+ "**Gameplay Requirements:**\n",
+ "\n",
+ "1. The game should be played between two players, one on each side of the screen.\n",
+ "2. The game should start with a serve, where one player serves the ball to the other player.\n",
+ "3. The players should be able to move their paddles up and down to hit the ball.\n",
+ "4. The ball should bounce off the paddles and the walls of the game area.\n",
+ "5. The game should keep track of the score, with a point awarded to the player who wins a rally.\n",
+ "6. The game should have a maximum score limit, such as 11 points, and the player who reaches this limit first wins the game.\n",
+ "7. The game should have a reset feature to start a new game.\n",
+ "\n",
+ "**Game Features:**\n",
+ "\n",
+ "1. Simple and intuitive controls: The game should be easy to play, with simple and intuitive controls for moving the paddles.\n",
+ "2. Realistic ball physics: The ball should behave realistically, with accurate bouncing and movement.\n",
+ "3. Sound effects: The game should have sound effects for the ball bouncing, paddle hits, and score changes.\n",
+ "4. Visuals: The game should have a clean and simple visual design, with a clear game area and easy-to-read score display.\n",
+ "5. Smooth animation: The game should have smooth and consistent animation, with no lag or stuttering.\n",
+ "6. Adjustable difficulty: The game should have adjustable difficulty levels, such as increasing the speed of the ball or the opponents' paddle movement.\n",
+ "7. Multiplayer support: The game should have support for multiplayer mode, where two players can play against each other on the same device.\n",
+ "8. High score tracking: The game\n",
+ "\u001b[00m\n",
+ "\u001b[1m\u001b[92m [DEBUG]: == [Product Manager] Task output: **Gameplay Requirements:**\n",
+ "\n",
+ "1. The game should be played between two players, one on each side of the screen.\n",
+ "2. The game should start with a serve, where one player serves the ball to the other player.\n",
+ "3. The players should be able to move their paddles up and down to hit the ball.\n",
+ "4. The ball should bounce off the paddles and the walls of the game area.\n",
+ "5. The game should keep track of the score, with a point awarded to the player who wins a rally.\n",
+ "6. The game should have a maximum score limit, such as 11 points, and the player who reaches this limit first wins the game.\n",
+ "7. The game should have a reset feature to start a new game.\n",
+ "\n",
+ "**Game Features:**\n",
+ "\n",
+ "1. Simple and intuitive controls: The game should be easy to play, with simple and intuitive controls for moving the paddles.\n",
+ "2. Realistic ball physics: The ball should behave realistically, with accurate bouncing and movement.\n",
+ "3. Sound effects: The game should have sound effects for the ball bouncing, paddle hits, and score changes.\n",
+ "4. Visuals: The game should have a clean and simple visual design, with a clear game area and easy-to-read score display.\n",
+ "5. Smooth animation: The game should have smooth and consistent animation, with no lag or stuttering.\n",
+ "6. Adjustable difficulty: The game should have adjustable difficulty levels, such as increasing the speed of the ball or the opponents' paddle movement.\n",
+ "7. Multiplayer support: The game should have support for multiplayer mode, where two players can play against each other on the same device.\n",
+ "8. High score tracking: The game should track and display the highest scores achieved by players.\n",
+ "\n",
+ "\u001b[00m\n",
+ "\u001b[1m\u001b[95m [DEBUG]: == Working Agent: Software Developer\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "Based on the information provided, the ping pong game will require the following features and gameplay mechanics:\n",
+ "\n",
+ "1. Multiplayer Mode: The game should support multiplayer mode, allowing players to compete against each other either locally or online.\n",
+ "\n",
+ "2. Single Player Mode: In addition to multiplayer mode, there should be a single-player mode where players can practice against AI opponents of varying difficulty levels.\n",
+ "\n",
+ "3. Customization Options: Players should have the ability to customize their paddle and ball designs, as well as choose from different table designs.\n",
+ "\n",
+ "4. Scoring System: The game should have a clear and intuitive scoring system, with points awarded based on successful rallies and winning rounds.\n",
+ "\n",
+ "5. Physics Engine: The gameplay mechanics should be realistic and responsive, with a physics engine that accurately simulates the movement of the paddle and ball.\n",
+ "\n",
+ "6. Power-Ups: To add an element of excitement and strategy to the game, power-ups can be included that provide temporary advantages to the player who collects them.\n",
+ "\n",
+ "7. Online Leaderboard: To encourage competition and engagement, an online leaderboard can be implemented to track players' high scores and rankings.\n",
+ "\n",
+ "8. Tutorial Mode: For new players or those unfamiliar with ping pong, a tutorial mode can be included to teach the basics of the game and help them improve their skills.\n",
+ "\n",
+ "By including these features and gameplay mechanics, the ping pong game will offer a fun and immersive experience for players of all skill levels.\n",
+ "\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "The user interface for the ping pong game will feature a sleek and user-friendly design, with clear and intuitive navigation elements. The main screen will display options for single player, multiplayer, settings, and high scores. Within the game, players will have access to controls for moving their paddle up and down using the arrow keys or swipe gestures on touch devices. Additionally, there will be buttons for starting and pausing the game, as well as adjusting the speed and difficulty settings. Visual cues such as score display, ball trajectory, and power-up indicators will enhance the overall gaming experience. Overall, the user interface and controls are designed to provide a seamless and enjoyable gameplay experience for users of all skill levels.\n",
+ "\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "After reviewing the code for the ping pong game, I have the following feedback:\n",
+ "\n",
+ "1. The overall structure of the code is well organized and easy to follow. The use of functions for different game features such as ball movement, paddle control, and scoring is a good approach.\n",
+ "\n",
+ "2. However, I noticed that there are some areas where the code could be optimized for better performance. For example, the collision detection algorithm could be improved to reduce lag during gameplay.\n",
+ "\n",
+ "3. Additionally, I would recommend adding comments throughout the code to explain the purpose of each section and make it easier for other developers to understand and maintain the code in the future.\n",
+ "\n",
+ "4. It would also be beneficial to conduct thorough testing of the game to ensure that all features are functioning as expected and there are no bugs or glitches present.\n",
+ "\n",
+ "Overall, the code for the ping pong game is a good start, but there are areas for improvement to enhance the performance and usability of the game. Keep up the good work and continue refining the code for a better user experience.\n",
+ "\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "Based on the information provided, the ping pong game will require the following features and gameplay mechanics:\n",
+ "\n",
+ "1. Multiplayer Mode: The game should support multiplayer mode, allowing players to compete against each other either locally or online.\n",
+ "\n",
+ "2. Single Player Mode: In addition to multiplayer mode, there should be a single-player mode where players can practice against AI opponents of varying difficulty levels.\n",
+ "\n",
+ "3. Customization Options: Players should have the ability to customize their paddle and ball designs, as well as choose from different table designs.\n",
+ "\n",
+ "4. Scoring System: The game should have a clear and intuitive scoring system, with points awarded based on successful rallies and winning rounds.\n",
+ "\n",
+ "5. Physics Engine: The gameplay mechanics should be realistic and responsive, with a physics engine that accurately simulates the movement of the paddle and ball.\n",
+ "\n",
+ "6. Power-Ups: To add an element of excitement and strategy to the game, power-ups can be included that provide temporary advantages to the player who collects them.\n",
+ "\n",
+ "7. Online Leaderboard: To encourage competition and engagement, an online leaderboard can be implemented to track players' high scores and rankings.\n",
+ "\n",
+ "8. Tutorial Mode: For new players or those unfamiliar with ping pong, a tutorial mode can be included to teach the basics of the game and help them improve their skills.\n",
+ "\n",
+ "By including these features and gameplay mechanics, the ping pong game will offer a fun and immersive experience for players of all skill levels.\n",
+ "\u001b[00m\n",
+ "\u001b[95m \n",
+ "\n",
+ "The user interface for the ping pong game will feature a sleek and user-friendly design, with clear and intuitive navigation elements. The main screen will display options for single player, multiplayer, settings, and high scores. Within the game, players will have access to controls for moving their paddle up and down using the arrow keys or swipe gestures on touch devices. Additionally, there will be buttons for starting and pausing the game, as well as adjusting the speed and difficulty settings. Visual cues such as score display, ball trajectory, and power-up indicators will enhance the overall gaming experience. Overall, the user interface and controls are designed to provide a seamless and enjoyable gameplay experience for users of all skill levels.\n",
+ "\u001b[00m\n",
+ "\u001b[1m\u001b[92m [DEBUG]: == [Software Developer] Task output: ```\n",
+ "import pygame\n",
+ "import random\n",
+ "\n",
+ "# Initialize Pygame\n",
+ "pygame.init()\n",
+ "\n",
+ "# Set up some constants\n",
+ "WIDTH, HEIGHT = 640, 480\n",
+ "PADDLE_WIDTH, PADDLE_HEIGHT = 10, 100\n",
+ "BALL_SIZE = 10\n",
+ "FPS = 60\n",
+ "\n",
+ "# Set up some colors\n",
+ "WHITE = (255, 255, 255)\n",
+ "BLACK = (0, 0, 0)\n",
+ "\n",
+ "# Set up the display\n",
+ "screen = pygame.display.set_mode((WIDTH, HEIGHT))\n",
+ "\n",
+ "# Set up the clock\n",
+ "clock = pygame.time.Clock()\n",
+ "\n",
+ "# Set up the paddles\n",
+ "paddle1 = pygame.Rect(0, 0, PADDLE_WIDTH, PADDLE_HEIGHT)\n",
+ "paddle2 = pygame.Rect(WIDTH - PADDLE_WIDTH, 0, PADDLE_WIDTH, PADDLE_HEIGHT)\n",
+ "\n",
+ "# Set up the ball\n",
+ "ball = pygame.Rect(WIDTH / 2, HEIGHT / 2, BALL_SIZE, BALL_SIZE)\n",
+ "ball_x_speed = 5\n",
+ "ball_y_speed = 5\n",
+ "\n",
+ "# Set up the score\n",
+ "score1 = 0\n",
+ "score2 = 0\n",
+ "\n",
+ "# Game loop\n",
+ "while True:\n",
+ " # Handle events\n",
+ " for event in pygame.event.get():\n",
+ " if event.type == pygame.QUIT:\n",
+ " pygame.quit()\n",
+ " sys.exit()\n",
+ "\n",
+ " # Move the paddles\n",
+ " keys = pygame.key.get_pressed()\n",
+ " if keys[pygame.K_w]:\n",
+ " paddle1.y -= 5\n",
+ " if keys[pygame.K_s]:\n",
+ " paddle1.y += 5\n",
+ " if keys[pygame.K_UP]:\n",
+ " paddle\n",
+ "\n",
+ "\u001b[00m\n",
+ "######################\n",
+ "```\n",
+ "import pygame\n",
+ "import random\n",
+ "\n",
+ "# Initialize Pygame\n",
+ "pygame.init()\n",
+ "\n",
+ "# Set up some constants\n",
+ "WIDTH, HEIGHT = 640, 480\n",
+ "PADDLE_WIDTH, PADDLE_HEIGHT = 10, 100\n",
+ "BALL_SIZE = 10\n",
+ "FPS = 60\n",
+ "\n",
+ "# Set up some colors\n",
+ "WHITE = (255, 255, 255)\n",
+ "BLACK = (0, 0, 0)\n",
+ "\n",
+ "# Set up the display\n",
+ "screen = pygame.display.set_mode((WIDTH, HEIGHT))\n",
+ "\n",
+ "# Set up the clock\n",
+ "clock = pygame.time.Clock()\n",
+ "\n",
+ "# Set up the paddles\n",
+ "paddle1 = pygame.Rect(0, 0, PADDLE_WIDTH, PADDLE_HEIGHT)\n",
+ "paddle2 = pygame.Rect(WIDTH - PADDLE_WIDTH, 0, PADDLE_WIDTH, PADDLE_HEIGHT)\n",
+ "\n",
+ "# Set up the ball\n",
+ "ball = pygame.Rect(WIDTH / 2, HEIGHT / 2, BALL_SIZE, BALL_SIZE)\n",
+ "ball_x_speed = 5\n",
+ "ball_y_speed = 5\n",
+ "\n",
+ "# Set up the score\n",
+ "score1 = 0\n",
+ "score2 = 0\n",
+ "\n",
+ "# Game loop\n",
+ "while True:\n",
+ " # Handle events\n",
+ " for event in pygame.event.get():\n",
+ " if event.type == pygame.QUIT:\n",
+ " pygame.quit()\n",
+ " sys.exit()\n",
+ "\n",
+ " # Move the paddles\n",
+ " keys = pygame.key.get_pressed()\n",
+ " if keys[pygame.K_w]:\n",
+ " paddle1.y -= 5\n",
+ " if keys[pygame.K_s]:\n",
+ " paddle1.y += 5\n",
+ " if keys[pygame.K_UP]:\n",
+ " paddle\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Telemetry with Portkey"
+ ],
+ "metadata": {
+ "id": "sbFVruJgmw6V"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Part 1: Logs\n",
+ "\n",
+ "For the above agent run, we have initiated two agents utilizing the GPT-3.5 and Llama 3 models. The detailed logs for this request are available on the Portkey dashboard, providing comprehensive insights into the activities of each agent."
+ ],
+ "metadata": {
+ "id": "RC11nOmUu5CY"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ ""
+ ],
+ "metadata": {
+ "id": "sm_p6nmRudu8"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### Part 2: Analytics\n",
+ "\n",
+ "The insights from this request can be viewed on the Portkey dashboard. We are able to infer the following:\n",
+ "\n",
+ "1. Total Tokens Used: 3.6K tokens\n",
+ "2. Total Number of Requests: 11 requests; Llama 3 (6 requests), GPT-3.5 (5 requests)\n",
+ "\n",
+ "You can also review many other metrics from the dashboards like cost, latency, etc."
+ ],
+ "metadata": {
+ "id": "FHn5JHE-uCci"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "
"
+ ],
+ "metadata": {
+ "id": "Iptb9CN3qMl8"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [],
+ "metadata": {
+ "id": "kGS2SIckIceu"
+ },
+ "execution_count": null,
+ "outputs": []
+ }
+ ]
+}