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

Uploaded CPython 3.12macOS 15.0+ ARM64

plato_sdk-1.1.16-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.16-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.16-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.16-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.16-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.16-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.16-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.16-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.16.tar.gz.

File metadata

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

File hashes

Hashes for plato_sdk-1.1.16.tar.gz
Algorithm Hash digest
SHA256 fb45573259c39977e96eb0e6b15938da321f617f8095b77bf7d726fa3c961b60
MD5 a235f642fdedfcf510ac16a3eb58ae0a
BLAKE2b-256 92f1097629ac4d495e42a291a20c7573fc5d7a7d64e89e5fd224c267e79045e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 81c8719177508888183b2d49cab35116197d231861f5926e1de56cfdeec286c3
MD5 f16dd9f7ff9108e7c3ad0b069a1a6c46
BLAKE2b-256 bb9391031c8dd9ff2c12fc85ceb50b51040d23ca8c9d2ba628be47b0ff6d81c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 3b903ed82e995d4d232bbee18b71c34847b0ea6d0b557ca66f053365c56a6e14
MD5 fb5270f83835348580e0d54e05cd63f9
BLAKE2b-256 cb23544bdeb4142ba0d8f6012b81393f03658fd330f27531dddc49dba15c5bb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 be03cbf5b3c08d6f5298b1dbeb82f31e254fd776df0f679dfc6343996468ede2
MD5 4e8086b1c2a3569df60165c661c71585
BLAKE2b-256 3294b3345d3c8f138235c877f8ffa0514004eb72c9502e8a0d86453432096d51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 f395bb675224b8f2eb8127bd51e1f7d4c3e65e0e971043a57062ffa68882accf
MD5 5f3f8643c2e95aee6b569e64b250e27a
BLAKE2b-256 f76bde27029c3323730d527405934beae2db7caddbd1bac0c1d4e9afc6b7ff10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp312-cp312-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 3a2473d1240ce6c723aadbf9e2f95e39dcdbc328913f3dc08de4bd51a8d00712
MD5 51c95f83f15439b7e4408352d172f47e
BLAKE2b-256 4bf1aeda0adf1fe200d2fd0c6982f5864d8a8b99cdea0ce212d0ba4a792b8395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9bf6d610351926fe6b947b385df14619f96ba4c14f660b4a66222809232f3f36
MD5 7bd6beb0a98bdcd253c04949bb27e9a2
BLAKE2b-256 ea0149a5c0b5f94f3c0390a62c953ae65c3f41ad18b616558f053eabf759b5b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 e6f3de630cf35bdf53227bcf179efc2c361b7f5784ab38d05494fe56605effd8
MD5 7e8bf68b68ae45ab5e0cdd7eb40262cf
BLAKE2b-256 fec279535e3766033e4d05af31ec87f3926f0f0fcbce208e75a9a7e5994e1d1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp311-cp311-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 746e5fe0fbf7b67a8a09073c2b54a336836fe0abe1c5052f8869d07173531bdb
MD5 bb5348992c5ae501915d80599af52733
BLAKE2b-256 94e1574f05d1b05eb077db76022dd77a525989ee3f74fc0586945a737ad7c30f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d68e82a29677f15d2524237fc14cb3755797cb326d5fc65b1a999a78485b681
MD5 08fa3b598a2995d89246bf5547839ec4
BLAKE2b-256 5beb3c952a121aef7fdb6d53130b53e3bb9b019c195d1cf8c32b834fdb758a05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 2e68a12125b8ee1853f8b45279a6ca9dc0c40fcd5744b40d6d4357e4436e2631
MD5 0b512f71e014671f873aface61c492cc
BLAKE2b-256 1b16ffbc98f68c0a408abce4f72560c5b38e7e27d12e7fffe3d76c31b2745f05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.16-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 4081ba21791657c3b3c248ad688993337f33102cce83ee6a1cb435882f344ee2
MD5 b663e8588c824cd39d49effa1fecf16f
BLAKE2b-256 a17dcde00bef7b1cdff0a598d62ad791e1a7d2337128a42fdd4948b02d77adb8

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