{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "5c9cf754", "metadata": {}, "outputs": [], "source": [ "import modal" ] }, { "cell_type": "code", "execution_count": 6, "id": "a73b738f", "metadata": {}, "outputs": [], "source": [ "import modal\n", "\n", "app = modal.App(\"example-get-started\")\n", "\n", "\n", "@app.function()\n", "def square(x):\n", " print(\"This code is running on a remote worker!\")\n", " return x**2\n", "\n", "\n", "@app.local_entrypoint()\n", "def main():\n", " print(\"the square is\", square.remote(42))\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "f8653ac7", "metadata": {}, "outputs": [], "source": [ "from hello import app, hello" ] }, { "cell_type": "code", "execution_count": null, "id": "ae58c3a8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Hello from Delhi, Delhi, IN!!'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from hello import app, hello\n", " reply=hello.local()\n", "reply" ] }, { "cell_type": "code", "execution_count": 4, "id": "9f178389", "metadata": {}, "outputs": [], "source": [ "from llama import app, generate" ] }, { "cell_type": "code", "execution_count": 5, "id": "03715973", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "925d0142b2374a918fd8fd170c415ac1", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
✓ Initialized. View run at https://modal.com/apps/ankushmehta243/main/ap-eokiQPPBn1jbB7S6coAKUc\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m Initialized. \u001b[38;5;249mView run at \u001b[0m\u001b[4;38;5;249mhttps://modal.com/apps/ankushmehta243/main/ap-eokiQPPBn1jbB7S6coAKUc\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e292ee898b494254bd851d0d770ec240", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
✓ Created objects.\n", "├── 🔨 Created mount c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\llama.py\n", "└── 🔨 Created function generate.\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m Created objects.\n", "\u001b[38;5;244m├── \u001b[0m🔨 Created mount c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\llama.py\n", "\u001b[38;5;244m└── \u001b[0m🔨 Created function generate.\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b68bee6063054b938ec071da309fba60", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 0%| | 0/4 [00:00<?, ?it/s]
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 0%| | 0/4 [00:00, ?it/s]\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 25%|██▌ | 1/4 [01:04<03:14, 64.67s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 25%|██▌ | 1/4 [01:04<03:14, 64.67s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 75%|███████▌ | 3/4 [01:04<00:16, 16.89s/it]Fetching 4 files: 100%|██████████| 4/4 [01:04<00:00, 16.25s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 75%|███████▌ | 3/4 [01:04<00:16, 16.89s/it]Fetching 4 files: 100%|██████████| 4/4 [01:04<00:00, 16.25s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 0%| | 0/4 [00:00<?, ?it/s]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 0%| | 0/4 [00:00, ?it/s]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 25%|██▌ | 1/4 [00:04<00:14, 4.72s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 25%|██▌ | 1/4 [00:04<00:14, 4.72s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 50%|█████ | 2/4 [00:09<00:09, 4.95s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 50%|█████ | 2/4 [00:09<00:09, 4.95s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 75%|███████▌ | 3/4 [00:15<00:05, 5.09s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 75%|███████▌ | 3/4 [00:15<00:05, 5.09s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 100%|██████████| 4/4 [00:15<00:00, 3.25s/it]Loading checkpoint shards: 100%|██████████| 4/4 [00:15<00:00, 3.88s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 100%|██████████| 4/4 [00:15<00:00, 3.25s/it]Loading checkpoint shards: 100%|██████████| 4/4 [00:15<00:00, 3.88s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"
\n"
],
"text/plain": [
"\u001b[31mSetting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Stopping app - local entrypoint completed.\n",
"
\n"
],
"text/plain": [
"\u001b[33mStopping app - local entrypoint completed.\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"✓ App completed. View run at https://modal.com/apps/ankushmehta243/main/ap-eokiQPPBn1jbB7S6coAKUc\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m App completed. \u001b[38;5;249mView run at \u001b[0m\u001b[4;38;5;249mhttps://modal.com/apps/ankushmehta243/main/ap-eokiQPPBn1jbB7S6coAKUc\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "'<|begin_of_text|>Life is a mystery, everyone must stand alone, I hear you call my name,'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with modal.enable_output():\n", " with app.run():\n", " result=generate.remote(\"Life is a mystery, everyone must stand alone, I hear\")\n", "result" ] }, { "cell_type": "code", "execution_count": 6, "id": "eaf47ba6", "metadata": {}, "outputs": [], "source": [ "from pricer_ephemeral import app, price" ] }, { "cell_type": "code", "execution_count": 7, "id": "3e3cbdc8", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "49883cadfa514f4ba03efc3da05fe68f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
✓ Initialized. View run at https://modal.com/apps/ankushmehta243/main/ap-zYROHiEK5Vkuc6Nxdjt8Wj\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m Initialized. \u001b[38;5;249mView run at \u001b[0m\u001b[4;38;5;249mhttps://modal.com/apps/ankushmehta243/main/ap-zYROHiEK5Vkuc6Nxdjt8Wj\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "bd86728bceb1457981c92613dfdf95c2", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
✓ Created objects.\n", "├── 🔨 Created mount c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_ephemeral.py\n", "└── 🔨 Created function price.\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m Created objects.\n", "\u001b[38;5;244m├── \u001b[0m🔨 Created mount c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_ephemeral.py\n", "\u001b[38;5;244m└── \u001b[0m🔨 Created function price.\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "61caea8dea2847259e00ba021d6fff52", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 0%| | 0/4 [00:00<?, ?it/s]
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 0%| | 0/4 [00:00, ?it/s]\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 25%|██▌ | 1/4 [00:58<02:56, 58.99s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 25%|██▌ | 1/4 [00:58<02:56, 58.99s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 50%|█████ | 2/4 [01:01<00:51, 25.66s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 50%|█████ | 2/4 [01:01<00:51, 25.66s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1AFetching 4 files: 100%|██████████| 4/4 [01:01<00:00, 15.34s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1AFetching 4 files: 100%|██████████| 4/4 [01:01<00:00, 15.34s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"
\n"
],
"text/plain": [
"\u001b[31m\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 0%| | 0/4 [00:00<?, ?it/s]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 0%| | 0/4 [00:00, ?it/s]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 25%|██▌ | 1/4 [00:04<00:12, 4.26s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 25%|██▌ | 1/4 [00:04<00:12, 4.26s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 50%|█████ | 2/4 [00:09<00:09, 4.58s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 50%|█████ | 2/4 [00:09<00:09, 4.58s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 75%|███████▌ | 3/4 [00:13<00:04, 4.68s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 75%|███████▌ | 3/4 [00:13<00:04, 4.68s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\u001b[1ALoading checkpoint shards: 100%|██████████| 4/4 [00:14<00:00, 2.99s/it]Loading checkpoint shards: 100%|██████████| 4/4 [00:14<00:00, 3.57s/it]\n",
"
\n"
],
"text/plain": [
"\u001b[31m\u001b[1ALoading checkpoint shards: 100%|██████████| 4/4 [00:14<00:00, 2.99s/it]Loading checkpoint shards: 100%|██████████| 4/4 [00:14<00:00, 3.57s/it]\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"
\n"
],
"text/plain": [
"\u001b[31mSetting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n"
],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Stopping app - local entrypoint completed.\n",
"
\n"
],
"text/plain": [
"\u001b[33mStopping app - local entrypoint completed.\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Runner terminated.\n",
"
\n"
],
"text/plain": [
"\u001b[33mRunner terminated.\n",
"\u001b[0m"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"✓ App completed. View run at https://modal.com/apps/ankushmehta243/main/ap-zYROHiEK5Vkuc6Nxdjt8Wj\n", "\n" ], "text/plain": [ "\u001b[32m✓\u001b[0m App completed. \u001b[38;5;249mView run at \u001b[0m\u001b[4;38;5;249mhttps://modal.com/apps/ankushmehta243/main/ap-zYROHiEK5Vkuc6Nxdjt8Wj\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "133.0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with modal.enable_output():\n", " with app.run():\n", " result=price.remote(\"Quadcast HyperX condenser mic, connects via usb-c to your computer for crystal clear audio\")\n", "result" ] }, { "cell_type": "code", "execution_count": 22, "id": "66706bed", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "- Creating objects...\n", "\\ Creating objects...\n", "/ Creating objects...\n", "└── - Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "/ Creating objects...\n", "└── / Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "/ Creating objects...\n", "└── / Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "/ Creating objects...\n", "└── / Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "/ Creating objects...\n", "└── / Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Uploaded \n", " 0/1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Finalizing\n", " index of 1 files\n", "/ Creating objects...\n", "└── / Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Finalizing\n", " index of 1 files\n", "\\ Creating objects...\n", "└── \\ Creating mount \n", " c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py: Finalizing\n", " index of 1 files\n", "/ Creating objects...\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── - Creating function Pricer.*...\n", "\\ Creating objects...\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── 🔨 Created function Pricer.*.\n", "/ Creating objects...\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── 🔨 Created function Pricer.*.\n", "\\ Creating objects...\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── 🔨 Created function Pricer.*.\n", "| Creating objects...\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── 🔨 Created function Pricer.*.\n", "\n", "✓ Created objects.\n", "├── 🔨 Created mount \n", "│ c:\\Users\\ANKUSH\\Desktop\\price-predictor-agent\\pricer_service.py\n", "└── 🔨 Created function Pricer.*.\n", "✓ App deployed in 7.903s! 🎉\n", "\n", "View Deployment: \n", "https://modal.com/apps/ankushmehta243/main/deployed/pricer-service\n" ] } ], "source": [ "!modal deploy -m pricer_service" ] }, { "cell_type": "code", "execution_count": 23, "id": "170d9ff0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "133.0\n" ] } ], "source": [ "Pricer = modal.Cls.from_name(\"pricer-service\", \"Pricer\")\n", "pricer = Pricer()\n", "reply = pricer.price.remote(\"Quadcast HyperX condenser mic, connects via usb-c to your computer for crystal clear audio\")\n", "print(reply)" ] }, { "cell_type": "code", "execution_count": 24, "id": "e6101ef5", "metadata": {}, "outputs": [], "source": [ "from agents.specialist_agent import SpecialistAgent" ] }, { "cell_type": "code", "execution_count": 25, "id": "aabd1bcc", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "299.0" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent = SpecialistAgent()\n", "agent.price(\"iPad Pro 2nd generation\")" ] }, { "cell_type": "code", "execution_count": null, "id": "4cb51854", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }