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.17.tar.gz (10.0 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.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.17-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.17-cp312-cp312-macosx_15_0_arm64.whl (10.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

plato_sdk-1.1.17-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.17-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.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.17-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.17-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.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.17-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.17-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.17.tar.gz.

File metadata

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

File hashes

Hashes for plato_sdk-1.1.17.tar.gz
Algorithm Hash digest
SHA256 437aad54670255bcff73844174936db02e0351e165b6fc989cde7ba9e1bb7bcc
MD5 2a392e25d03d9895c846ffe17e4f1eab
BLAKE2b-256 b2959244de22b6bc1179ba892e9a3ad93e1ddf120dc6cbe1573b5bba26e51ebb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13367070418c1bf1ddbb17c922b6c87b223c31cf16e92a7052bf4d0af4a86924
MD5 6be43672b023625d9713882afef7a6a6
BLAKE2b-256 80f41e5f8ddcd88fa67e1c371df534cee307b6481bf5a612cb8335a5d936b5de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 db0f229fbda162aa671713a93d8e440bad1f6b35c7067d059b1034eee70c9332
MD5 1da227dc47e375a10403979b7276ba42
BLAKE2b-256 6c3843bee2f9d31d1712f2e5990f2c9f5227b4d793fb878c6a3462252e34bcc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2ac71514eae346120496568dd85726e3f1fa61824b7f842ee5603d5c236be898
MD5 dae952e7e38cf5b9a5171bfbf5dd1ffb
BLAKE2b-256 fe2caa456c10a80a945576c5edbbafb2904f1bb973f07036771b3cece15fb12c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 8724a7bbc054b2bc049933b09a616da2dfc07190b80a6285671b2307351dc8b8
MD5 d734f9e800daf4aead3a8c723e2618b7
BLAKE2b-256 27d7dfb77c1ad1dd2f09b982a25ad535205e9fc6384ce7324613cdbb159486f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp312-cp312-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 0e456b82a5410c4cc4ccbdc49d705d4929743c956e6ddda05c96d065d0484720
MD5 6c673cbda6c9b501f9ce4fe547b5dadc
BLAKE2b-256 a338d89ca479a93ac2796e4617f241ccef96e2f9b9c5f1b1fc2f2d523188c15f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84b774335e9b77cdb8b8ed496a6f97e5f2f0bdf981132e2c1bd4b41ba4d58074
MD5 1ebcfbd97f8ac5e7fadc8ebd7b0f3c4c
BLAKE2b-256 e6713decbba121168cef0ae0cd54cbc57d36fa643127bfe78bda202d607411fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 95dab84eda9d3442cff95208069589a61a0aae4ee510de68c0a976f7f3324e02
MD5 612ef7d06739c033c8f994671d51648f
BLAKE2b-256 97eb19bb929d96fef91284086b0d3113e6550af5ba55cd615d31617137c4f076

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp311-cp311-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 875b9d5808f9a40eed7a32d1e5e4a75ce58fb149946ca2946e04fc61b4fc4f08
MD5 c0973dcddb0a577de7576911aa3ea025
BLAKE2b-256 29ae0820ed1d4068d2d7e2fcb33a94a6fb0124e5ff21ecfbe37c62b72ab0c13c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e9ef64885502ab0f5cb9cc39dd9090673058219529b1b6c93817fdc4326cd4a
MD5 33073a5ae7f882c828f2bf7c9ac32e8c
BLAKE2b-256 dcbaf3f88c7800dcb67fc46878f3907325807fb9d4ee3deb101c9974bed12bb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 1884e48da80eda7e96f353a0494c4eb75f3bc464a6ea13c1f1a461661ee6690f
MD5 4508db31b3e7c209f0026f571fd87a32
BLAKE2b-256 33540dfc87af5683ccccb65d0b8b689be0be762f5641aeeee9797ac632a93018

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.17-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 16937abdcdb81e8822dfab077a761727961ab96272f2eb1f209bb6783b3ae904
MD5 09a846b621083707d479ada2118757a3
BLAKE2b-256 c444dd30539077bd20708dac91422ddf51384ef6da03ea578bd909842bff85e7

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