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

Uploaded CPython 3.12macOS 15.0+ ARM64

plato_sdk-1.1.8-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.8-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.8-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.8-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.8-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.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

plato_sdk-1.1.8-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.8-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.8.tar.gz.

File metadata

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

File hashes

Hashes for plato_sdk-1.1.8.tar.gz
Algorithm Hash digest
SHA256 0bb344353d039ed3a8757ec99651cab29b9b0b8b68adcd6fc6650e6c50a52a69
MD5 960d72bd698ceb47f0131e8bdd8f52d8
BLAKE2b-256 04c1ce8ad0568e1a769431ddde0476482703580b84e8dc3c43fe8d97e7b3a9ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d3385bbae9795099acaf883c14b6ab2eb489aa430cc7d53ec0a410e64e28794
MD5 41df73b18deeb76511a38af1aed1ea9e
BLAKE2b-256 41d160cd56acbb56eb436062570995c2c61c2b8fec3f784b4e84cf3dd3c7e958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 63a5b0b381b195ca4ce78695fecd7a6865a5b32d49f15b0bbf3fa967ccf6408f
MD5 98a1bd106fce96daad325efdd3cf401d
BLAKE2b-256 2640e5cb0f7dfe4a702b4bcea52958c647d9a8b8cd0a0025f3f9161e7ae6ef0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3dfbe29195c7bc8ddc2af4a0eb1a830754117018bbfb86f0de2780ecb87ebeae
MD5 6579db7ca7196c0fd371af903e1182fe
BLAKE2b-256 093e7ce1c9a5cbbf37fef78f0efa702ccffd982e2df73120556b489f6ea3a63e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 40f265f69197136e2eccc1f2bb56f51418b67c00b07e761d58dde9d4594957fb
MD5 30204bb42f18b1fc02e7a614c272d78d
BLAKE2b-256 43940fd3a1340b56a60a58c5773fad199791ac186ca750633c867061888095ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp312-cp312-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 04db4e36303583896b63bce652da8bbeab19754ee58b61c4ce6969a89c34a3ad
MD5 312e7cb2d1135dac17d90c1f22fb65ae
BLAKE2b-256 d97c3bc3ce061d1f677ad63ae3e05f032e1fe1cfcde288976a816dce4771fcc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a714c1a4ec9b6e8a1875b0e6e55b212d19a3a771e5af09cb037ebf5e2085e74b
MD5 7a14ebc64209ef915950868eae409562
BLAKE2b-256 0f8ba0b135a470fe99ae3468feacbb769ba439a850b6aff38918d624b284404b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 df931a07181f9c4c3bc9b4e147577260eac7be1612c85aa9c378ab4dc59412cb
MD5 4d480fa07e4977aa4f3c2666080c159d
BLAKE2b-256 9f113490abcac1238b46e586859e26042fe1d570cd64f386aabc248d6e6400cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp311-cp311-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 f6bd89d650e0a8f2a4735d4628ba29bcfab99f197d0fa9bea3a72c29ef3502e4
MD5 d1cf80e9d0544c68624b4febea1d4cf6
BLAKE2b-256 64bcc9bdb708aa9a43386cb0cfcc813dfe9f18785869b7483127cfd78732b616

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bee74b725596bcdd089a60516846847278af2552110d07ef404c8d8d17cbc3e2
MD5 720fb7737a65ac51b7de3b549db00f42
BLAKE2b-256 a4702c22986d00191bdc57aa9fd23af467ec18bffeb81b103befe46b19c5b809

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 d17551171979dc20b7d57125455af3158bd1a41a6577fc36bb25a2620c541b11
MD5 0546c899f449ac49acfcd919a86e6f25
BLAKE2b-256 05d9e8510f1e728ad8b0524b51466091ed63d82de99c4b3bd5e6379f0fbe2a84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.8-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 d05a6f66efd9b3e1528d38e2a0aa9ee87ce5b84902f8b64c7ccf216a8123ad38
MD5 21f191212028642d866326ad4c9aabb4
BLAKE2b-256 1cd6208d2b58a204361a33d0e727b95e5d644908419f5455f7f3daa2bb323d31

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