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

Uploaded CPython 3.12macOS 15.0+ ARM64

plato_sdk-1.1.3-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.3-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.3-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.3-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.3-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.3-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.3-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.3-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.3.tar.gz.

File metadata

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

File hashes

Hashes for plato_sdk-1.1.3.tar.gz
Algorithm Hash digest
SHA256 012d33c5acc7b6ccdee2c54f15ece2924a0d068c9863af23e8a6fcff9f3ead9a
MD5 a78568abb74700e3c3ccc9ce0115d773
BLAKE2b-256 f1807b78ae4cd7cb93edf72ee2d49afd697c83cce620fa19d8da0707d9cd0805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 910f710fcb49ca19ec9810bbafa209b75e1bf6e86f99b7dbf355975253148d21
MD5 290b09f2233a0427fb31f9ebb4c1c3b0
BLAKE2b-256 0fc59b8f8da06d147b30d18624cb446c776fbe33b07eaa9a196c069bb348015c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 a1a9ff889c420015200b93d6c12f80882b3cf3bfd028924d61265a7029b704b8
MD5 a2473270bec32c7eabee63c0ae71db63
BLAKE2b-256 30d1911294a8f7da1f13953a35cdacb014e77b1c04035a2bcdfe65f2891f53d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 109d6aafd6f99077fd8092b78a5cbd8fdfb523245deb929889409e828223f3f1
MD5 de2c9cbd7d6f94436e50d12140ec19b5
BLAKE2b-256 0afd42200371c97bd8cbb4d14786384532f8b68f3cb1f3285e5edca34aa39b8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 5b3d7d1d20fef2f1825cb3c3157545eb4d956828675d5bab40cdab46c6941ad8
MD5 ca7cf5282a734632c5b12fe1c329bf87
BLAKE2b-256 fc0e3b5c348bfdd8ecee0dd8a95b11450368b52b7c95fbfc4b4113960fff50ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp312-cp312-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 3613ae1aae30320685240eda8db91abaaa5f7d41aa6f5e80e0aae5af0894dcd1
MD5 eb4c569b7e2010d6cc8488d7bb7f37b5
BLAKE2b-256 c6e217ceecf265195ca301019c2b21611a56db4497c02c0753e235d64faffb08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be273abf36ddf87d85edd121cb6b58ce91c63584d3aa35558ba2b1569e6afd1b
MD5 523efefc33194624a472232e4251099a
BLAKE2b-256 772ce707b4b63b5fb4e16568f11600425b6a4a44f2b539ec874301c2f6b5fe56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 1194e304b0ce136e6ccf1cff92464c1e3fccb52c22c3ef295686f586f9629c1f
MD5 b1e2e64604a06b69e3c225c4e8aa5a0b
BLAKE2b-256 6c36f8a29275ebf8064b25b2dbb86ee77fdc225f4dc03beb04fb27d41e030e81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp311-cp311-macosx_13_0_universal2.whl
Algorithm Hash digest
SHA256 839173da5f2e1f21098bde0ca2d83154e70b23dc27508466ffc9b9d750a7aa5c
MD5 95462e05f9510339bd8c0568bbe5ab56
BLAKE2b-256 f1fa1755c7de430d329b31e6bbe4d2bd3be339435199998942a42d9807640452

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d4b9483ba0bb16edd62dba9aeaf97bc9890156903710f5b99f8c9726912dfdfa
MD5 14982b310c0c42e9d33004aaec673b36
BLAKE2b-256 48cad8738644d3444818812aeeb3f9d09a29112b92c32a1bcdf1b77b21840973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 3d65917cdb05b526ee6af2169a7c6dbbd621c3af254ba3093b36c8f9c5f9bd62
MD5 0485497bbe2171b6ad1bf1a0ec243cb8
BLAKE2b-256 f6c5354df7e9d8204c678869e8b98b082e0429c717575aaae9640e540037d8e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plato_sdk-1.1.3-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 34a5fa9834f4fedcfd3934236c2b5b448027c9c46fbe1ad75e77dd44dca07485
MD5 b9acb5929bf1e8ccd44594d80a78cf5c
BLAKE2b-256 5f82929fba8f82a7aa4d27c2a61d51a6d49edae2949b0fbccd920d5ac7334bee

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