Skip to main content

Plato SDK

Project description

Plato SDK

Usage

Install the plato-sdk library

pip install plato-sdk

Set Plato api key enviornment variable

PLATO_API_KEY=

Create an enviornment and connect to it using the cdp_url

import asyncio
import os
from plato import Plato, PlatoTask
from plato.examples.doordash_tasks import all_tasks as doordash_tasks

base_prompt = """
You are a helpful assistant that can help me buy food from doordash.
start by going to {start_url}. Do not navigate to other websites.
While you can't finish the checkout process becuase you need user permission,
you can add items to cart and see the total price. Do not end the task until you have added the necessary items to cart.
Here is the task:
{prompt}

Make sure to complete the checkout process once you've added the necessary items to cart.
The task is not complete until the order is sent and paid for.
You do not need my permission to and place an order.
"""

async def run_task(client: Plato, task: PlatoTask):
    env = await client.make_environment(task.env_id, open_page_on_start=False)

    await env.wait_for_ready()
    await env.reset(task)

    cdp_url = await env.get_cdp_url()

    prompt = base_prompt.format(start_url=task.start_url, prompt=task.prompt)

    # live view url to watch live
    live_view_url = await env.get_live_view_url()
    print(f"Live view URL: {live_view_url}")


    try:
        # connect agent and run
        await YourAgent.run(cdp_url, prompt)

        result = await env.evaluate()
        print(f"Evaluation result: {result}")

    except Exception as e:
        print(f"Error: {e}")
    finally:
        await env.close()


async def main():
    client = Plato(api_key=os.environ.get("PLATO_API_KEY"))
    for task in doordash_tasks:
        await run_task(client, task)


if __name__ == "__main__":
    asyncio.run(main())

State mutations

State mutations returns the diffs of all modified fields

# add item to cart
...

state_mutations: dict = env.get_state()

This returns a JSON object like this:

{
    "success": true,
    "state": {
        "added": {},
        "removed": {},
        "modified": {
            "detailed_carts": {
                "old": [],
                "new": [
                    {
                        "id": "5b227ce7-d0e9-47af-93c4-d8acfc5134d3",
                        "hasError": null,
                        "isConsumerPickup": false,
                        "isConvenienceCart": false,
                        "isPrescriptionDelivery": false,
                        "prescriptionStoreInfo": null,
                        "isMerchantShipping": false,
                        "offersDelivery": true,
                        "offersPickup": true,
                        "subtotal": 1499,
                        "urlCode": null,
                        "groupCart": false,
                        "groupCartType": null,
                        "groupCartPollInterval": null,
                        "isCatering": false,
                        "isSameStoreCatering": null,
                        "isBundle": false,
                        "bundleType": null,
                        "fulfillmentType": null,
                        "originalBundleOrderCartId": null,
                        "cartStatusType": null,
                        "cateringInfo": null,
                        "shortenedUrl": null,
                        "maxIndividualCost": null,
                        "serviceRateMessage": null,
                        "isOutsideDeliveryRegion": null,
                        "currencyCode": null,
                        "asapMinutesRange": null,
                        "orderTimeAvailability": null,
                        "menu": {
                            "id": "20016546",
                            "hoursToOrderInAdvance": null,
                            "name": null,
                            "minOrderSize": null,
                            "isCatering": false,
                            "typename": "Menu"
                        },
                        "creator": {
                            "id": "56349731",
                            "firstName": "Rob",
                            "lastName": "Farlow",
                            "localizedNames": {
                                "informalName": "Rob",
                                "formalName": "Rob Farlow",
                                "formalNameAbbreviated": "Rob F",
                                "typename": "LocalizedNames"
                            },
                            "typename": "OrderCartCreator"
                        },
                        "deliveries": null,
                        "submittedAt": null,
                        "restaurant": {
                            "id": "24770143",
                            "name": "Popstar shawarma",
                            "maxOrderSize": 0,
                            "coverImgUrl": "https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1200,height=672,format=auto/https://doordash-static.s3.amazonaws.com/media/restaurant/cover/12699cb8-d1bf-469e-8c5b-4da529838942.jpg",
                            "businessHeaderImgUrl": "https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1200,height=672,format=auto/https://doordash-static.s3.amazonaws.com/media/store/header/3eed46fc-3637-47fa-9378-e5848e125798.jpg",
                            "coverSquareImgUrl": "https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1200,height=672,format=auto/https://doordash-static.s3.amazonaws.com/media/restaurant/cover_square/f8e23996-e307-42b7-859e-3e96b954d8a7.PNG",
                            "squareCoverImgUrl": null,
                            "slug": null,
                            "address": {
                                "printableAddress": null,
                                "street": "91 6th Street",
                                "lat": 37.781284,
                                "lng": -122.40871,
                                "city": "San Francisco",
                                "state": "CA",
                                "postalCode": null,
                                "country": null,
                                "displayAddress": "91 6th St, San Francisco, CA 94103, USA",
                                "typename": "Address"
                            },
                            "business": {
                                "id": "11490330",
                                "name": "Popstar shawarma",
                                "typename": "Business"
                            },
                            "orderProtocol": null,
                            "idealGroupSize": null,
                            "highQualitySubtotalThreshold": null,
                            "shouldShowStoreLogo": null,
                            "isConsumerSubscriptionEligible": null,
                            "bulkSubstitutionPreference": null,
                            "merchantPromotions": null,
                            "requiresCheckIn": null,
                            "offersPackageReturns": false,
                            "snapMerchantId": null,
                            "typename": "Restaurant"
                        },
                        "storeDisclaimers": [],
                        "orders": [
                            {
                                "id": "62df4926-0c9e-4111-a60e-9cb0ccf8b69f",
                                "consumer": {
                                    "id": "56349731",
                                    "firstName": "Rob",
                                    "lastName": "Farlow",
                                    "localizedNames": {
                                        "informalName": "Rob",
                                        "formalName": "Rob Farlow",
                                        "formalNameAbbreviated": "Rob F",
                                        "typename": "LocalizedNames"
                                    },
                                    "typename": "OrderConsumer"
                                },
                                "isSubCartFinalized": false,
                                "orderItems": [
                                    {
                                        "id": "395040ed-40fc-47d7-9076-77141afd26a8",
                                        "options": [],
                                        "cartItemStatusType": "CART_ITEM_STATUS_TYPE_UNSPECIFIED",
                                        "nestedOptions": "[]",
                                        "specialInstructions": "",
                                        "substitutionPreference": "substitute",
                                        "quantity": 1,
                                        "singlePrice": null,
                                        "priceOfTotalQuantity": 1499,
                                        "priceDisplayString": "$14.99",
                                        "nonDiscountPriceDisplayString": null,
                                        "continuousQuantity": null,
                                        "unit": "ea",
                                        "purchaseType": "PURCHASE_TYPE_UNIT",
                                        "estimatedPricingDescription": "",
                                        "increment": null,
                                        "discounts": null,
                                        "item": {
                                            "id": "7559717819",
                                            "imageUrl": "https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1200,height=672,format=auto/https://doordash-static.s3.amazonaws.com/media/photosV2/895bfa37-0194-46f5-97ad-88edc728e5e8-retina-large.jpg",
                                            "name": "1. Chicken Sarookh Wrap",
                                            "price": 1499,
                                            "minAgeRequirement": 0,
                                            "restrictionInfo": null,
                                            "category": {
                                                "title": "",
                                                "typename": "OrderCartItemCategory"
                                            },
                                            "extras": null,
                                            "itemTagsList": [],
                                            "typename": "OrderCartItem"
                                        },
                                        "bundleStore": null,
                                        "giftInfo": null,
                                        "badges": null,
                                        "nudgeList": null,
                                        "promoNudgeList": null,
                                        "restrictionInfo": null,
                                        "isRoutineReorderEligible": false,
                                        "itemLevelDiscountMonetaryFields": {
                                            "currency": null,
                                            "displayString": null,
                                            "decimalPlaces": null,
                                            "unitAmount": null,
                                            "__typename": "AmountMonetaryFields"
                                        },
                                        "typename": "OrderItem"
                                    }
                                ],
                                "paymentCard": null,
                                "paymentLineItems": null,
                                "isOrderRoutineReorderEligible": false,
                                "typename": "Order"
                            }
                        ],
                        "selectedDeliveryOption": null,
                        "teamAccount": null,
                        "total": 1918,
                        "totalBeforeDiscountsAndCredits": 1499,
                        "footerDetails": null,
                        "orderQualityInfo": null,
                        "discountBannerDetails": [],
                        "shouldApplyCredits": true,
                        "invalidItems": null,
                        "domain": null,
                        "containsAlcohol": false,
                        "foodAlcoholConstraintCartLevel": null,
                        "commissionMessage": null,
                        "scheduledDeliveryAvailable": false,
                        "enableNewScheduleAheadUi": false,
                        "deliveryOptionsUiConfig": null,
                        "preselectedOptionUpdate": null,
                        "isDigitalWalletAllowed": false,
                        "isPreTippable": true,
                        "hideSalesTax": false,
                        "paymentProtocol": null,
                        "merchantShippingDayRangeString": null,
                        "merchantShippingDetails": null,
                        "totalCreditsAvailable": null,
                        "creditsApplicableBeforeTip": false,
                        "creditsApplicableBeforeTipDetails": null,
                        "showAccessibilityCompliance": false,
                        "totalSavings": null,
                        "taxAmount": null,
                        "tipAmount": null,
                        "merchantTipAmount": null,
                        "tipPercentageArgument": null,
                        "dasherFee": null,
                        "overauthTotal": null,
                        "legislativeFeeDetails": [],
                        "deliveryFee": null,
                        "deliveryFeeDetails": null,
                        "appliedServiceFee": null,
                        "minOrderFee": null,
                        "minOrderSubtotal": null,
                        "adsVertical": null,
                        "asapTimeRange": null,
                        "asapPickupTimeRange": null,
                        "asapNumMinutesUntilClose": null,
                        "asapPickupNumMinutesUntilClose": null,
                        "extraSosDeliveryFee": null,
                        "fulfillsOwnDeliveries": false,
                        "asapDeliveryOverrideTitle": null,
                        "asapDeliveryAvailable": true,
                        "asapPickupAvailable": true,
                        "scheduledDeliveryOptionQuoteMessage": null,
                        "bundleDetails": null,
                        "deliveryOptions": [],
                        "minAgeRequirement": null,
                        "selfDeliveryType": null,
                        "serviceRateDetails": null,
                        "providesExternalCourierTracking": false,
                        "routineReorderTimeSlots": [],
                        "routineReorderWeekIntervals": [],
                        "supplementalPaymentEligibleAmountsList": [],
                        "supplementalAuthorizedPaymentDetailsList": [],
                        "menuOptions": [],
                        "storeOrderCarts": [],
                        "consumerPromotion": null,
                        "allConsumerPromotion": null,
                        "discountDetails": null,
                        "expenseOrderOptions": null,
                        "companyPaymentInfo": null,
                        "paymentProfileType": null,
                        "creditsBackDetails": null,
                        "isDashpassApplied": false,
                        "pricingQuoteId": null,
                        "ageRestrictedIdVerificationInfo": null,
                        "signatureRequired": false,
                        "messagesAndBanners": null,
                        "appliedMxLoyaltyRewards": null,
                        "lineItemTooltipData": [],
                        "eligibleSubscription": null,
                        "recurringDeliveryDetails": null,
                        "loyaltyPointsSummary": null,
                        "differentialPricingDetails": null,
                        "applicableMxLoyaltyRewards": null,
                        "applicableExternalGiftCardDetails": null,
                        "asapDeliveryOverrideSubtitle": null,
                        "typename": "OrderCart"
                    }
                ]
            }
        }
    }
}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plato_sdk-1.1.14.tar.gz (13.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

plato_sdk-1.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.14-cp312-cp312-macosx_15_0_universal2.whl (10.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ universal2 (ARM64, x86-64)

plato_sdk-1.1.14-cp312-cp312-macosx_15_0_arm64.whl (10.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

plato_sdk-1.1.14-cp312-cp312-macosx_13_0_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.12macOS 13.0+ x86-64

plato_sdk-1.1.14-cp312-cp312-macosx_13_0_universal2.whl (10.7 MB view details)

Uploaded CPython 3.12macOS 13.0+ universal2 (ARM64, x86-64)

plato_sdk-1.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.14-cp311-cp311-macosx_15_0_universal2.whl (10.1 MB view details)

Uploaded CPython 3.11macOS 15.0+ universal2 (ARM64, x86-64)

plato_sdk-1.1.14-cp311-cp311-macosx_13_0_universal2.whl (10.7 MB view details)

Uploaded CPython 3.11macOS 13.0+ universal2 (ARM64, x86-64)

plato_sdk-1.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.14-cp310-cp310-macosx_15_0_universal2.whl (10.1 MB view details)

Uploaded CPython 3.10macOS 15.0+ universal2 (ARM64, x86-64)

plato_sdk-1.1.14-cp310-cp310-macosx_13_0_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

File details

Details for the file plato_sdk-1.1.14.tar.gz.

File metadata

  • Download URL: plato_sdk-1.1.14.tar.gz
  • Upload date:
  • Size: 13.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for plato_sdk-1.1.14.tar.gz
Algorithm Hash digest
SHA256 0e8617fef58b87e03e15c47e50d7a29c53f5a9fc270ad916e3f2f57b241b5c94
MD5 b9fb49953f500f02212e3b63d253c50c
BLAKE2b-256 9668bf9cd159a258f3bb3aab190b401164bb2e90ae92ba736fe8511173685281

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e80d153120767420364603118b30dffb4a10a18d5d54d1421862f79709e83981
MD5 29df27b5188361fca0dc7ca979d77aff
BLAKE2b-256 cc64e64ca217e1bf494181c5f527aa56cf37f1fcd0176c39ba75bbc97b840499

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp312-cp312-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 9b51b76e9e10a569a2d1501bb9326f28b6fae1578064956567de06e8e78c3965
MD5 e9c65a9cf6ffc93c8659b4ddfeb767da
BLAKE2b-256 8a0502755a0cfb33ca1ce7c98db731e86c7bb4640576f3a08329a42e4eb9834a

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6177c7defd969f4bd9051540c2b59d9884bcdaf43a296469d3740ef8e57d1161
MD5 640719c68bcf07b521c736e711435754
BLAKE2b-256 a7953f0e17483cb1ff5a3d6c9591c466d201528b920578724161a44667400c6f

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 42e4503160a0a227047bab8b93ef805d580f903a920a1e257253cfd1b17cd9bd
MD5 8f8b4a504e2794a578239d8085f9b5cb
BLAKE2b-256 dbb0ccd343b6753e046075447cb6bf2a6a8b42015760d90465d4860d110b0ede

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp312-cp312-macosx_13_0_universal2.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp312-cp312-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 311f81f2c0317d0fd2fd95aab6aff17b168e2b5f4130545c45a213f1c19941bb
MD5 c816ecf89e00998c9dd8913fe105a28d
BLAKE2b-256 63d4ac3f632d2d596ca0308aa1cdf28cb8a2dd9cf400663e58340ef1ae9fcb49

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f9e64e567896f3231626e3deb89326d660ee227bb0c6f59631d33624c799275
MD5 806412665b98db0a4d80b2073f6613ad
BLAKE2b-256 6d327be62b93653195a3c980d49a78c12dab44835f52dd320946cf67b8632383

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp311-cp311-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 9d8709b263124a15d556e8c5efa22f5327be0de62a961b4e22e03ec5931b319b
MD5 5965fce7af135c7d4464500ba296170c
BLAKE2b-256 a32c77b3c10e255772a7e780c38a677d306f54891efd7aeb8c7a3a14770b9768

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp311-cp311-macosx_13_0_universal2.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp311-cp311-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 d843dce562696ad0047f5f2ec391118ac82e3f2a067a3a269c662bfccd74fcf0
MD5 3c56b610fdedbe046853bda67a1873b1
BLAKE2b-256 ba37da643715e265f74ac802e46d96970abd5ceb7d0d2dd811e47079e9167123

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f85a8685adebfcb3455dfaab036af17b6cabddad83161dedc1e4e5104696c27
MD5 945dcfb0fcef08deae6c11e51ff7e1c6
BLAKE2b-256 9910f3ce293b5183db8660fe1bca09ae3ece7b47d72d643c68cc3f3814d7954d

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp310-cp310-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 37ed043499ff452659929c374f2ebbca81ee3aed40e57b296ca8fc02d6ea772a
MD5 201cbfba0dfdb2d0fd57b2f23cad0af9
BLAKE2b-256 a06713c74e427101d3f783124cf5a3b9855b1ef7f9b5f1133ff451054d380b29

See more details on using hashes here.

File details

Details for the file plato_sdk-1.1.14-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for plato_sdk-1.1.14-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 cd936de4b698fb4c3205f9e359a1af9b89eab667b89acda7ab731f9ae3f667f9
MD5 a7c5292fa0bf89fcc372e51917192835
BLAKE2b-256 b573cf76fdd7327ecfdc847ac8bd82dd1504d91487f37e22be278c8015eafcfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page