{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"1qtS6tFp15YuwyPaSE3rkF5f7OxBXn9f2","timestamp":1737987287948},{"file_id":"https://github.com/trancethehuman/ai-workshop-code/blob/main/Baby_step_scrape_your_first_website_and_pipe_to_an_LLM.ipynb","timestamp":1737619246569}]},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["Install Firecrawl's python package to be able to use it."],"metadata":{"id":"VoMqKuBsUd1p"}},{"cell_type":"code","source":["pip install firecrawl-py -q"],"metadata":{"id":"LM25nYrLUkuW"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**Install** gradio for the UI"],"metadata":{"id":"0WhW8WTYU1H-"}},{"cell_type":"code","source":["!pip install gradio openai"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"collapsed":true,"id":"KOlAy1nY9Lms","executionInfo":{"status":"ok","timestamp":1737987408560,"user_tz":-420,"elapsed":18347,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}},"outputId":"b8512857-dcb2-4ca1-ba94-ac4a1c39e7c1"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Collecting gradio\n"," Downloading gradio-5.13.1-py3-none-any.whl.metadata (16 kB)\n","Requirement already satisfied: openai in /usr/local/lib/python3.10/dist-packages (1.57.4)\n","Collecting aiofiles<24.0,>=22.0 (from gradio)\n"," Downloading aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)\n","Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n","Collecting fastapi<1.0,>=0.115.2 (from gradio)\n"," Downloading fastapi-0.115.7-py3-none-any.whl.metadata (27 kB)\n","Collecting ffmpy (from gradio)\n"," Downloading ffmpy-0.5.0-py3-none-any.whl.metadata (3.0 kB)\n","Collecting gradio-client==1.6.0 (from gradio)\n"," Downloading gradio_client-1.6.0-py3-none-any.whl.metadata (7.1 kB)\n","Requirement already satisfied: httpx>=0.24.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.28.1)\n","Requirement already satisfied: huggingface-hub>=0.25.1 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.27.0)\n","Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.4)\n","Collecting markupsafe~=2.0 (from gradio)\n"," Downloading MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)\n","Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.26.4)\n","Requirement already satisfied: orjson~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.10.12)\n","Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (24.2)\n","Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.2.2)\n","Requirement already satisfied: pillow<12.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (11.0.0)\n","Requirement already satisfied: pydantic>=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.10.3)\n","Collecting pydub (from gradio)\n"," Downloading pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n","Collecting python-multipart>=0.0.18 (from gradio)\n"," Downloading python_multipart-0.0.20-py3-none-any.whl.metadata (1.8 kB)\n","Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.2)\n","Collecting ruff>=0.2.2 (from gradio)\n"," Downloading ruff-0.9.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\n","Collecting safehttpx<0.2.0,>=0.1.6 (from gradio)\n"," Downloading safehttpx-0.1.6-py3-none-any.whl.metadata (4.2 kB)\n","Collecting semantic-version~=2.0 (from gradio)\n"," Downloading semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n","Collecting starlette<1.0,>=0.40.0 (from gradio)\n"," Downloading starlette-0.45.3-py3-none-any.whl.metadata (6.3 kB)\n","Collecting tomlkit<0.14.0,>=0.12.0 (from gradio)\n"," Downloading tomlkit-0.13.2-py3-none-any.whl.metadata (2.7 kB)\n","Requirement already satisfied: typer<1.0,>=0.12 in /usr/local/lib/python3.10/dist-packages (from gradio) (0.15.1)\n","Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.12.2)\n","Collecting uvicorn>=0.14.0 (from gradio)\n"," Downloading uvicorn-0.34.0-py3-none-any.whl.metadata (6.5 kB)\n","Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.6.0->gradio) (2024.10.0)\n","Requirement already satisfied: websockets<15.0,>=10.0 in /usr/local/lib/python3.10/dist-packages (from gradio-client==1.6.0->gradio) (14.1)\n","Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai) (1.9.0)\n","Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from openai) (0.8.2)\n","Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai) (1.3.1)\n","Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai) (4.67.1)\n","Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (3.10)\n","Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n","Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (2024.12.14)\n","Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx>=0.24.1->gradio) (1.0.7)\n","Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n","Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.25.1->gradio) (3.16.1)\n","Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.25.1->gradio) (2.32.3)\n","Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2.8.2)\n","Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n","Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2024.2)\n","Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (0.7.0)\n","Requirement already satisfied: pydantic-core==2.27.1 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.0->gradio) (2.27.1)\n","Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n","Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n","Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer<1.0,>=0.12->gradio) (13.9.4)\n","Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas<3.0,>=1.0->gradio) (1.17.0)\n","Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n","Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n","Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.25.1->gradio) (3.4.0)\n","Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.25.1->gradio) (2.2.3)\n","Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n","Downloading gradio-5.13.1-py3-none-any.whl (57.6 MB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.6/57.6 MB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading gradio_client-1.6.0-py3-none-any.whl (321 kB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m321.8/321.8 kB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading aiofiles-23.2.1-py3-none-any.whl (15 kB)\n","Downloading fastapi-0.115.7-py3-none-any.whl (94 kB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.8/94.8 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)\n","Downloading python_multipart-0.0.20-py3-none-any.whl (24 kB)\n","Downloading ruff-0.9.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.4/12.4 MB\u001b[0m \u001b[31m59.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading safehttpx-0.1.6-py3-none-any.whl (8.7 kB)\n","Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n","Downloading starlette-0.45.3-py3-none-any.whl (71 kB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading tomlkit-0.13.2-py3-none-any.whl (37 kB)\n","Downloading uvicorn-0.34.0-py3-none-any.whl (62 kB)\n","\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.3/62.3 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hDownloading ffmpy-0.5.0-py3-none-any.whl (6.0 kB)\n","Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n","Installing collected packages: pydub, uvicorn, tomlkit, semantic-version, ruff, python-multipart, markupsafe, ffmpy, aiofiles, starlette, safehttpx, gradio-client, fastapi, gradio\n"," Attempting uninstall: markupsafe\n"," Found existing installation: MarkupSafe 3.0.2\n"," Uninstalling MarkupSafe-3.0.2:\n"," Successfully uninstalled MarkupSafe-3.0.2\n","Successfully installed aiofiles-23.2.1 fastapi-0.115.7 ffmpy-0.5.0 gradio-5.13.1 gradio-client-1.6.0 markupsafe-2.1.5 pydub-0.25.1 python-multipart-0.0.20 ruff-0.9.3 safehttpx-0.1.6 semantic-version-2.10.0 starlette-0.45.3 tomlkit-0.13.2 uvicorn-0.34.0\n"]}]},{"cell_type":"markdown","source":["https://www.firecrawl.dev/app"],"metadata":{"id":"BFaGef1o-r4X"}},{"cell_type":"code","source":["import getpass\n","\n","FIRECRAWL_API_KEY = getpass.getpass(\"Firecrawl API Key: \")"],"metadata":{"id":"6xG5rfuZVcsx","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1737987416103,"user_tz":-420,"elapsed":2665,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}},"outputId":"701075d5-bb5e-4918-f8c0-8bb968c9dac4"},"execution_count":null,"outputs":[{"name":"stdout","output_type":"stream","text":["Firecrawl API Key: ··········\n"]}]},{"cell_type":"code","source":["from firecrawl import FirecrawlApp\n","\n","app = FirecrawlApp(api_key=FIRECRAWL_API_KEY)"],"metadata":{"id":"udAMPSd7hAz_"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["laravel = app.scrape_url(\n"," 'https://laravel.com',\n"," params={'formats': ['markdown', 'html']})"],"metadata":{"id":"8yyP9TpVgI3j"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["print(laravel[\"markdown\"])\n","laravel_markdown = laravel[\"markdown\"]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"O82jSZPeirnb","outputId":"ed3a6a44-67e2-41a4-c96d-a7733937e896","executionInfo":{"status":"ok","timestamp":1737987490013,"user_tz":-420,"elapsed":506,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}}},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["# The PHP Framework for Web Artisans\n","\n","Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the\n","foundation — freeing you to create without sweating the small things.\n","\n","[Get Started](https://laravel.com/docs/11.x) [Watch Laracasts](https://laracasts.com/)\n","\n","## Write code for the joy of it.\n","\n","Laravel values beauty. We love clean code just as much\n","as you do. Simple, elegant syntax puts amazing functionality at your fingertips. Every feature\n","has been thoughtfully considered to provide a wonderful developer experience.\n","\n","[Start Learning](https://laravel.com/docs/11.x)\n","\n","## One Framework, Many Flavors\n","\n","Build robust, full-stack applications in PHP using\n","Laravel and [Livewire](https://livewire.laravel.com/). Love\n","JavaScript? Build a monolithic React or Vue driven frontend by pairing Laravel with [Inertia](https://inertiajs.com/).\n","\n","Or, let Laravel serve as a robust backend API for your\n","Next.js application, mobile application, or other frontend. Either way, our starter kits will have\n","you productive in minutes.\n","\n","[Empower Your Frontend](https://laravel.com/frontend)\n","\n","## Everything you need to be amazing.\n","\n","Out of the box, Laravel has elegant solutions for the\n","common features needed by all modern web applications. It's time to start building amazing applications and\n","stop wasting time searching for packages and reinventing the wheel.\n","\n","### Authentication\n","\n","Authenticating users is as simple as adding an authentication middleware to your Laravel route definition:\n","\n","```torchlight\n","\n","Route::get('/profile', ProfileController::class)\n"," ->middleware('auth');\n","```\n","\n","Once the user is authenticated, you can access the authenticated user via the `Auth` facade:\n","\n","```torchlight\n","\n","use Illuminate\\Support\\Facades\\Auth;\n","\n","// Get the currently authenticated user...\n","$user = Auth::user();\n","```\n","\n","Of course, you may define your own authentication middleware, allowing you to customize the authentication process.\n","\n","For more information on Laravel's authentication features, check out the [authentication documentation](https://laravel.com/docs/authentication).\n","\n","### Authorization\n","\n","You'll often need to check whether an authenticated user is authorized to perform a specific action. Laravel's model policies make it a breeze:\n","\n","```torchlight\n","\n","php artisan make:policy UserPolicy\n","```\n","\n","Once you've defined your authorization rules in the generated policy class, you can authorize the user's request in your controller methods:\n","\n","```torchlight has-focus-lines\n","\n","public function update(Request $request, Invoice $invoice)\n","{\n"," Gate::authorize('update', $invoice);\n","\n"," $invoice->update(/* ... */);\n","}\n","```\n","\n","[Learn more](https://laravel.com/docs/authorization)\n","\n","### Eloquent ORM\n","\n","Scared of databases? Don't be. Laravel’s Eloquent ORM makes it painless to interact with your application's data, and models, migrations, and relationships can be quickly scaffolded:\n","\n","```torchlight\n","\n","php artisan make:model Invoice --migration\n","```\n","\n","Once you've defined your model structure and relationships, you can interact with your database using Eloquent's powerful, expressive syntax:\n","\n","```torchlight\n","\n","// Create a related model...\n","$user->invoices()->create(['amount' => 100]);\n","\n","// Update a model...\n","$invoice->update(['amount' => 200]);\n","\n","// Retrieve models...\n","$invoices = Invoice::unpaid()->where('amount', '>=', 100)->get();\n","\n","// Rich API for model interactions...\n","$invoices->each->pay();\n","```\n","\n","[Learn more](https://laravel.com/docs/eloquent)\n","\n","### Database Migrations\n","\n","Migrations are like version control for your database, allowing your team to define and share your application's database schema definition:\n","\n","```torchlight\n","\n","public function up(): void\n","{\n"," Schema::create('flights', function (Blueprint $table) {\n"," $table->uuid()->primary();\n"," $table->foreignUuid('airline_id')->constrained();\n"," $table->string('name');\n"," $table->timestamps();\n"," });\n","}\n","```\n","\n","[Learn more](https://laravel.com/docs/migrations)\n","\n","### Validation\n","\n","Laravel has over 90 powerful, built-in validation rules and, using Laravel Precognition, can provide live validation on your frontend:\n","\n","```torchlight has-focus-lines\n","\n","public function update(Request $request)\n","{\n"," $validated = $request->validate([\\\n"," 'email' => 'required|email|unique:users',\\\n"," 'password' => Password::required()->min(8)->uncompromised(),\\\n"," ]);\n","\n"," $request->user()->update($validated);\n","}\n","```\n","\n","[Learn more](https://laravel.com/docs/validation)\n","\n","### Notifications & Mail\n","\n","Use Laravel to quickly send beautifully styled notifications to your users via email, Slack, SMS, in-app, and more:\n","\n","```torchlight\n","\n","php artisan make:notification InvoicePaid\n","```\n","\n","Once you have generated a notification, you can easily send the message to one of your application's users:\n","\n","```torchlight\n","\n","$user->notify(new InvoicePaid($invoice));\n","```\n","\n","[Learn more](https://laravel.com/docs/notifications)\n","\n","### File Storage\n","\n","Laravel provides a robust filesystem abstraction layer, providing a single, unified API for interacting with local filesystems and cloud based filesystems like Amazon S3:\n","\n","```torchlight\n","\n","$path = $request->file('avatar')->store('s3');\n","```\n","\n","Regardless of where your files are stored, interact with them using Laravel's simple, elegant syntax:\n","\n","```torchlight\n","\n","$content = Storage::get('photo.jpg');\n","\n","Storage::put('photo.jpg', $content);\n","```\n","\n","[Learn more](https://laravel.com/docs/filesystem)\n","\n","### Job Queues\n","\n","Laravel lets you to offload slow jobs to a background queue, keeping your web requests snappy:\n","\n","```torchlight has-focus-lines\n","\n","$podcast = Podcast::create(/* ... */);\n","\n","ProcessPodcast::dispatch($podcast)->onQueue('podcasts');\n","```\n","\n","You can run as many queue workers as you need to handle your workload:\n","\n","```torchlight\n","\n","php artisan queue:work redis --queue=podcasts\n","```\n","\n","For more visibility and control over your queues, [Laravel Horizon](https://laravel.com/docs/horizon) provides a beautiful dashboard and code-driven configuration for your Laravel-powered Redis queues.\n","\n","**Learn more**\n","\n","- [Job Queues](https://laravel.com/docs/queues)\n","- [Laravel Horizon](https://laravel.com/docs/horizon)\n","\n","### Task Scheduling\n","\n","Schedule recurring jobs and commands with an expressive syntax and say goodbye to complicated configuration files:\n","\n","```torchlight\n","\n","$schedule->job(NotifySubscribers::class)->hourly();\n","```\n","\n","Laravel's scheduler can even handle multiple servers and offers built-in overlap prevention:\n","\n","```torchlight\n","\n","$schedule->job(NotifySubscribers::class)\n"," ->dailyAt('9:00')\n"," ->onOneServer()\n"," ->withoutOverlapping();\n","```\n","\n","[Learn more](https://laravel.com/docs/scheduling)\n","\n","### Testing\n","\n","Laravel is built for testing. From unit tests to browser tests, you’ll feel more confident in deploying your application:\n","\n","```torchlight\n","\n","$user = User::factory()->create();\n","\n","$this->browse(fn (Browser $browser) => $browser\n"," ->visit('/login')\n"," ->type('email', $user->email)\n"," ->type('password', 'password')\n"," ->press('Login')\n"," ->assertPathIs('/home')\n"," ->assertSee(\"Welcome {$user->name}\")\n",");\n","```\n","\n","[Learn more](https://laravel.com/docs/testing)\n","\n","### Events & WebSockets\n","\n","Laravel's events allow you to send and listen for events across your application, and listeners can easily be dispatched to a background queue:\n","\n","```torchlight\n","\n","OrderShipped::dispatch($order);\n","```\n","\n","```torchlight\n","\n","class SendShipmentNotification implements ShouldQueue\n","{\n"," public function handle(OrderShipped $event): void\n"," {\n"," // ...\n"," }\n","}\n","```\n","\n","Your frontend application can even subscribe to your Laravel events using [Laravel Echo](https://laravel.com/docs/broadcasting) and WebSockets, allowing you to build real-time, dynamic applications:\n","\n","```torchlight\n","\n","Echo.private(`orders.${orderId}`)\n"," .listen('OrderShipped', (e) => {\n"," console.log(e.order);\n"," });\n","```\n","\n","[Learn more](https://laravel.com/docs/events)\n","\n","We've just scratched the surface. Laravel has you\n","covered for everything you will need to build a web application, including email verification, rate\n","limiting, and custom console commands. Check out the [Laravel documentation](https://laravel.com/docs/11.x) to keep learning.\n","\n","## Move fast... with confidence.\n","\n","Laravel is committed to delivering the best testing\n","experience you can imagine. No more brittle tests that are a nightmare to maintain. Beautiful\n","testing APIs, database seeding, and painless browser testing let you ship with confidence.\n","\n","[Learn More](https://laravel.com/docs/http-tests)\n","\n","## Enterprise scale without the enterprise complexity.\n","\n","Our vast library of meticulously maintained packages means you're\n","ready for anything. Let [Laravel Octane](https://laravel.com/docs/octane) supercharge your\n","application's performance, and experience infinite scale on [Laravel Vapor](https://vapor.laravel.com/), our serverless deployment platform powered by AWS\n","Lambda.\n","\n","- [![Forge Logo](https://laravel.com/img/ecosystem/forge.min.svg)\\\\\n","\\\\\n","Forge\\\\\n","\\\\\n","Server management doesn't have to be a nightmare. Provision and deploy unlimited PHP applications on DigitalOcean, Linode, Vultr, Amazon, Hetzner and more.](https://forge.laravel.com/)\n","- [![Vapor Logo](https://laravel.com/img/ecosystem/vapor.min.svg)\\\\\n","\\\\\n","Vapor\\\\\n","\\\\\n","Laravel Vapor is a serverless deployment platform for Laravel, powered by AWS. Launch your Laravel infrastructure on Vapor and fall in love with the scalable simplicity of serverless.](https://vapor.laravel.com/)\n","\n","- [![Laravel Breeze Logo Logo](https://laravel.com/img/ecosystem/breeze.min.svg)\\\\\n","\\\\\n","Breeze\\\\\n","\\\\\n","Lightweight starter kit scaffolding for new applications with Blade or Inertia.](https://laravel.com/docs/11.x/starter-kits#laravel-breeze)\n","- [![Laravel Cashier Logo](https://laravel.com/img/ecosystem/cashier.min.svg)\\\\\n","\\\\\n","Cashier\\\\\n","\\\\\n","Take the pain out of managing subscriptions on Stripe or Paddle.](https://laravel.com/docs/11.x/billing)\n","- [![Laravel Dusk Logo](https://laravel.com/img/ecosystem/dusk.min.svg)\\\\\n","\\\\\n","Dusk\\\\\n","\\\\\n","Automated browser testing to ship your application with confidence.](https://laravel.com/docs/11.x/dusk)\n","- [![Laravel Echo Logo](https://laravel.com/img/ecosystem/echo.min.svg)\\\\\n","\\\\\n","Echo\\\\\n","\\\\\n","Listen for WebSocket events broadcast by your Laravel application.](https://laravel.com/docs/11.x/broadcasting)\n","- [![Envoyer Logo](https://laravel.com/img/ecosystem/envoyer.min.svg)\\\\\n","\\\\\n","Envoyer\\\\\n","\\\\\n","Deploy your Laravel applications to customers with zero downtime.](https://envoyer.io/)\n","- [![Herd Logo](https://laravel.com/img/ecosystem/herd.min.svg)\\\\\n","\\\\\n","Herd\\\\\n","\\\\\n","The fastest Laravel local dev environment - now for macOS and Windows.](https://herd.laravel.com/)\n","- [![Laravel Horizon Logo](https://laravel.com/img/ecosystem/horizon.min.svg)\\\\\n","\\\\\n","Horizon\\\\\n","\\\\\n","Beautiful UI for monitoring your Redis driven Laravel queues.](https://laravel.com/docs/11.x/horizon)\n","- [![Inertia Logo](https://laravel.com/img/ecosystem/inertia.min.svg)\\\\\n","\\\\\n","Inertia\\\\\n","\\\\\n","Create modern single-page React and Vue apps using classic server-side routing.](https://inertiajs.com/)\n","- [![Laravel Jetstream Logo](https://laravel.com/img/ecosystem/jetstream.min.svg)\\\\\n","\\\\\n","Jetstream\\\\\n","\\\\\n","Robust starter kit including authentication and team management.](https://jetstream.laravel.com/)\n","- [![Laravel Livewire Logo](https://laravel.com/img/ecosystem/livewire.min.svg)\\\\\n","\\\\\n","Livewire\\\\\n","\\\\\n","Build reactive, dynamic applications using Laravel and Blade.](https://livewire.laravel.com/)\n","- [![Laravel Nova Logo](https://laravel.com/img/ecosystem/nova.min.svg)\\\\\n","\\\\\n","Nova\\\\\n","\\\\\n","Thoughtfully designed administration panel for your Laravel applications.](https://nova.laravel.com/)\n","- [![Laravel Octane Logo](https://laravel.com/img/ecosystem/octane.min.svg)\\\\\n","\\\\\n","Octane\\\\\n","\\\\\n","Supercharge your application's performance by keeping it in memory.](https://laravel.com/docs/11.x/octane)\n","- [![Laravel Pennant Logo](https://laravel.com/img/ecosystem/pennant.min.svg)\\\\\n","\\\\\n","Pennant\\\\\n","\\\\\n","A simple, lightweight library for managing feature flags.](https://laravel.com/docs/11.x/pennant)\n","- [![Laravel Pint Logo](https://laravel.com/img/ecosystem/pint.min.svg)\\\\\n","\\\\\n","Pint\\\\\n","\\\\\n","Opinionated PHP code style fixer for minimalists.](https://laravel.com/docs/11.x/pint)\n","- [![Laravel Prompts Logo](https://laravel.com/img/ecosystem/prompts.min.svg)\\\\\n","\\\\\n","Prompts\\\\\n","\\\\\n","Beautiful and user-friendly forms for command-line applications.](https://laravel.com/docs/11.x/prompts)\n","- [![Laravel Pulse Logo](https://laravel.com/img/ecosystem/pulse.min.svg)\\\\\n","\\\\\n","Pulse\\\\\n","\\\\\n","At-a-glance insights into your application's performance and usage.](https://pulse.laravel.com/)\n","- [![Laravel Reverb Logo](https://laravel.com/img/ecosystem/reverb.min.svg)\\\\\n","\\\\\n","Reverb\\\\\n","\\\\\n","Blazing fast and scalable WebSockets for your application.](https://reverb.laravel.com/)\n","- [![Laravel Sail Logo](https://laravel.com/img/ecosystem/sail.min.svg)\\\\\n","\\\\\n","Sail\\\\\n","\\\\\n","Hand-crafted Laravel local development experience using Docker.](https://laravel.com/docs/11.x/sail)\n","- [![Laravel Sanctum Logo](https://laravel.com/img/ecosystem/sanctum.min.svg)\\\\\n","\\\\\n","Sanctum\\\\\n","\\\\\n","API and mobile application authentication without wanting to pull your hair out.](https://laravel.com/docs/11.x/sanctum)\n","- [![Laravel Scout Logo](https://laravel.com/img/ecosystem/scout.min.svg)\\\\\n","\\\\\n","Scout\\\\\n","\\\\\n","Lightning fast full-text search for your application's Eloquent models.](https://laravel.com/docs/11.x/scout)\n","- [![Laravel Socialite Logo](https://laravel.com/img/ecosystem/socialite.min.svg)\\\\\n","\\\\\n","Socialite\\\\\n","\\\\\n","Social authentication via Facebook, Twitter, GitHub, LinkedIn, and more.](https://laravel.com/docs/11.x/socialite)\n","- [![Laravel Spark Logo](https://laravel.com/img/ecosystem/spark.min.svg)\\\\\n","\\\\\n","Spark\\\\\n","\\\\\n","Launch your next business with our fully-featured, drop-in billing portal.](https://spark.laravel.com/)\n","- [![Laravel Telescope Logo](https://laravel.com/img/ecosystem/telescope.min.svg)\\\\\n","\\\\\n","Telescope\\\\\n","\\\\\n","Debug your application using our debugging and insight UI.](https://laravel.com/docs/11.x/telescope)\n","\n","## Loved by thousands of developers around the world.\n","\n","> ## “I’ve been using Laravel for nearly a decade and never been tempted to switch to anything else.“\n",">\n","> ![Adam Wathan](https://laravel.com/images/testimonials/adam-wathan.jpg)\n",">\n","> Adam Wathan\n",">\n","> Creator of [Tailwind CSS](https://tailwindcss.com/)\n","\n","> ## “Laravel takes the pain out of building modern, scalable web apps.“\n",">\n","> ![Aaron Francis](https://laravel.com/images/testimonials/aaron-francis.jpg)\n",">\n","> Aaron Francis\n",">\n","> Creator of [Torchlight](https://torchlight.dev/) and\n","> [Sidecar](https://github.com/hammerstonedev/sidecar)\n","\n","> ## “Laravel grew out to be an amazing innovative and active community. Laravel is so much more than just a PHP framework.“\n",">\n","> ![Bobby Bouwmann](https://laravel.com/images/testimonials/bobby-bouwmann.jpg)\n",">\n","> Bobby Bouwmann\n",">\n","> Elite Developer at [Enrise](https://enrise.com/)\n","\n","> ## “As an old school PHP developer, I have tried many frameworks; none has given me the development speed and enjoyment of use that I found with Laravel. It is a breath of fresh air in the PHP ecosystem, with a brilliant community around it.“\n",">\n","> ![Erika Heidi](https://laravel.com/images/testimonials/erika-heidi.jpg)\n",">\n","> Erika Heidi\n",">\n","> Creator of [Minicli](https://github.com/minicli/minicli)\n","\n","> ## “Laravel is nothing short of a delight. It allows me to build any web-y thing I want in record speed with joy.“\n",">\n","> ![Caleb Porzio](https://laravel.com/images/testimonials/caleb-porzio.jpg)\n",">\n","> Caleb Porzio\n",">\n","> Creator of [Livewire](https://livewire.laravel.com/)\n","> and [Alpine.js](https://alpinejs.dev/)\n","\n","> ## “I found Laravel by chance, but I knew right away that I found my thing. The framework, the ecosystem and the community - it’s the perfect package. I’ve worked on amazing projects and met incredible people; it’s safe to say that Laravel changed my life.“\n",">\n","> ![Zuzana Kunckova](https://laravel.com/images/testimonials/zuzana-kunckova.jpg)\n",">\n","> Zuzana Kunckova\n",">\n","> Full-Stack Developer\n","\n","> ## “Laravel’s best-in-class testing tools give me the peace of mind to ship robust apps quickly.“\n",">\n","> ![Michael Dyrynda](https://laravel.com/images/testimonials/michael-dyrynda.jpg)\n",">\n","> Michael Dyrynda\n",">\n","> Laravel Artisan + Laracon AU Organizer\n","\n","> ## “Laravel has been like rocket fuel for my career and business.“\n",">\n","> ![Chris Arter](https://laravel.com/images/testimonials/chris-arter.jpg)\n",">\n","> Chris Arter\n",">\n","> Developer at [Bankrate](https://www.bankrate.com/)\n","\n","> ## “I've been using Laravel for over 10 years and I can't imagine using PHP without it.“\n",">\n","> ![Eric L. Barnes](https://laravel.com/images/testimonials/eric-l-barnes.jpg)\n",">\n","> Eric L. Barnes\n",">\n","> Founder of [Laravel News](https://laravel-news.com/)\n","\n","> ## “I've been enjoying Laravel's focus on pushing developer experience to the next level for many years. All pieces of the ecosystem are powerful, well designed, fun to work with, and have stellar documentation. The surrounding friendly and helpful community is a joy to be a part of.“\n",">\n","> ![Freek Van der Herten](https://laravel.com/images/testimonials/freek-van-der-herten.jpg)\n",">\n","> Freek Van der Herten\n",">\n","> Owner of [Spatie](https://spatie.be/)\n","\n","> ## “Laravel and its ecosystem of tools help me build client projects faster, more secure, and higher quality than any other tools out there.“\n",">\n","> ![Jason Beggs](https://laravel.com/images/testimonials/jason-beggs.jpg)\n",">\n","> Jason Beggs\n",">\n","> Owner of [Design to Tailwind](https://designtotailwind.com/)\n","\n","> ## “I didn't fully appreciate Laravel's one-stop-shop, all-encompassing solution, until I tried (many) different ecosystems. Laravel is in a class of its own!“\n",">\n","> ![Joseph Silber](https://laravel.com/images/testimonials/joseph-silber.jpg)\n",">\n","> Joseph Silber\n",">\n","> Creator of [Bouncer](https://github.com/JosephSilber/bouncer)\n","\n","> ## “Laravel has helped me launch products quicker than any other solution, allowing me to get to market faster and faster as the community has evolved.“\n",">\n","> ![Steve McDougall](https://laravel.com/images/testimonials/steve-mcdougall.jpg)\n",">\n","> Steve McDougall\n",">\n","> Creator of [Laravel Transporter](https://github.com/JustSteveKing/laravel-transporter)\n","\n","> ## “I've been using Laravel for every project over the past ten years in a time where a new framework launches every day. To this date, there's just nothing like it.“\n",">\n","> ![Philo Hermans](https://laravel.com/images/testimonials/philo-hermans.jpg)\n",">\n","> Philo Hermans\n",">\n","> Founder of [Anystack](https://anystack.sh/)\n","\n","> ## “Laravel is for developers who write code because they can rather than because they have to.“\n",">\n","> ![Luke Downing](https://laravel.com/images/testimonials/luke-downing.jpg)\n",">\n","> Luke Downing\n",">\n","> Maker + Developer\n","\n","> ## “Laravel makes building web apps exciting! It has also helped me to become a better developer 🤙“\n",">\n","> ![Tony Lea](https://laravel.com/images/testimonials/tony-lea.jpg)\n",">\n","> Tony Lea\n",">\n","> Founder of [DevDojo](https://devdojo.com/)\n","\n","> ## “The Laravel ecosystem has been integral to the success of our business. The framework allows us to move fast and ship regularly, and Laravel Vapor has allowed us to operate at an incredible scale with ease.“\n",">\n","> ![Jack Ellis](https://laravel.com/images/testimonials/jack-ellis.jpg)\n",">\n","> Jack Ellis\n",">\n","> Co-founder of [Fathom\\\\\n","> Analytics](https://usefathom.com/)\n","\n","## A community built for people like you.\n","\n","Laravel is for everyone — whether you have been\n","programming for 20 years or 20 minutes. It's for architecture astronauts and weekend hackers. For\n","those with degrees and for those who dropped out to chase their dreams. Together, we create amazing\n","things.\n","\n","[Blog](https://blog.laravel.com/) [Forums](https://laracasts.com/discuss) [Jobs](https://larajobs.com/?partner=5) [Laravel News](https://laravel-news.com/) [Laracasts](https://laracasts.com/)\n","\n","![laracon](https://laravel.com/images/laracon.png)\n","\n","### Watch us on Laracasts\n","\n","## Tune In\n","\n","Laracasts includes free videos and tutorials\n","covering the entire Laravel ecosystem. Stay up to date by watching our latest videos.\n","\n","[Start Watching](https://laracasts.com/)\n","\n","![partners](https://laravel.com/images/partners.png)\n","\n","## Hire a partner for your next project\n","\n","Laravel Partners are elite shops providing\n","top-notch Laravel development and consulting. Each of our partners can help you craft a beautiful,\n","well-architected project.\n","\n","[Browse\\\\\n","Partners](https://partners.laravel.com/)\n"]}]},{"cell_type":"markdown","source":["Now let's concat the markdowns together in one string."],"metadata":{"id":"i5bSfR1ihjCf"}},{"cell_type":"code","source":["context = f\"\"\"The following are laravel \\n\\n{laravel_markdown}\\n\"\"\""],"metadata":{"id":"8eDEVI8xhsdB"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["Now we setup our LLM for extraction. Let's install Groq to access Llama 3.2 11B"],"metadata":{"id":"EoB2zeIsT9UV"}},{"cell_type":"code","source":["pip install groq -q"],"metadata":{"id":"yy8xazeCXNpO","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1737987533822,"user_tz":-420,"elapsed":4320,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}},"outputId":"59b88380-1d91-4466-8585-bf23359a4c15"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/109.6 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m109.6/109.6 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25h"]}]},{"cell_type":"code","source":["from groq import Groq\n","import getpass\n","\n","GROQ_API_KEY=getpass.getpass(\"Groq API Key: \")\n","\n","client = Groq(api_key=GROQ_API_KEY)"],"metadata":{"id":"XomR06c5XXhi","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1737987553679,"user_tz":-420,"elapsed":4560,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}},"outputId":"0b54c1e1-b903-4b5b-93c6-898af95f0d80"},"execution_count":null,"outputs":[{"name":"stdout","output_type":"stream","text":["Groq API Key: ··········\n"]}]},{"cell_type":"code","source":["system_message = f\"\"\"\n","You're a helpful intelligence assistant.\n","You're going to look at the course and prices.\n","Your answer is always extremely short and straight to the point.\n","\"\"\""],"metadata":{"id":"yC7oMdIOXcYJ"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["def get_response(query: str, context: str):\n"," completion = client.chat.completions.create(\n"," model=\"llama-3.2-11b-vision-preview\",\n"," messages=[\n"," {\n"," \"role\": \"system\",\n"," \"content\": system_message\n"," },\n"," {\n"," \"role\": \"user\",\n"," \"content\": context\n"," },\n"," {\n"," \"role\": \"user\",\n"," \"content\": query\n"," }\n"," ],\n"," temperature=0,\n"," max_tokens=1470,\n"," top_p=1,\n"," stream=False,\n"," stop=None,\n"," )\n","\n"," return completion.choices[0].message.content"],"metadata":{"id":"qaAmh3oyX9Bv"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["answer = get_response(\n"," query=\"what is laravel?\",\n"," context=context,\n"," )\n","\n","print(answer)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"d-eHFyBHYQqu","outputId":"322f00ed-88ed-44ac-e19f-fb4e29584811","executionInfo":{"status":"ok","timestamp":1737987675247,"user_tz":-420,"elapsed":821,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}}},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Laravel is a free, open-source PHP web framework used for building web applications. It is designed to make development faster, easier, and more enjoyable.\n"]}]},{"cell_type":"code","source":["print(\n"," get_response(\n"," query=\"who is founder laravel\",\n"," context=context,\n"," )\n",")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"SpXcB051kait","outputId":"0539e880-98ec-4a59-d391-995e52f52935","executionInfo":{"status":"ok","timestamp":1737987714869,"user_tz":-420,"elapsed":757,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}}},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Taylor Otwell is the founder of Laravel.\n"]}]},{"cell_type":"code","source":["print(\n"," get_response(\n"," query=\"framework laravel kapan di perkenalkan\",\n"," context=context,\n"," )\n",")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"LjIquGQjmavM","outputId":"8cbac543-6726-4562-8a4f-c1358cec0883","executionInfo":{"status":"ok","timestamp":1737987748387,"user_tz":-420,"elapsed":32422,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}}},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Laravel pertama kali diperkenalkan pada tahun 2011 oleh Taylor Otwell, seorang pengembang perangkat lunak asal Amerika Serikat. Pada saat itu, Laravel masih dalam bentuk beta dan belum memiliki fitur-fitur yang lengkap seperti saat ini.\n","\n","Laravel pertama kali dirilis pada tanggal 9 Agustus 2011, dan pada saat itu, framework ini masih menggunakan PHP 5.3 sebagai basisnya. Pada tahun 2012, Laravel telah mencapai versi 3.0 dan mulai mendapatkan popularitas di kalangan pengembang web.\n","\n","Pada tahun 2013, Laravel telah mencapai versi 4.0 dan mulai mendapatkan dukungan dari komunitas pengembang web. Pada tahun 2014, Laravel telah mencapai versi 5.0 dan mulai mendapatkan fitur-fitur baru seperti sistem autentikasi dan autorisasi.\n","\n","Saat ini, Laravel telah menjadi salah satu framework PHP yang paling populer dan digunakan oleh banyak pengembang web di seluruh dunia.\n"]}]},{"cell_type":"code","source":["import gradio as gr\n","\n","# Fungsi Gradio\n","def chat_interface(query, context=\"\"):\n"," try:\n"," response = get_response(query, context)\n"," return response\n"," except Exception as e:\n"," return f\"Error: {str(e)}\"\n","\n","# Antarmuka Gradio\n","iface = gr.Interface(\n"," fn=chat_interface,\n"," inputs=[\n"," gr.Textbox(label=\"Silahkan tanya saja\")\n"," ],\n"," outputs=gr.Textbox(label=\"Assistant Laravel\"),\n"," title=\"LLM Chat Interface\",\n"," description=\"Chat with the LLM.\",\n",")\n","\n","# Untuk Google Colab, gunakan share=True\n","iface.launch(pwa=True, share=True)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":611},"id":"h5IbStiE9Ko6","executionInfo":{"status":"ok","timestamp":1737988068695,"user_tz":-420,"elapsed":1038,"user":{"displayName":"Fajar Yusuf Nur Cahyo","userId":"10307426083619777362"}},"outputId":"1c7d6ae9-ce86-4046-8e19-d2193a6639b3"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Colab notebook detected. To show errors in colab notebook, set debug=True in launch()\n","* Running on public URL: https://c7b019bc4b9e7c71f0.gradio.live\n","\n","This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"]},{"output_type":"display_data","data":{"text/plain":[""],"text/html":["
"]},"metadata":{}},{"output_type":"execute_result","data":{"text/plain":[]},"metadata":{},"execution_count":17}]}]}