<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://aliirz.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://aliirz.com/" rel="alternate" type="text/html" /><updated>2026-04-29T14:43:23+00:00</updated><id>https://aliirz.com/feed.xml</id><title type="html">Ali Raza</title><subtitle>Passionate Software Architect, Entrepreneur, and Coffee Enthusiast</subtitle><author><name>Ali Raza</name></author><entry><title type="html">Harness engineering: the layer everyone’s building and nobody’s naming</title><link href="https://aliirz.com/harness-engineering" rel="alternate" type="text/html" title="Harness engineering: the layer everyone’s building and nobody’s naming" /><published>2026-04-18T00:00:00+00:00</published><updated>2026-04-18T00:00:00+00:00</updated><id>https://aliirz.com/harness-engineering</id><content type="html" xml:base="https://aliirz.com/harness-engineering">&lt;p&gt;Every serious AI coding setup has a hidden layer underneath the model. It’s not the model. It’s not the IDE plugin. It’s the infrastructure that decides what the model knows when it starts, what it remembers while it works, and what survives after it stops.&lt;/p&gt;

&lt;p&gt;I’ve been calling this harness engineering. Nobody else seems to be using that term, but the problem is real and every team building with AI is solving it — mostly in silence, mostly from scratch.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;what-the-problem-actually-is&quot;&gt;What the problem actually is&lt;/h2&gt;

&lt;p&gt;LLMs are stateless. Every session starts cold. The model has no memory of the deploy that broke prod last Tuesday, no recollection of the architectural decision you spent three hours debating, no awareness that you’ve already rejected this particular approach twice before.&lt;/p&gt;

&lt;p&gt;You end up re-explaining your stack. Re-establishing constraints. Watching the model repeat mistakes you’ve already corrected. The cost isn’t just time — it’s trust. You stop relying on the model for anything that requires context, which is most of what matters.&lt;/p&gt;

&lt;p&gt;A harness is the infrastructure layer that fixes this. At minimum it answers three questions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;What does the model know at the start of a session?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;What gets recorded while the model works?&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;What survives when the session ends?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answers vary wildly depending on which system you’re using.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;how-the-main-systems-answer-these-questions&quot;&gt;How the main systems answer these questions&lt;/h2&gt;

&lt;h3 id=&quot;claude-code&quot;&gt;Claude Code&lt;/h3&gt;

&lt;p&gt;Claude Code has CLAUDE.md — a markdown file that gets injected into context at session start. You write it manually. It’s useful but static: it knows what you told it, not what it observed.&lt;/p&gt;

&lt;p&gt;More recently (v2.1.59+), Anthropic added Auto-Memory: a background system that watches your sessions, extracts insights, and saves structured summaries to disk automatically. It’s early, but it’s the right direction.&lt;/p&gt;

&lt;p&gt;The gap: CLAUDE.md doesn’t update itself. Auto-Memory helps but isn’t yet a full episodic layer. There’s no built-in mechanism for the model to review what it learned last week and decide what’s worth keeping permanently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Whatever you manually put in CLAUDE.md, plus Auto-Memory summaries if enabled. No automatic learning.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;openai-codex-cli&quot;&gt;OpenAI Codex CLI&lt;/h3&gt;

&lt;p&gt;Codex has persistent memory in preview — but it’s enterprise/edu only, rolling out slowly, and region-delayed. It remembers preferences, coding style, and recurring patterns across sessions.&lt;/p&gt;

&lt;p&gt;The integrations are impressive (GitHub, Notion, Slack, Google Workspace). But integrations retrieve external context — they don’t synthesize it. There’s no mechanism for Codex to notice a recurring failure pattern and promote it to a standing rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Limited, where available. No automatic learning from patterns.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;langgraph&quot;&gt;LangGraph&lt;/h3&gt;

&lt;p&gt;LangGraph has the most mature persistence story of the framework-layer options. State checkpoints to a database per thread. Long-term memory via vector stores. MongoDB integration for cross-session recall. Interrupt-and-resume for human-in-the-loop workflows.&lt;/p&gt;

&lt;p&gt;The downside is configuration overhead. The default is amnesia — you have to explicitly wire a checkpointer and a vector store to get persistence. Most deployments don’t. And even when they do, vector similarity retrieval can miss context that’s semantically important but lexically distant from your current query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Everything, if you configured the backend. Nothing, if you didn’t.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;crewai&quot;&gt;CrewAI&lt;/h3&gt;

&lt;p&gt;CrewAI has the most ambitious memory model right now. Their 2026 Unified Memory API collapses short/long/entity/external memory types into one LLM-analyzed class with composite scoring (semantic similarity + recency + importance). Cognitive Memory adds agent-driven recall flows that proactively surface context.&lt;/p&gt;

&lt;p&gt;ChromaDB + SQLite as the default backend means persistence works out of the box. The scoping system (/, /project/alpha, /agent/researcher/findings) handles multi-agent setups cleanly.&lt;/p&gt;

&lt;p&gt;The risk: encoding and recall flows can disagree on importance. Agents may over-weight recency. And it’s tied to the CrewAI framework — you can’t take your memory layer to a different tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Full memory hierarchy, if the database persists. Learning is automatic but not human-validated.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;autogen&quot;&gt;AutoGen&lt;/h3&gt;

&lt;p&gt;AutoGen’s memory is an afterthought. The default is stateless. You can plug in ChromaDB, Redis, Neo4j, Mem0 — but nothing is configured out of the box, and the framework itself is now in maintenance mode as Microsoft shifts focus to their broader Agent Framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Nothing by default. Optional external backends if you wire them yourself.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;pi-pidev&quot;&gt;Pi (pi.dev)&lt;/h3&gt;

&lt;p&gt;Pi is by Mario Zechner and it’s the most honest harness on this list. The tagline is “there are many coding agents, but this one is mine.” That’s not a joke — it’s the design philosophy.&lt;/p&gt;

&lt;p&gt;Pi is a minimal terminal harness that supports 15+ LLM providers and a TypeScript extension system. No MCP. No built-in sub-agents. No permission popups. No memory layer baked in. The core is four tools: Read, Write, Edit, Bash. Everything else — sub-agents, sandboxing, RAG, persistence — you build via extensions or you don’t have it.&lt;/p&gt;

&lt;p&gt;Session state uses tree-structured storage so you can branch from any previous point, which is genuinely useful. Context loading comes from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AGENTS.md&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SYSTEM.md&lt;/code&gt; files at the project root. Auto-summarization handles compaction. That’s it.&lt;/p&gt;

&lt;p&gt;The absence of a memory layer isn’t an oversight. Pi’s bet is that most harnesses bundle too much and the right answer is primitives you can compose. I find that compelling. The downside is you have to build the memory layer yourself — or bring one in from outside.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What survives a session:&lt;/strong&gt; Tree-structured session history you can branch from. No cross-session learning without an external brain.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;the-problem-none-of-them-fully-solve&quot;&gt;The problem none of them fully solve&lt;/h2&gt;

&lt;p&gt;Every system above has at least one of these gaps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;No episodic layer&lt;/strong&gt; — no record of what the model actually did, tool by tool, session by session&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;No promotion mechanism&lt;/strong&gt; — no way for recurring patterns to graduate from observations to permanent rules&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Not portable&lt;/strong&gt; — memory is locked to the framework; switching tools means starting over&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;No human review gate&lt;/strong&gt; — automatic learning means automatic mistakes at scale&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most tools pick two or three of these to solve. None of them address all four cleanly.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;why-i-use-agentic-stack&quot;&gt;Why I use agentic-stack&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/codejunkie99/agentic-stack&quot;&gt;agentic-stack&lt;/a&gt; is not a framework. It’s a portable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.agent/&lt;/code&gt; folder — a structured memory system that plugs into whatever AI harness you’re actually using: Claude Code, Pi, Cursor, Windsurf, OpenCode, or a custom Python setup.&lt;/p&gt;

&lt;p&gt;The memory structure is four layers with distinct retention policies:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;working/&lt;/strong&gt; — current task state, cleared when done&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;episodic/&lt;/strong&gt; — timestamped records of what actually happened, tool by tool&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;semantic/&lt;/strong&gt; — durable lessons that survived human review&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;personal/&lt;/strong&gt; — your preferences, constraints, and how you like to work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;dream cycle&lt;/strong&gt; runs at session end. It clusters episodic entries by content similarity, scores them by salience (frequency × recency × pain_score), and stages high-salience candidates for review. A human validates before anything enters semantic memory. No automatic promotion, no silent mistakes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recall&lt;/strong&gt; runs before any risky operation — deploy, migration, schema change. It surfaces the most relevant past events. Not just similar keywords, but events that mattered.&lt;/p&gt;

&lt;p&gt;The portability is the differentiator. Your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.agent/&lt;/code&gt; folder moves with you. Switch from Claude Code to Cursor, the memory comes along. Switch to Pi — there’s a first-class adapter for that too. Switch to a custom Python agent — same thing. Your knowledge isn’t owned by the framework.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;why-this-framing-matters-now&quot;&gt;Why this framing matters now&lt;/h2&gt;

&lt;p&gt;Six months ago, “just use Claude” was a reasonable answer for most coding tasks. Today, teams are running multi-session workflows, building internal agents with persistent context, and making architectural decisions that depend on the model having accurate memory of what was tried before.&lt;/p&gt;

&lt;p&gt;The infrastructure layer is no longer optional. The question is whether you’re building it intentionally or stumbling into it one CLAUDE.md edit at a time.&lt;/p&gt;

&lt;p&gt;Harness engineering is the discipline of building that layer well. It’s worth naming, worth thinking about explicitly, and worth getting right before your agent’s memory becomes a liability rather than an asset.&lt;/p&gt;

&lt;hr /&gt;</content><author><name>Ali Raza</name></author><category term="ai-agents" /><category term="claude" /><category term="memory" /><category term="open-source" /><category term="engineering" /><summary type="html">Every serious AI coding setup has a hidden layer underneath the model. It’s not the model. It’s not the IDE plugin. It’s the infrastructure that decides what the model knows when it starts, what it remembers while it works, and what survives after it stops.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Horse-Harness-on-Dark-Surface.png" /><media:content medium="image" url="https://aliirz.com/images/Horse-Harness-on-Dark-Surface.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">DSPy: The Framework for Programming LLMs (Not Prompting Them)</title><link href="https://aliirz.com/dspy-the-framework-for-programming-llms" rel="alternate" type="text/html" title="DSPy: The Framework for Programming LLMs (Not Prompting Them)" /><published>2026-04-09T00:00:00+00:00</published><updated>2026-04-09T00:00:00+00:00</updated><id>https://aliirz.com/dspy-the-framework-for-programming-llms</id><content type="html" xml:base="https://aliirz.com/dspy-the-framework-for-programming-llms">&lt;p&gt;I spent two years prompting LLMs before I found DSPy.&lt;/p&gt;

&lt;p&gt;The cycle was always the same. Write a prompt. Test it on five examples. It works. Ship it. Then an edge case breaks. Add “IMPORTANT:” to the prompt. Works for two days. Model update changes behavior. Rewrite from scratch.&lt;/p&gt;

&lt;p&gt;I had folders of prompts. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v1.txt&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v2_final.txt&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v2_final_REALLY_final.txt&lt;/code&gt;. None of them documented &lt;em&gt;why&lt;/em&gt; they worked. When something broke, I couldn’t tell if it was the prompt, the model, or the data. No version control. No tests. Just vibes.&lt;/p&gt;

&lt;p&gt;Then I found DSPy.&lt;/p&gt;

&lt;h2 id=&quot;what-dspy-actually-does&quot;&gt;What DSPy Actually Does&lt;/h2&gt;

&lt;p&gt;DSPy is a framework from Stanford NLP. The idea is simple: you don’t write prompts. You write Python.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AnalyzeStartup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Signature&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Analyze a startup pitch.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;pitch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;viability_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;strengths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;weaknesses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;verdict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s a Signature. It declares inputs, outputs, and types. DSPy compiles this into a prompt. When you need better prompts, you run an optimizer and DSPy rewrites them based on examples that work.&lt;/p&gt;

&lt;p&gt;The mental model shift: LLMs become function calls. You declare the interface. The framework handles the implementation.&lt;/p&gt;

&lt;h2 id=&quot;what-changed&quot;&gt;What Changed&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;I stopped memorizing prompt tricks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before DSPy: “If I put examples before instructions, it works better. Sometimes. Unless it’s GPT-4o. Then I need to structure it differently.”&lt;/p&gt;

&lt;p&gt;After DSPy: I write a Signature. DSPy figures out the best prompt format. The prompt becomes an implementation detail. I care about inputs, outputs, and behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I can finally test my LLM code.&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;test_startup_analyzer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;startup_analyzer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pitch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;We&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;re building AI for dog grooming...&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;viability_score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strengths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;weaknesses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Real tests. In my test suite. With assertions. This alone changed how I think about LLM applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model swaps are one line.&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;lm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;openai/gpt-4o-mini&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# lm = dspy.LM(&quot;anthropic/claude-3-sonnet&quot;)
# lm = dspy.LM(&quot;gemini/gemini-2.0-flash&quot;)
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Same code. Different model. DSPy handles the prompt translation. Before, every model needed prompt tuning. GPT-4 liked prompts one way. Claude another. Gemini another. Prompts were coupled to specific models. Now they’re not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimizers do the tuning for me.&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;optimizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BootstrapFewShot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;metric&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;my_metric&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_bootstrapped_demos&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;optimized&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;optimizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartupAnalyzer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;trainset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;train_examples&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Hand DSPy some examples of good outputs. It runs experiments, finds what works, builds the prompt. You review the results. That’s it.&lt;/p&gt;

&lt;h2 id=&quot;why-this-matters&quot;&gt;Why This Matters&lt;/h2&gt;

&lt;p&gt;If you’ve spent any time in production LLM systems, you know the pain. Prompts are brittle. Model updates break things. You can’t version control a prompt the same way you version control code. You can’t write unit tests for a prompt the same way you test functions.&lt;/p&gt;

&lt;p&gt;DSPy doesn’t solve all of this. But it moves the abstraction up one level. You’re still working with LLMs. But you’re programming them, not prompting them.&lt;/p&gt;

&lt;p&gt;The difference between raw SQL scattered through your codebase and an ORM. One is brittle, untyped, hard to refactor. The other is structured, testable, maintainable.&lt;/p&gt;

&lt;h2 id=&quot;when-dspy-makes-sense&quot;&gt;When DSPy Makes Sense&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;You’re building something real, not a demo&lt;/li&gt;
  &lt;li&gt;You need reliability, not “it works sometimes”&lt;/li&gt;
  &lt;li&gt;You want to swap models without rewriting everything&lt;/li&gt;
  &lt;li&gt;You’re tired of the prompt treadmill&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;why-i-wrote-a-guide&quot;&gt;Why I Wrote a Guide&lt;/h2&gt;

&lt;p&gt;I spent two years learning DSPy by hitting every error message, debugging every silent failure, and rewriting every prompt that “worked in testing.”&lt;/p&gt;

&lt;p&gt;I wrote down everything I learned. Practical stuff. Real code. The things nobody explains in documentation.&lt;/p&gt;

&lt;p&gt;It’s called &lt;a href=&quot;https://harmlessdspy.com&quot;&gt;Harmless DSPy&lt;/a&gt;. Chapter 1 is free if you want to see if it’s your thing.&lt;/p&gt;

&lt;p&gt;DSPy is developed by Omar Khattab and team at Stanford NLP. It’s open source, actively maintained, and genuinely changed how I build with LLMs.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;If you’re interested in DSPy, I also wrote about &lt;a href=&quot;/using-dspy-with-gpt-vision/&quot;&gt;using DSPy with GPT Vision&lt;/a&gt; for extracting structured data from images, and &lt;a href=&quot;/building-knowledge-graphs-using-dspy/&quot;&gt;building knowledge graphs with DSPy&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="dspy" /><category term="llm" /><category term="python" /><category term="machine-learning" /><summary type="html">I spent two years prompting LLMs before I found DSPy.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/dspy-framework.jpg" /><media:content medium="image" url="https://aliirz.com/images/dspy-framework.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Spec-Driven Development with AI: Why Your AI Is Guessing (And How to Stop It)</title><link href="https://aliirz.com/why-your-ai-is-guessing" rel="alternate" type="text/html" title="Spec-Driven Development with AI: Why Your AI Is Guessing (And How to Stop It)" /><published>2026-04-03T00:00:00+00:00</published><updated>2026-04-03T00:00:00+00:00</updated><id>https://aliirz.com/why-your-ai-is-guessing</id><content type="html" xml:base="https://aliirz.com/why-your-ai-is-guessing">&lt;p&gt;There’s a moment every developer has felt. You give an AI a task. It comes back confident, producing code that almost works. The logic is plausible. The syntax is clean. And then you realize it invented a function that doesn’t exist, picked the wrong library, or quietly changed a data model three files away from where you were looking.&lt;/p&gt;

&lt;p&gt;You call it a hallucination. I call it a communication failure.&lt;/p&gt;

&lt;p&gt;The AI did not fail you. You failed to brief it.&lt;/p&gt;

&lt;h2 id=&quot;the-briefing-problem&quot;&gt;The Briefing Problem&lt;/h2&gt;

&lt;p&gt;Think about how you actually hand off work to a contractor. You don’t walk up to a plumber and say “fix the water situation in the kitchen, you’ll figure it out.” You describe the symptoms, show them the pipes, tell them what you’ve already tried, specify what can’t be touched, and agree on what done looks like.&lt;/p&gt;

&lt;p&gt;AI agents are contractors. Very fast, very literal contractors who will execute exactly what you communicate to them, not what you meant. The gap between what you mean and what you say is where every hallucination lives.&lt;/p&gt;

&lt;p&gt;Most developers are still in the “you’ll figure it out” phase. They write a sentence or two, hit enter, and treat the output like a lottery ticket. Sometimes it’s great. More often it’s plausible garbage that takes longer to fix than to rewrite.&lt;/p&gt;

&lt;p&gt;Spec-Driven Development is the system that closes that gap.&lt;/p&gt;

&lt;h2 id=&quot;what-sdd-actually-is&quot;&gt;What SDD Actually Is&lt;/h2&gt;

&lt;p&gt;SDD is not a tool. It’s not a library. It’s a communication discipline.&lt;/p&gt;

&lt;p&gt;The core idea: before you let an AI write code, you write a structured document that captures your intent, your context, your constraints, and your definition of done. That document is the spec. The AI executes against the spec, not against your vibes.&lt;/p&gt;

&lt;p&gt;There are four things a good spec contains:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context.&lt;/strong&gt; What problem are you solving and why does it exist? The AI needs to understand the shape of the situation before it touches anything. “Add a login screen” is ambiguous. “Add a login screen to a React Native app using Expo Router, where the auth session is managed by Supabase, and the design system uses NativeWind” is not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints.&lt;/strong&gt; What is not negotiable? The library. The naming convention. The folder structure. The error handling approach. Constraints are not limitations on the AI. They’re the boundaries inside which creativity is actually useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tasks.&lt;/strong&gt; What are the atomic steps to get from here to done? A task is small enough that the AI can complete it without asking a clarifying question. If a task requires judgment, it needs to be two tasks with the judgment made in writing first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Acceptance criteria.&lt;/strong&gt; What does done look like? If you can’t write this down, you don’t actually know what you want yet. That’s fine. Write it down until you do. The spec catches unclear thinking before it becomes unclear code.&lt;/p&gt;

&lt;h2 id=&quot;a-concrete-before-and-after&quot;&gt;A Concrete Before and After&lt;/h2&gt;

&lt;p&gt;Here’s the kind of prompt that produces lottery-ticket results:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Build a user profile screen that shows the user’s info and lets them edit it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And here’s what that looks like when you brief it properly:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;Context:
We&apos;re adding a profile screen to an existing React Native app using
Expo Router. User data lives in Supabase under the `profiles` table.
Auth is already configured.

Constraints:
- Use NativeWind for all styling. No new dependencies.
- Edit form must handle optimistic updates and roll back on failure.
- Use existing Button and TextInput components from @/components/ui.

Tasks:
1. Create app/(tabs)/profile.tsx with read-only view of display_name,
   avatar_url, and bio
2. Add Edit button that toggles inline form fields for those three values
3. On save, call updateProfile() with optimistic UI update, roll back on error
4. Show loading skeleton during initial data fetch

Done when:
- User can view and edit profile without a full page reload
- Changes persist in Supabase
- Errors show a toast notification&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Same feature. Completely different conversation. The second one produces code you can actually ship.&lt;/p&gt;

&lt;h2 id=&quot;this-is-not-more-work&quot;&gt;This Is Not More Work&lt;/h2&gt;

&lt;p&gt;The pushback I always hear: “that takes too long, I’ll just iterate faster.”&lt;/p&gt;

&lt;p&gt;You won’t. You’ll iterate at the same speed, but the iterations will be bigger and more expensive. Fixing a wrong architectural decision in week three costs ten times more than writing a constraint in week one. The spec looks like overhead until you’ve spent two hours untangling code that confidently went in the wrong direction.&lt;/p&gt;

&lt;p&gt;Writing a spec for a focused feature takes ten minutes. It saves you the first revision almost every time.&lt;/p&gt;

&lt;p&gt;The other thing: once you have the spec, you have the documentation. You don’t have to write it later. You don’t have to reverse-engineer intent from code six months from now. The spec is the paper trail. Check it into git next to the code and it stays honest.&lt;/p&gt;

&lt;h2 id=&quot;the-agentsmd-concept&quot;&gt;The AGENTS.md Concept&lt;/h2&gt;

&lt;p&gt;Here’s how seriously the best SDD tooling takes this communication problem. OpenSpec has a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AGENTS.md&lt;/code&gt; — sometimes described as “a README for robots.” It’s not documentation for humans. It’s a document where you tell your AI agents exactly how to read your project, how to format their output, and how to follow your workflow.&lt;/p&gt;

&lt;p&gt;Think about that for a second. You’re writing instructions for the AI about how to receive instructions. That’s the level of explicitness that actually eliminates guessing. Most hallucinations happen not because the AI is wrong, but because it filled in a gap you didn’t know existed. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AGENTS.md&lt;/code&gt; closes those gaps at the system level, not feature by feature.&lt;/p&gt;

&lt;p&gt;You don’t need a special tool to start doing this. A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CLAUDE.md&lt;/code&gt; or a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AGENTS.md&lt;/code&gt; in your project root, with your stack, your conventions, and your non-negotiables, gets you 80% of the way there today.&lt;/p&gt;

&lt;h2 id=&quot;the-mindset-shift&quot;&gt;The Mindset Shift&lt;/h2&gt;

&lt;p&gt;The real change isn’t in your tools. It’s in how you see your role.&lt;/p&gt;

&lt;p&gt;When you vibe code, you’re a typist hoping the AI figures it out. When you spec, you’re a systems designer who gives the AI something solid to execute against.&lt;/p&gt;

&lt;p&gt;That shift feels small. The results are not.&lt;/p&gt;

&lt;p&gt;In the next article in this series, I’m going to break down the anatomy of a great spec in detail, with a real project and annotated templates you can steal. If you want to follow along, the companion template is below.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Next in the series:&lt;/strong&gt; &lt;a href=&quot;#&quot;&gt;Anatomy of a Great Spec&lt;/a&gt; (coming next)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Companion asset:&lt;/strong&gt; &lt;a href=&quot;https://github.com/aliirz/sdd-series/blob/main/01-spec-vs-prompt-cheatsheet.md&quot;&gt;Spec vs. Prompt Cheat Sheet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Fission-AI/OpenSpec&quot;&gt;OpenSpec on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://aliirz.com/getting-started-with-sdd&quot;&gt;Getting Started with SDD&lt;/a&gt; (my original walkthrough)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://addyosmani.com/blog/good-spec/&quot;&gt;Addy Osmani: How to Write a Good Spec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Ali Raza</name></author><category term="sdd" /><category term="ai-agents" /><category term="openspec" /><category term="spec-driven-development" /><summary type="html">There’s a moment every developer has felt. You give an AI a task. It comes back confident, producing code that almost works. The logic is plausible. The syntax is clean. And then you realize it invented a function that doesn’t exist, picked the wrong library, or quietly changed a data model three files away from where you were looking.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/ai-guessing.png" /><media:content medium="image" url="https://aliirz.com/images/ai-guessing.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Made it show its work</title><link href="https://aliirz.com/phntm-update-show-your-work" rel="alternate" type="text/html" title="Made it show its work" /><published>2026-03-30T00:00:00+00:00</published><updated>2026-03-30T00:00:00+00:00</updated><id>https://aliirz.com/phntm-update-show-your-work</id><content type="html" xml:base="https://aliirz.com/phntm-update-show-your-work">&lt;p&gt;I wrote about &lt;a href=&quot;https://phntm.sh&quot;&gt;phntm.sh&lt;/a&gt; a few weeks ago. The short version: a file sharing tool that encrypts in your browser, puts the key in the URL fragment, and forgets the ciphertext when the timer runs out. I literally cannot read your file.&lt;/p&gt;

&lt;p&gt;Since then I’ve been heads down. Here’s what changed and why.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;The landing page was lying by omission.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not intentionally. But it said “encrypted, self-destructing file sharing” without explaining what that actually means. Most people read that and think: encrypted somewhere on a server, probably. A checkbox someone ticked.&lt;/p&gt;

&lt;p&gt;So I rewrote it. The new hero says what’s actually happening — your file encrypts &lt;em&gt;in your browser&lt;/em&gt; before it goes anywhere. The decryption key never touches the server. There’s a WHY section now that explains zero-knowledge, not as a buzzword, but as a specific technical decision with real consequences.&lt;/p&gt;

&lt;p&gt;It also lists who this is actually built for: journalists, lawyers, developers. People who’ve had reasons to care about this stuff before the rest of us did.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;The encryption is visible now.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the change I’m most proud of.&lt;/p&gt;

&lt;p&gt;When you upload a file, the UI now shows you the cipher algorithm and key size in real-time. AES-256-GCM. 256-bit key. Client-side. You can watch it happen. The status text cycles through glyphs before resolving — like a terminal decoding something. A bit theatrical, but also accurate.&lt;/p&gt;

&lt;p&gt;I added this to downloads too. When someone receives your file, they see the same details. Cipher. Key size. Client-side processing.&lt;/p&gt;

&lt;p&gt;The reason this matters: trust isn’t a paragraph in a privacy policy. Trust is watching the lock turn. When encryption is invisible, it might as well not be there from a user’s perspective. Making it visible makes the claim real.&lt;/p&gt;

&lt;p&gt;I also strip the URL fragment from analytics. The key is in the fragment. Analytics never see it. That needed to be airtight.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;The CLI actually tells you what’s happening now.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The CLI went from “it works” to “it feels good to use.”&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phntm send&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phntm get&lt;/code&gt; now have step tracking. You see each stage: encrypting, uploading, done. Progress bars. Proper handling when the output file already exists (increments instead of clobbering). The ANSI rendering was cleaned up so it doesn’t break on weird terminals.&lt;/p&gt;

&lt;p&gt;Before this it was a pipe. Now it feels like a tool.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;A note on what I fixed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There was a bug where the CLI was getting 403 errors from the server because the origin check was too strict. The CLI sends an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-Phntm-Client&lt;/code&gt; header and the server was rejecting it. Fixed. Also found that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost&lt;/code&gt; with a port was failing origin comparisons because I was comparing the full origin string against just the hostname. Small bug, annoying to track down, obvious in retrospect.&lt;/p&gt;

&lt;p&gt;Ran a security audit. Patched the findings. Nothing dramatic.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Both the web app and the CLI are open source. The code is how you verify the claims.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aliirz/phntm.sh&quot;&gt;github.com/aliirz/phntm.sh&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aliirz/phntm-cli&quot;&gt;github.com/aliirz/phntm-cli&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If something seems off, open an issue. That’s the whole point.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="open-source" /><category term="privacy" /><category term="security" /><category term="phntm" /><category term="cli" /><summary type="html">I wrote about phntm.sh a few weeks ago. The short version: a file sharing tool that encrypts in your browser, puts the key in the URL fragment, and forgets the ciphertext when the timer runs out. I literally cannot read your file.</summary></entry><entry><title type="html">The Web Is A Cop And You Invited It In</title><link href="https://aliirz.com/the-web-is-a-cop" rel="alternate" type="text/html" title="The Web Is A Cop And You Invited It In" /><published>2026-03-22T00:00:00+00:00</published><updated>2026-03-22T00:00:00+00:00</updated><id>https://aliirz.com/the-web-is-a-cop</id><content type="html" xml:base="https://aliirz.com/the-web-is-a-cop">&lt;p&gt;A few months ago I wrote that we &lt;a href=&quot;/Remember-when-we-owned-our-files&quot;&gt;gave up file ownership without noticing&lt;/a&gt;. That we handed control to corporations not because it was better, but because it was easier. I ended with “we can build something better.”&lt;/p&gt;

&lt;p&gt;This is that something.&lt;/p&gt;

&lt;p&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/Q9-33j4bV7M?si=78tP6i4Vf6H6F31y&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;A file sharing service needs to do exactly one thing. Move bytes from point A to point B, then forget they existed. No accounts. No logs. No server that can read what you sent.&lt;/p&gt;

&lt;p&gt;The technology to do this has existed for over a decade. Client-side encryption. URL fragments that browsers never send to servers. AES-256-GCM. None of this is new. Nobody bothered because collecting your data was always more profitable than respecting it.&lt;/p&gt;

&lt;p&gt;So I built &lt;a href=&quot;https://phntm.sh&quot;&gt;phntm.sh&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Your file gets encrypted in your browser before it goes anywhere. The decryption key lives in the URL fragment, which means I never receive it. All I store is ciphertext. Noise. I literally cannot read your file. When the timer expires, the ciphertext is destroyed. Nothing to subpoena. Nothing to leak.&lt;/p&gt;

&lt;p&gt;The web app and CLI are both open source because “trust me” is not an architecture.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Web app: &lt;a href=&quot;https://github.com/aliirz/phntm.sh&quot;&gt;github.com/aliirz/phntm.sh&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;CLI: &lt;a href=&quot;https://github.com/aliirz/phntm-cli&quot;&gt;github.com/aliirz/phntm-cli&lt;/a&gt; / &lt;a href=&quot;https://phntm.sh/cli&quot;&gt;phntm.sh/cli&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Ali Raza</name></author><category term="open-source" /><category term="privacy" /><category term="security" /><category term="zero-knowledge" /><category term="encryption" /><summary type="html">A few months ago I wrote that we gave up file ownership without noticing. That we handed control to corporations not because it was better, but because it was easier. I ended with “we can build something better.”</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/own-the-web.jpg" /><media:content medium="image" url="https://aliirz.com/images/own-the-web.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Spec-Driven Development Made Easy: A Practical Guide with OpenSpec</title><link href="https://aliirz.com/getting-started-with-sdd" rel="alternate" type="text/html" title="Spec-Driven Development Made Easy: A Practical Guide with OpenSpec" /><published>2026-01-30T00:00:00+00:00</published><updated>2026-01-30T00:00:00+00:00</updated><id>https://aliirz.com/getting-started-with-sdd</id><content type="html" xml:base="https://aliirz.com/getting-started-with-sdd">&lt;p&gt;I’ve been vibe coding for the better part of a year. You know the drill. Open Cursor or Claude Code, type something like “build me a login screen with Google auth,” and hope for the best. Sometimes it works great. Sometimes the AI hallucinates a library that doesn’t exist, picks a routing strategy you hate, or quietly breaks something three files away.&lt;/p&gt;

&lt;p&gt;The problem isn’t the AI. It’s us. We treat coding agents like search engines when we should be treating them like literal-minded pair programmers. They’re excellent at following instructions. We’re just bad at giving them.&lt;/p&gt;

&lt;p&gt;That’s where Spec-Driven Development comes in.&lt;/p&gt;

&lt;h2 id=&quot;what-is-spec-driven-development&quot;&gt;What Is Spec-Driven Development?&lt;/h2&gt;

&lt;p&gt;Spec-driven development (SDD) flips the script. Instead of coding first and documenting later, you write structured intent that AI agents execute to generate the implementation. The specification is the source of truth, not the code.&lt;/p&gt;

&lt;p&gt;Think of it like this: you wouldn’t hand a contractor a vague description and say “build me a house, you’ll figure it out.” You’d give them blueprints. SDD is blueprints for AI agents.&lt;/p&gt;

&lt;p&gt;The workflow breaks into four phases:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Specify&lt;/strong&gt; - Write a plain-language markdown file defining the &lt;em&gt;what&lt;/em&gt; and &lt;em&gt;why&lt;/em&gt;. User goals, requirements, acceptance criteria. No technical “how-to” details yet.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Plan&lt;/strong&gt; - Layer in the technical context. Tech stack, architectural patterns, security constraints. This is the “how” at a high level.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tasks&lt;/strong&gt; - Break the plan into small, reviewable steps. Each task should be atomic enough for an AI agent to implement without further clarification.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Implement&lt;/strong&gt; - Feed these artifacts to an AI agent to generate code and tests that strictly adhere to the spec.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;why-not-just-vibe-code&quot;&gt;Why Not Just Vibe Code?&lt;/h2&gt;

&lt;p&gt;Three reasons I keep coming back to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reduced hallucinations.&lt;/strong&gt; Clear constraints in a spec prevent the AI from making “creative” guesses that cause bugs. When you tell it “use expo-router for navigation,” it doesn’t surprise you with react-navigation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Living documentation.&lt;/strong&gt; The spec is version-controlled next to the code. It never becomes a dusty artifact nobody reads. It &lt;em&gt;is&lt;/em&gt; the thing that drives development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Better code reviews.&lt;/strong&gt; Reviewers evaluate changes against the original intent rather than trying to reverse-engineer the logic from code. “Does this match what we said we’d build?” is a much easier question than “What is this code trying to do?”&lt;/p&gt;

&lt;h2 id=&quot;the-tools&quot;&gt;The Tools&lt;/h2&gt;

&lt;p&gt;Several toolkits now automate the management of specifications:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/github/spec-kit&quot;&gt;&lt;strong&gt;GitHub Spec Kit&lt;/strong&gt;&lt;/a&gt; - An open-source toolkit providing slash commands (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/speckit.specify&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/speckit.plan&lt;/code&gt;) to automate branch creation, template generation, and task breakdown. Works with Copilot, Claude Code, and Gemini CLI.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://kiro.dev/&quot;&gt;&lt;strong&gt;Amazon Kiro&lt;/strong&gt;&lt;/a&gt; - An agentic development tool that guides you through requirements and design phases directly within an integrated environment.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Fission-AI/OpenSpec&quot;&gt;&lt;strong&gt;OpenSpec&lt;/strong&gt;&lt;/a&gt; - A lightweight layer for brownfield &lt;em&gt;and&lt;/em&gt; greenfield development that helps align humans and AI on changes before code is written. Supports 24 AI tools.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://tessl.io/&quot;&gt;&lt;strong&gt;Tessl&lt;/strong&gt;&lt;/a&gt; - A platform where the specification itself is the maintained artifact, allowing code to be continuously regenerated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this walkthrough, I’m using OpenSpec. It’s lightweight, open-source, and works with whatever AI coding assistant you already have.&lt;/p&gt;

&lt;h2 id=&quot;building-a-mobile-app-with-openspec-the-full-walkthrough&quot;&gt;Building a Mobile App with OpenSpec: The Full Walkthrough&lt;/h2&gt;

&lt;p&gt;Let’s say I want to build a React Native mobile app from scratch. Here’s how I’d approach it using SDD with OpenSpec. The core loop is: &lt;strong&gt;Propose → Plan → Implement → Archive&lt;/strong&gt;. You never just “ask” the AI to write code. You ask it to create a Change Proposal, align on the details, and only &lt;em&gt;then&lt;/em&gt; authorize it to code.&lt;/p&gt;

&lt;h3 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Node.js&lt;/strong&gt; (v20.19+)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;AI Coding Assistant&lt;/strong&gt;: Claude Code, Cursor, or Windsurf work best since they can read your file structure and run terminal commands&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;phase-1-initialization--the-constitution&quot;&gt;Phase 1: Initialization &amp;amp; The “Constitution”&lt;/h3&gt;

&lt;p&gt;Before building anything, install the tool and set the ground rules.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;npm &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; @fission-ai/openspec@latest

&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;my-mobile-app
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;my-mobile-app

openspec init&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This creates an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openspec/&lt;/code&gt; folder in your project.&lt;/p&gt;

&lt;p&gt;Now the crucial part. Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openspec/project.md&lt;/code&gt; and edit it manually. This is your project’s constitution — the non-negotiable constraints every future spec must respect.&lt;/p&gt;

&lt;p&gt;Mine looks something like:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This is a React Native app using Expo. We use TypeScript, Tailwind (via NativeWind) for styling, and Supabase for the backend. All navigation uses expo-router. We follow atomic design principles for components.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the single most important file in the whole process. OpenSpec injects this context into every artifact it generates — proposals, designs, tasks. It’s how you stop the AI from “forgetting” your stack choices halfway through Phase 4.&lt;/p&gt;

&lt;h3 id=&quot;phase-2-the-base-build-your-first-change&quot;&gt;Phase 2: The Base Build (Your First Change)&lt;/h3&gt;

&lt;p&gt;Instead of manually running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npx create-expo-app&lt;/code&gt;, treat the project setup as your first spec change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start the change:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your AI chat (Cursor, Claude Code, etc.), type:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:new setup-project&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Prompt: &lt;em&gt;“Create a proposal to scaffold a new React Native app with Expo and TypeScript. Include a basic home screen.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate the plan:&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:ff&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s “Fast Forward.” It generates the Proposal, Spec, Design, and Tasks all at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review the artifacts (this is the SDD magic):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don’t let the AI code yet. Open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openspec/changes/setup-project/&lt;/code&gt; folder and check:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;proposal.md&lt;/strong&gt; — Does it understand &lt;em&gt;why&lt;/em&gt; we’re doing this?&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;design.md&lt;/strong&gt; — Did it pick the right libraries? If it chose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;react-navigation&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;expo-router&lt;/code&gt;, correct it here. Before a single line of code exists.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;tasks.md&lt;/strong&gt; — Are the steps specific and atomic? “Run init command,” “Create directory structure,” “Configure TypeScript.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where SDD earns its keep. You catch architectural misalignment &lt;em&gt;before&lt;/em&gt; it becomes 500 lines of wrong code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implement:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you’re satisfied with the artifacts:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:apply&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The AI executes the tasks file line by line — running terminal commands to scaffold the app, writing the initial code, all within the constraints you defined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Archive:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verify the app runs in your emulator, then:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:archive&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This merges your change into the “Main Spec” and clears the stage for the next feature.&lt;/p&gt;

&lt;h3 id=&quot;phase-3-the-development-loop&quot;&gt;Phase 3: The Development Loop&lt;/h3&gt;

&lt;p&gt;Now you build every feature — Login, Profile, Camera, whatever — using the same cycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Adding a Login Screen&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:new login-flow&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Prompt: &lt;em&gt;“I need a login screen. It should support Email/Password and Google Auth. Use a dark theme consistent with our existing design tokens.”&lt;/em&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:ff&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now review:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Did the spec include error states? (Password too short, network failure, invalid email)&lt;/li&gt;
  &lt;li&gt;Is the design reusing your existing Button components or creating new ones?&lt;/li&gt;
  &lt;li&gt;Does the tasks list include writing tests?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If anything’s off, edit the markdown files directly. Then:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:apply&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Test the login. If it works:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;/opsx:archive&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Rinse, repeat. Every feature follows the same loop.&lt;/p&gt;

&lt;h2 id=&quot;what-ive-learned-so-far&quot;&gt;What I’ve Learned So Far&lt;/h2&gt;

&lt;p&gt;SDD isn’t magic. It doesn’t guarantee perfect code. But it does three things that vibe coding can’t:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It forces you to think before you build.&lt;/strong&gt; Writing a spec is harder than typing a prompt. That difficulty is the point. You catch bad ideas when they’re cheap to fix — in a markdown file, not in a tangled dependency graph.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It gives you a paper trail.&lt;/strong&gt; When something breaks in month three, you don’t have to reverse-engineer intent from code. The spec tells you what you meant. The design tells you why you chose that approach. The tasks tell you what was supposed to happen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It makes AI agents dramatically more reliable.&lt;/strong&gt; Constraints reduce hallucinations. A well-specified task with clear boundaries produces better code than a vague open-ended prompt every single time.&lt;/p&gt;

&lt;p&gt;The biggest mindset shift? Stop thinking of the AI as a coder. Think of it as a very fast, very literal contractor. You’re the architect. The spec is the blueprint. The code is just the construction.&lt;/p&gt;

&lt;h2 id=&quot;try-it&quot;&gt;Try It&lt;/h2&gt;

&lt;p&gt;If you want to get started, the barrier is low:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;npm &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; @fission-ai/openspec@latest
&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;your-project &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;your-project
openspec init&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Edit your constitution. Write your first spec. Let the AI build from there.&lt;/p&gt;

&lt;p&gt;Because the future of AI-assisted development isn’t about writing better prompts. It’s about writing better specs.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Fission-AI/OpenSpec&quot;&gt;OpenSpec on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/github/spec-kit&quot;&gt;GitHub Spec Kit&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.thoughtworks.com/en-us/insights/blog/agile-engineering-practices/spec-driven-development-unpacking-2025-new-engineering-practices&quot;&gt;Thoughtworks: Spec-Driven Development&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.redhat.com/articles/2025/10/22/how-spec-driven-development-improves-ai-coding-quality&quot;&gt;Red Hat: How SDD Improves AI Coding Quality&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.blog/ai-and-ml/generative-ai/spec-driven-development-with-ai-get-started-with-a-new-open-source-toolkit/&quot;&gt;GitHub Blog: Spec-Driven Development with AI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@danielmccullough?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Daniel McCullough&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/photos/-FPFq_trr2Y?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="sdd" /><category term="openspec" /><category term="ai-agents" /><category term="mobile-dev" /><summary type="html">I’ve been vibe coding for the better part of a year. You know the drill. Open Cursor or Claude Code, type something like “build me a login screen with Google auth,” and hope for the best. Sometimes it works great. Sometimes the AI hallucinates a library that doesn’t exist, picks a routing strategy you hate, or quietly breaks something three files away.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/sdd-blueprint.jpg" /><media:content medium="image" url="https://aliirz.com/images/sdd-blueprint.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Writing code that writes code</title><link href="https://aliirz.com/writing-code-that-writes-code" rel="alternate" type="text/html" title="Writing code that writes code" /><published>2025-09-19T00:00:00+00:00</published><updated>2025-09-19T00:00:00+00:00</updated><id>https://aliirz.com/writing-code-that-writes-code</id><content type="html" xml:base="https://aliirz.com/writing-code-that-writes-code">&lt;p&gt;I built a multi-agent system because I could. Not because the world needs another coding assistant. We have Cursor, VS Code with Copilot, Windsurf, Replit Agent, Lovable. They all do this better than what I made.&lt;/p&gt;

&lt;p&gt;But I wanted to see what happens when you give different AI agents different tools and watch them try to collaborate. Mostly out of curiosity. I have built multi agent systems before but never with the Claude Code SDK.&lt;/p&gt;

&lt;h2 id=&quot;the-setup&quot;&gt;The Setup&lt;/h2&gt;

&lt;p&gt;Four specialized agents:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;File Manager: Creates and edits files&lt;/li&gt;
  &lt;li&gt;Code Executor: Runs commands and code&lt;/li&gt;
  &lt;li&gt;Analyst: Reviews and audits code&lt;/li&gt;
  &lt;li&gt;Coordinator: Plans and delegates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each agent only gets the tools it needs. No more, no less. File Manager can’t execute code. Code Executor can’t analyze patterns. Real separation of concerns.&lt;/p&gt;

&lt;h2 id=&quot;what-happens&quot;&gt;What Happens&lt;/h2&gt;

&lt;p&gt;Ask it to build a FastAPI server and something interesting happens. The agents start talking to each other through their actions:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;file_manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Creates&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;py &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bugs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;code_executor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Tries&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fails&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;analyst&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Points&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;file_manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Fixes&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;code_executor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Runs&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;again&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;works&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The code they write is actually decent. Clean structure, proper error handling, reasonable patterns. Good enough for prototypes you’d actually use.&lt;/p&gt;

&lt;h2 id=&quot;the-code&quot;&gt;The Code&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run_agent_task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;agent_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AgentType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;_create_agent_options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;agent_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ClaudeSDKClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;receive_response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# Actually creates files, runs commands, etc.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Using ClaudeSDKClient gives you real power. Not just text completion. Actual file system access. Actual command execution.&lt;/p&gt;

&lt;h2 id=&quot;what-im-learning&quot;&gt;What I’m Learning&lt;/h2&gt;

&lt;p&gt;The main thing is watching what happens when you force specialization. When the File Manager agent can’t run code, it has to write more carefully. When the Code Executor hits errors, it has to ask for help.&lt;/p&gt;

&lt;p&gt;It’s like pair programming, but with artificial constraints that force actual collaboration.&lt;/p&gt;

&lt;h2 id=&quot;what-it-actually-builds&quot;&gt;What It Actually Builds&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;A working FastAPI server with proper routing&lt;/li&gt;
  &lt;li&gt;A data scraper that handles errors gracefully&lt;/li&gt;
  &lt;li&gt;A web dashboard with actual functionality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not groundbreaking, but solid prototypes you could build on. The kind of code you’d write yourself if you were moving fast.&lt;/p&gt;

&lt;h2 id=&quot;why-bother&quot;&gt;Why Bother?&lt;/h2&gt;

&lt;p&gt;Honestly? Because I was bored and the Claude Code SDK was sitting there. Building something that builds something else felt like a fun weekend project.&lt;/p&gt;

&lt;p&gt;Sure, it’s inefficient compared to just using Cursor. But efficiency wasn’t the point. Curiosity was.&lt;/p&gt;

&lt;h2 id=&quot;what-i-learned&quot;&gt;What I Learned&lt;/h2&gt;

&lt;p&gt;Building this taught me more about the Claude SDK than any documentation would. Watching agents fail and recover gave me ideas for how to structure my own code better.&lt;/p&gt;

&lt;p&gt;Also, there’s something satisfying about building a system that builds systems. Even if those systems are basic. Even if better tools exist.&lt;/p&gt;

&lt;p&gt;Sometimes you build things just to see if you can. This was one of those times.&lt;/p&gt;

&lt;p&gt;The code is on &lt;a href=&quot;https://github.com/aliirz/ai-agents-experiment&quot;&gt;GitHub&lt;/a&gt; if you want to mess with it. It’s actually pretty useful for quick prototypes.&lt;/p&gt;

&lt;p&gt;Because sometimes the most important thing isn’t what works perfectly. It’s what works at all.&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@agforl24?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Tai Bui&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/photos/a-cat-sitting-on-top-of-a-laptop-computer-iPsOfXA79U4?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="claude" /><category term="ai-agents" /><category term="experiment" /><summary type="html">I built a multi-agent system because I could. Not because the world needs another coding assistant. We have Cursor, VS Code with Copilot, Windsurf, Replit Agent, Lovable. They all do this better than what I made.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Cat-Coding-Picture.jpg" /><media:content medium="image" url="https://aliirz.com/images/Cat-Coding-Picture.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Remember when we owned our files?</title><link href="https://aliirz.com/Remember-when-we-owned-our-files" rel="alternate" type="text/html" title="Remember when we owned our files?" /><published>2025-08-05T00:00:00+00:00</published><updated>2025-08-05T00:00:00+00:00</updated><id>https://aliirz.com/Remember-when-we-owned-our-files</id><content type="html" xml:base="https://aliirz.com/Remember-when-we-owned-our-files">&lt;p&gt;There was a time when we controlled our data.
You didn’t need permission from a company to send someone a file. You didn’t need an account. You didn’t need to agree to anything. You just shared it. One computer talked to another. That was enough.&lt;/p&gt;

&lt;p&gt;It wasn’t perfect. It broke sometimes. But it worked. And it belonged to us.&lt;/p&gt;

&lt;p&gt;Now, every photo, document, or message has to pass through someone else’s server. We hand it over. We wait. We trust. Most people don’t even think about it. They’ve been told this is just how the internet works.&lt;/p&gt;

&lt;p&gt;But it’s not how the internet was designed. It’s not how it has to be.&lt;/p&gt;

&lt;p&gt;We’ve centralized everything. We’ve given up control. We’ve accepted that our files live in someone else’s system, under someone else’s rules. Not because it’s better. Because it’s easier. Because it’s what we were told to do.&lt;/p&gt;

&lt;p&gt;And in doing that, we gave up something important. Autonomy. Privacy. Simplicity. The idea that two people can talk to each other without a corporation sitting in between.&lt;/p&gt;

&lt;p&gt;We can do better. The tools exist. Encryption is stronger. Networks are faster. We can build systems that are secure, private, and truly ours.&lt;/p&gt;

&lt;p&gt;But we have to care enough to try.&lt;/p&gt;

&lt;p&gt;We have to remember what we had. And why we gave it up.&lt;/p&gt;

&lt;p&gt;Not to go back. But to build something better.&lt;/p&gt;

&lt;p&gt;And this time, to keep it.&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@jontyson?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Jon Tyson&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/photos/a-pile-of-old-photos-and-postcards-sitting-on-top-of-each-other-P2aOvMMUJnY?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="tech" /><category term="nostalgia" /><summary type="html">There was a time when we controlled our data. You didn’t need permission from a company to send someone a file. You didn’t need an account. You didn’t need to agree to anything. You just shared it. One computer talked to another. That was enough.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Nostalgia%20Picture%20from%20Unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/Nostalgia%20Picture%20from%20Unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TICTeC 2025</title><link href="https://aliirz.com/tictec-2025" rel="alternate" type="text/html" title="TICTeC 2025" /><published>2025-07-22T00:00:00+00:00</published><updated>2025-07-22T00:00:00+00:00</updated><id>https://aliirz.com/tictec-2025</id><content type="html" xml:base="https://aliirz.com/tictec-2025">&lt;p&gt;Sometimes I hate the fact that I was born in Pakistan… well, not sometimes, just whenever my visa gets rejected for no clear reason.&lt;/p&gt;

&lt;p&gt;This year I was invited to speak at TICTeC 2025 in Belgium. I was super excited as I would get a chance to talk about my passion for AI and democracy. I was going to present Numainda as a case study. The TICTeC team made sure I had tickets and reservations all set up.&lt;/p&gt;

&lt;p&gt;I applied for my visa at VFS’s new office in Chata Bakhtawar. The whole process itself was time-consuming and cumbersome. My visa appointment was set at 10 am and I got free from it all finally around 6 pm. They don’t allow you to take phones with you and make you run for exchanging currency to euros, just FYI.&lt;/p&gt;

&lt;p&gt;Khair, I applied grinding my teeth at all times and then I waited. With the date for the conference fast approaching, I realized that I would not be able to get it on time. I tried everything I could to learn more about it but to no avail.&lt;/p&gt;

&lt;p&gt;Gemma and her team offered me to present virtually, which I accepted gladly. So here is my talk:&lt;/p&gt;

&lt;p&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/2Zuez5TBDK4?si=hCtyyViuPiiw_U_V&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;While the visa process was frustrating and ultimately unsuccessful, this experience taught me that opportunities can still come through alternative means. The TICTeC team’s flexibility and willingness to accommodate virtual participation shows that the global tech community values diverse voices, regardless of bureaucratic hurdles.&lt;/p&gt;

&lt;p&gt;I hope that one day, Pakistani citizens won’t have to face such lengthy and uncertain visa processes. One can only hope 🥹.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="tictec" /><summary type="html">Sometimes I hate the fact that I was born in Pakistan… well, not sometimes, just whenever my visa gets rejected for no clear reason.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/presenting-at-tictec.jpg" /><media:content medium="image" url="https://aliirz.com/images/presenting-at-tictec.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Chain of Draft (CoD): Making LLMs Think Like Humans on a Deadline</title><link href="https://aliirz.com/chain-of-draft" rel="alternate" type="text/html" title="Chain of Draft (CoD): Making LLMs Think Like Humans on a Deadline" /><published>2025-04-15T00:00:00+00:00</published><updated>2025-04-15T00:00:00+00:00</updated><id>https://aliirz.com/chain-of-draft</id><content type="html" xml:base="https://aliirz.com/chain-of-draft">&lt;p&gt;Ever watched someone solve a tough problem while pacing, scribbling half-sentences, muttering “carry the two…” under their breath? That’s how we humans reason. We don’t narrate full essays in our heads. We sketch ideas. And that’s &lt;em&gt;exactly&lt;/em&gt; the vibe of Chain of Draft (CoD).&lt;/p&gt;

&lt;p&gt;CoD is like giving your LLM a sticky note and saying: “Solve this, but keep it tight. No TED Talks.”&lt;/p&gt;

&lt;h3 id=&quot;so-what-is-chain-of-draft-really&quot;&gt;So what is Chain of Draft, really?&lt;/h3&gt;

&lt;p&gt;It’s a prompting strategy from a recent paper &lt;a href=&quot;https://arxiv.org/abs/2502.18600&quot;&gt;“Chain of Draft: Thinking Faster by Writing Less”&lt;/a&gt;. Instead of long-winded Chain of Thought (CoT) answers where the model explains every mental detour, CoD asks it to reason in fast, minimal bursts—5 words max per step.&lt;/p&gt;

&lt;p&gt;Imagine you’re doing mental math in a checkout line and the person behind you is sighing loudly. That’s CoD.&lt;/p&gt;

&lt;h3 id=&quot;why-should-you-care&quot;&gt;Why should you care?&lt;/h3&gt;

&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You get the same accuracy (sometimes better)&lt;/li&gt;
  &lt;li&gt;You save on tokens (92% fewer, no joke)&lt;/li&gt;
  &lt;li&gt;You get answers faster (less to compute = more speed)&lt;/li&gt;
  &lt;li&gt;It works on logic, arithmetic, QA, multi-hop tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is ideal when your app’s running a fleet of agents and one of them decides to write a memoir. CoD stops the oversharing.&lt;/p&gt;

&lt;h3 id=&quot;the-showdown-cod-vs-cot&quot;&gt;The Showdown: CoD vs CoT&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Feature&lt;/th&gt;
      &lt;th&gt;Chain of Thought (CoT)&lt;/th&gt;
      &lt;th&gt;Chain of Draft (CoD)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Style&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;Rambling essay&lt;/td&gt;
      &lt;td&gt;Bullet points with a mission&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Token Usage&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;High&lt;/td&gt;
      &lt;td&gt;Low (like, &lt;em&gt;really&lt;/em&gt; low)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Speed&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;Slower&lt;/td&gt;
      &lt;td&gt;Fast and snappy&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Accuracy&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;Great&lt;/td&gt;
      &lt;td&gt;Also great&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;$$$&lt;/td&gt;
      &lt;td&gt;$&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Interpretability&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;High&lt;/td&gt;
      &lt;td&gt;Medium (still readable though)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;try-it-yourself&quot;&gt;Try it Yourself&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;openai&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OpenAI&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Initialize the OpenAI client with your API key
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OpenAI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;chain_of_draft_prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;question&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;You&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;re a reasoning expert. Solve this problem using extremely 
    short steps (5 words max). Then, give the answer.

    Question: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;question&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;

    Steps:
&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Create a chat completion
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;completions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gpt-4o&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;chain_of_draft_prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;What’s 23 * 17?&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;temperature&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Print the assistant&apos;s reply
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;tldr&quot;&gt;TL;DR&lt;/h3&gt;

&lt;p&gt;Chain of Draft is the minimalist cousin of CoT. It doesn’t talk much, but it gets things done.&lt;/p&gt;

&lt;p&gt;Use it when:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You want results, not rambling&lt;/li&gt;
  &lt;li&gt;You’re running at scale&lt;/li&gt;
  &lt;li&gt;Token bills are getting ridiculous&lt;/li&gt;
  &lt;li&gt;Your agents are thinking like poets, not engineers&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Ali Raza</name></author><category term="llm" /><category term="prompt-technique" /><category term="chain-of-thought" /><category term="chain-of-draft" /><summary type="html">Ever watched someone solve a tough problem while pacing, scribbling half-sentences, muttering “carry the two…” under their breath? That’s how we humans reason. We don’t narrate full essays in our heads. We sketch ideas. And that’s exactly the vibe of Chain of Draft (CoD).</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/chain-of-draft.jpg" /><media:content medium="image" url="https://aliirz.com/images/chain-of-draft.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">All Things Devcast Episode 1</title><link href="https://aliirz.com/all-things-devcast" rel="alternate" type="text/html" title="All Things Devcast Episode 1" /><published>2025-01-28T00:00:00+00:00</published><updated>2025-01-28T00:00:00+00:00</updated><id>https://aliirz.com/all-things-devcast</id><content type="html" xml:base="https://aliirz.com/all-things-devcast">&lt;p&gt;I’ve launched All Things Devcast, my new podcast diving deep into the world of artificial intelligence and software development. This podcast aims to bridge the gap between cutting-edge AI technology and practical implementation in the developer’s world.&lt;/p&gt;

&lt;p&gt;In each episode, we’ll explore practical tips, engage in thought-provoking discussions, and share actionable insights that you can apply to your tech projects. Whether you’re a seasoned developer, tech leader, or just someone passionate about staying ahead in the rapidly evolving tech landscape, there’s something here for you. The first episode is now live! Check it out:&lt;/p&gt;

&lt;iframe width=&quot;100%&quot; height=&quot;180&quot; frameborder=&quot;no&quot; scrolling=&quot;no&quot; seamless=&quot;&quot; src=&quot;https://share.transistor.fm/e/3072595e?color=F90476&amp;amp;background=132852&quot;&gt;&lt;/iframe&gt;</content><author><name>Ali Raza</name></author><category term="podcast" /><category term="openai" /><category term="claude" /><category term="tech" /><category term="software" /><summary type="html">I’ve launched All Things Devcast, my new podcast diving deep into the world of artificial intelligence and software development. This podcast aims to bridge the gap between cutting-edge AI technology and practical implementation in the developer’s world.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Black_Headphones_on_Table.jpg" /><media:content medium="image" url="https://aliirz.com/images/Black_Headphones_on_Table.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Building Knowledge Graphs Using DSPy</title><link href="https://aliirz.com/building-knowledge-graphs-using-dspy" rel="alternate" type="text/html" title="Building Knowledge Graphs Using DSPy" /><published>2025-01-03T00:00:00+00:00</published><updated>2025-01-03T00:00:00+00:00</updated><id>https://aliirz.com/building-knowledge-graphs-using-dspy</id><content type="html" xml:base="https://aliirz.com/building-knowledge-graphs-using-dspy">&lt;p&gt;One of the coolest things I learned in 2024 was DSPy &lt;a href=&quot;https://github.com/stanfordnlp/dspy&quot;&gt;1&lt;/a&gt;. It’s a framework for programming LLMs (not prompting). It’s a great way to build LLM applications.&lt;/p&gt;

&lt;p&gt;We have helped build some cool applications using DSPy. We deployed a License information extractor at TRA &lt;a href=&quot;https://www.travelresorts.com/&quot;&gt;2&lt;/a&gt; and a couple of smart agents at Revreply &lt;a href=&quot;https://revreply.com/&quot;&gt;3&lt;/a&gt; for scoring and validating emails before they are sent out. I made my first ever open source contribution to DSPy in 2024 albeit small but still meaningful.&lt;/p&gt;

&lt;p&gt;At boostpanda we are working on the next generation RAG agent. One of the key aspects is utilizing knowledge graphs as well as memwalker to build a faster RAG pipeline. While it’s a work in progress, I thought why not demonstrate an example of how DSPy can be used to extract knowledge graphs from text.&lt;/p&gt;

&lt;p&gt;So in true indie hacker spirit, as part of my 100 days of AI challenge, I decided to build a DSPy program that extracts knowledge graphs from text:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;EntityRelations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BaseModel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;first_entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(...,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;The first entity in the relationship&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;relationship&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(...,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;The relationship between the two entities, should be a verb&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;second_entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(...,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;The second entity in the relationship&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;EntityExtraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Signature&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;The text to extract entities from&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EntityRelations&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Entities and their relationships extracted from the text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_entities_and_relations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extractor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Identify the main entities and their relationship in the sentence: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extractor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;model_dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;keys&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;first_entity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;relationship&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;second_entity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keys&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;build_knowledge_graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extractor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sent_tokenize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DiGraph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;entity1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;relationship&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;extract_entities_and_relations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extractor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add_node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add_node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add_edge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;relation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;relationship&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Failed to extract or add entities for the sentence &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;nf&quot;&gt;draw_knowledge_graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;draw_knowledge_graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;spring_layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;draw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;with_labels&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;node_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;node_color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;skyblue&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;edge_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get_edge_attributes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;relation&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;draw_networkx_edge_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;edge_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Knowledge Graph&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;configure_dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;userdata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ValueError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;API key for OpenAI is not set in environment variables.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OpenAI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gpt-4o&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;max_tokens&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;400&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;settings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TypedPredictor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EntityExtraction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;entity_extractor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;configure_dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;



&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
On a bright sunny day, not too far, not too near,
Lived two silly sisters, so full of cheer.
Anaya was seven, Liyana just five,
When they had an idea that came alive!

“Let’s build a machine!” Anaya declared.
“One that eats socks!” (Liyana just stared.)
“Why socks?” Liyana asked, scratching her head.
“Because eating bananas is boring,” she said.

So they grabbed a big pot and a very small spoon,
A trumpet, a toaster, and a bright red balloon.
They piled it all high, till it looked like a blob,
“This is perfect!” said Anaya, “Let’s call it Bob!”

Bob rumbled and grumbled, it clanked and it beeped,
Then suddenly WHOOSH! Out came a leap!
A sock shot out high, like a rocket in space,
It landed, of course, on poor Liyana’s face&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;build_knowledge_graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity_extractor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The output is a knowledge graph that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;images/graph.png&quot; alt=&quot;Knowledge Graph&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I am so excited about this. I think this is a great way to extract knowledge graphs from text.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="dspy" /><category term="knowledge-graphs" /><category term="tutorial" /><summary type="html">One of the coolest things I learned in 2024 was DSPy 1. It’s a framework for programming LLMs (not prompting). It’s a great way to build LLM applications.</summary></entry><entry><title type="html">Python Best Practices: Code This, Not That 🐍</title><link href="https://aliirz.com/python-best-practices" rel="alternate" type="text/html" title="Python Best Practices: Code This, Not That 🐍" /><published>2024-11-28T00:00:00+00:00</published><updated>2024-11-28T00:00:00+00:00</updated><id>https://aliirz.com/python-best-practices</id><content type="html" xml:base="https://aliirz.com/python-best-practices">&lt;p&gt;Writing Python code is easy, but writing &lt;em&gt;Pythonic&lt;/em&gt; code? That’s an art! Let’s explore some Python best practices that will level up your coding game. We’ll use these emojis to rate different code approaches:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;💩 Avoid this code&lt;/li&gt;
  &lt;li&gt;🤔 OK, but not utilizing Python’s features&lt;/li&gt;
  &lt;li&gt;🐍 Pythonic way&lt;/li&gt;
  &lt;li&gt;💡 Bonus tips&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;1-elegant-null-checks&quot;&gt;1. Elegant Null Checks&lt;/h2&gt;

&lt;p&gt;Let’s start with something we do all the time - checking if a variable is not null (None in Python).&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# 🤔 OK but verbose
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Claude&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Hello &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 Pythonic and clean
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Hello &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;💡 Pro tip: Use f-strings for string formatting. They’re more readable and faster than older methods!&lt;/p&gt;

&lt;h2 id=&quot;2-list-operations-like-a-pro&quot;&gt;2. List Operations Like a Pro&lt;/h2&gt;

&lt;h3 id=&quot;checking-if-an-item-exists&quot;&gt;Checking if an item exists&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;languages&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Python&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;JavaScript&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Ruby&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Python&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🤔 The long way
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;found&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;languages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;found&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 The Pythonic way
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;found&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;languages&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;list-comprehensions&quot;&gt;List Comprehensions&lt;/h3&gt;

&lt;p&gt;Want to transform a list? Forget the loops!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🤔 Traditional approach
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;squares&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;squares&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 Pythonic magic
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;squares&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 💡 Bonus: Dictionary comprehension
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;square_dict&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;3-the-power-of-any-and-all&quot;&gt;3. The Power of any() and all()&lt;/h2&gt;

&lt;p&gt;Need to check conditions across a collection? Python has your back!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;scores&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;85&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;92&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;78&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;88&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🤔 Old school way
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scores&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;passed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 Pythonic perfection
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passed&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scores&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 💡 Using any() for finding failing grades
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;has_failing&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;any&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scores&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;4-smart-iterations&quot;&gt;4. Smart Iterations&lt;/h2&gt;

&lt;p&gt;Stop counting indices when you don’t need to!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;apple&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;banana&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;cherry&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🤔 The index way
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;. &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 Pythonic enumeration
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fruit&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Start counting from 1
&lt;/span&gt;    &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;. &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruit&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 💡 Bonus: Parallel iteration with zip
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prices&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fruit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;price&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fruit&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: $&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;5-context-managers-the-safe-way&quot;&gt;5. Context Managers: The Safe Way&lt;/h2&gt;

&lt;p&gt;Always use context managers for resource handling:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# 💩 Dangerous way
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;data.txt&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Hello World!&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# What if an exception occurs before this?
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 🐍 Safe and clean
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;data.txt&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Hello World!&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# File closes automatically!&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;6-mutable-default-arguments&quot;&gt;6. Mutable Default Arguments&lt;/h2&gt;

&lt;p&gt;Here’s a common pitfall that even experienced Python developers sometimes miss:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# 💩 Dangerous way
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;append_to_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]):&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# DON&apos;T do this!
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# First call works as expected
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append_to_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# [1]
# But the second call might surprise you
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append_to_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# [1, 2] Oops!
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 🐍 Pythonic way
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;append_to_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;7-generator-expressions&quot;&gt;7. Generator Expressions&lt;/h2&gt;

&lt;p&gt;When working with large datasets, generators can save memory:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# 🤔 Memory-hungry way
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 🐍 Memory-efficient way
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Writing Pythonic code isn’t just about being fancy - it’s about writing code that’s:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;More readable&lt;/li&gt;
  &lt;li&gt;Less prone to bugs&lt;/li&gt;
  &lt;li&gt;More maintainable&lt;/li&gt;
  &lt;li&gt;Often more performant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember, Python’s motto is “Simple is better than complex.” These patterns help you write code that’s both simple AND powerful!&lt;/p&gt;

&lt;p&gt;Want to learn more? Check out Python’s &lt;a href=&quot;https://www.python.org/dev/peps/pep-0020/&quot;&gt;Zen of Python&lt;/a&gt; by typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;import this&lt;/code&gt; in your Python interpreter!&lt;/p&gt;

&lt;p&gt;Happy coding! 🐍✨&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="python" /><category term="programming" /><category term="best-practices" /><category term="tutorial" /><summary type="html">Writing Python code is easy, but writing Pythonic code? That’s an art! Let’s explore some Python best practices that will level up your coding game. We’ll use these emojis to rate different code approaches:</summary></entry><entry><title type="html">GPT Vision and DSPY towards smarter automation</title><link href="https://aliirz.com/using-dspy-with-gpt-vision" rel="alternate" type="text/html" title="GPT Vision and DSPY towards smarter automation" /><published>2024-08-22T16:54:00+00:00</published><updated>2024-08-22T16:54:00+00:00</updated><id>https://aliirz.com/using-dspy-with-gpt-vision</id><content type="html" xml:base="https://aliirz.com/using-dspy-with-gpt-vision">&lt;p&gt;Recently, I was presented with an intriguing challenge by a client. They were using a tablet-based point of sale (POS) system to sell memberships. The process involved a salesperson entering the buyer’s information and then having the buyer provide their signature after verifying all the details. However, once the contract was generated, it frequently failed validation because the details entered by the sales rep didn’t match the buyer’s license. This discrepancy wasted a significant amount of time and effort.&lt;/p&gt;

&lt;p&gt;While investigating this issue, I discovered that the app was already capturing and storing an image of the buyer’s driver’s license. This sparked an idea: why not use Optical Character Recognition (OCR) to convert the driver’s license image into text and pre-fill the form? However, just using OCR wasn’t enough; the extracted information needed to be structured properly in JSON format. It became clear that I needed a Large Language Model (LLM) to achieve this. Eventually, I implemented a solution using Google Vision AI combined with GPT-4o, and it performed quite well.&lt;/p&gt;

&lt;p&gt;Although the initial solution was effective, I knew it could be improved further. That’s when I turned to &lt;a href=&quot;https://dspy-docs.vercel.app/&quot;&gt;DSPY&lt;/a&gt;, a framework designed to program (not just prompt) language models. I decided to fully integrate GPT Vision with DSPY, allowing me to read the image and receive structured JSON with a single API call. Since DSPY didn’t have a built-in abstract LM class to support GPT Vision, I had to do some digging online and on &lt;a href=&quot;https://github.com/stanfordnlp/dspy/issues/624&quot;&gt;GitHub&lt;/a&gt;. Here’s what I found:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base64&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;re&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dsp&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LM&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;encode_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;rb&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;base64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;b64encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
GPTVision is a class that extends the LM class from dsp.py
&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GPTVision&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gpt-4o&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;provider&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;openai&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;https://api.openai.com/v1/chat/completions&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;basic_request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pattern&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;^Image Path: .*&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;matches&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;re&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;findall&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pattern&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;re&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MULTILINE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;image_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Image Path: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Authorization&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Bearer &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_key&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;base64_image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;encode_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gpt-4o&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
                        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;
                        &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
                        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;image_url&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;image_url&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                                &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;data:image/jpeg;base64,&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base64_image&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
                            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
                        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;max_tokens&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;
        

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__call__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;only_completed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;return_sorted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;responses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;basic_request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;responses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;completions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;choice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;responses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;choices&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;completions&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The above implementation worked beautifully, especially when combined with my signature:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;VqaCoT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Signature&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Extract the following demographic fields from the US driver license image and return them in JSON format. If a field is not found, return an empty string for that field. The fields to extract are:

                - Full Name (ignore titles or job descriptions such as &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Motorist&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)
                - First Name (If it contains a middle name such as Lori Lee or Yasir N, just pick up the first name and ignore the middle name)
                - Last Name (Its always at the very beginning right next to 1 usually)
                - Middle Name (If no middle name is present, return an empty string)
                - Date of Birth
                - Gender
                - Address (including street, city, state, and zip code. Sometimes the demographics have numbers against them, like the address might have something like 8 145 Street. We need to make sure we dont pick up the serial numbers)
                - License Number (Its always at the top and the first field that looks like a license number such 4965454 or R-140-428-730-065. The title is sometimes LIC NO or ID)
                - Issue Date
                - Expiration Date&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;image_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Base64 format of the image&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;demographics&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dspy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OutputField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;{
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Full Name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;First Name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Last Name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Middle Name&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Date of Birth&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Gender&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Address&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: {{
                        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Street&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;City&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Zip Code&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
                    }},
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;License Number&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Issue Date&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;,
                    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Expiration Date&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
                }}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So far, I am quite satisfied with this implementation. I’m not sure what I’ll add next, but I’m excited about the possibilities!&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="gpt" /><category term="vision" /><category term="dspy" /><summary type="html">Recently, I was presented with an intriguing challenge by a client. They were using a tablet-based point of sale (POS) system to sell memberships. The process involved a salesperson entering the buyer’s information and then having the buyer provide their signature after verifying all the details. However, once the contract was generated, it frequently failed validation because the details entered by the sales rep didn’t match the buyer’s license. This discrepancy wasted a significant amount of time and effort.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/dspy-license.jpg" /><media:content medium="image" url="https://aliirz.com/images/dspy-license.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Mastering Markdown; A Cheatsheet from a Dev Who Loves Markdown (But Keeps Googling It)</title><link href="https://aliirz.com/markdown-cheatsheet" rel="alternate" type="text/html" title="Mastering Markdown; A Cheatsheet from a Dev Who Loves Markdown (But Keeps Googling It)" /><published>2024-06-26T15:54:00+00:00</published><updated>2024-06-26T15:54:00+00:00</updated><id>https://aliirz.com/markdown-cheatsheet</id><content type="html" xml:base="https://aliirz.com/markdown-cheatsheet">&lt;p&gt;I have a deep love for Markdown .It’s the magical tool that turns plain text into beautifully formatted documents. But here’s a little secret: even with over 10 years in tech, I still find myself googling how to format Markdown. So, I decided to write this cheatsheet to end my relentless web searches&lt;/p&gt;

&lt;h2 id=&quot;headers&quot;&gt;Headers&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;Use &lt;span class=&quot;sb&quot;&gt;`#`&lt;/span&gt; for headers. The number of &lt;span class=&quot;sb&quot;&gt;`#`&lt;/span&gt; symbols at the beginning of the line indicates whether it&apos;s a heading 1, 2, 3, etc.

&lt;span class=&quot;gh&quot;&gt;# H1&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;## H2&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;### H3&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;#### H4&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;##### H5&lt;/span&gt;
&lt;span class=&quot;gu&quot;&gt;###### H6&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;emphasis&quot;&gt;Emphasis&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_ &lt;/code&gt;for emphasis.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;ge&quot;&gt;*italic*&lt;/span&gt; or _italic_
&lt;span class=&quot;gs&quot;&gt;**bold**&lt;/span&gt; or __bold__
&lt;span class=&quot;ges&quot;&gt;***bold and italic***&lt;/span&gt; or ___bold and italic___&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;lists&quot;&gt;Lists&lt;/h2&gt;

&lt;h3 id=&quot;unordered-list&quot;&gt;Unordered List&lt;/h3&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; for unordered lists.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; Item 1
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; Item 2
&lt;span class=&quot;p&quot;&gt;  -&lt;/span&gt; Item 2a
&lt;span class=&quot;p&quot;&gt;  -&lt;/span&gt; Item 2b&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;ordered-list&quot;&gt;Ordered List&lt;/h2&gt;

&lt;p&gt;Use numbers for ordered lists.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;1.&lt;/span&gt; Item 1
&lt;span class=&quot;p&quot;&gt;2.&lt;/span&gt; Item 2
&lt;span class=&quot;p&quot;&gt;   1.&lt;/span&gt; Item 2a
&lt;span class=&quot;p&quot;&gt;   2.&lt;/span&gt; Item 2b&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[text](URL)&lt;/code&gt; for links.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;Ali Raza&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;https://www.aliirz.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;images&quot;&gt;Images&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;![alt text](URL)&lt;/code&gt; for images.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;![&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;Markdown Logo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;https://markdown-here.com/img/icon256.png&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;blockquotes&quot;&gt;Blockquotes&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; for blockquotes.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;gt&quot;&gt;&amp;gt; This is a blockquote.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;

&lt;h3 id=&quot;inline-code&quot;&gt;Inline Code&lt;/h3&gt;

&lt;p&gt;Use backticks for inline code.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;sb&quot;&gt;`code`&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;code-blocks&quot;&gt;Code Blocks&lt;/h3&gt;

&lt;p&gt;Use triple backticks for code blocks.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;```&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;javascript
&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;helloWorld&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Hello, world!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;```&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;horizontal-rules&quot;&gt;Horizontal Rules&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;---&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;***&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;___&lt;/code&gt; for horizontal rules.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;***&lt;/span&gt;
&lt;span class=&quot;ge&quot;&gt;__&lt;/span&gt;_&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;tables&quot;&gt;Tables&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;| &lt;/code&gt;to create tables.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;| Header 1 | Header 2 |
|----------|----------|
| Cell 1   | Cell 2   |
| Cell 3   | Cell 4   |&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;strikethrough&quot;&gt;Strikethrough&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~~&lt;/code&gt; to strikethrough text.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;~~This was a mistake.~~&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;task-lists&quot;&gt;Task Lists&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;- [ ]&lt;/code&gt; for task lists.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; [x] Completed task
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; [ ] Incomplete task&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;footnotes&quot;&gt;Footnotes&lt;/h2&gt;

&lt;p&gt;Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[^1]&lt;/code&gt; for footnotes.&lt;/p&gt;

&lt;p&gt;Here is a footnote reference[^1].&lt;/p&gt;

&lt;h2 id=&quot;emoji&quot;&gt;Emoji&lt;/h2&gt;

&lt;p&gt;Use colons to include emoji.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;:smile: :+1: :heart:&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name>Ali Raza</name></author><category term="cheat-sheet" /><category term="markdown" /><summary type="html">I have a deep love for Markdown .It’s the magical tool that turns plain text into beautifully formatted documents. But here’s a little secret: even with over 10 years in tech, I still find myself googling how to format Markdown. So, I decided to write this cheatsheet to end my relentless web searches</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/md.png" /><media:content medium="image" url="https://aliirz.com/images/md.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Building a PDF Chatbot</title><link href="https://aliirz.com/doc-sleek-talk-to-your-pdf-file" rel="alternate" type="text/html" title="Building a PDF Chatbot" /><published>2024-06-03T09:03:00+00:00</published><updated>2024-06-03T09:03:00+00:00</updated><id>https://aliirz.com/doc-sleek-talk-to-your-pdf-file</id><content type="html" xml:base="https://aliirz.com/doc-sleek-talk-to-your-pdf-file">&lt;p&gt;I’ve been quietly working on a personal challenge: 100 days of AI. As part of this journey, I built a chatbot that lets you chat with a PDF file. Using GPT-4 and the Assistants API, my bot can help you interact with the content of any PDF you upload.&lt;/p&gt;

&lt;p&gt;I used Bun, Next.js, GPT-4o, and ShadCN/Tailwind. It’s been a fun and rewarding experience combining these technologies to create something I’ve always wanted to.&lt;/p&gt;

&lt;p&gt;Here is a demo:&lt;/p&gt;

&lt;p&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/FxCOL_uIzc4&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;Feel free to explore the code on GitHub!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/Boost-Panda/sleek-doc-api&quot;&gt;https://github.com/Boost-Panda/sleek-doc-api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/Boost-Panda/sleek-doc-ui&quot;&gt;https://github.com/Boost-Panda/sleek-doc-ui&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="chatbot" /><category term="gpt-4" /><category term="bun" /><category term="next.js" /><category term="tailwind" /><category term="100-days-of-ai" /><summary type="html">I’ve been quietly working on a personal challenge: 100 days of AI. As part of this journey, I built a chatbot that lets you chat with a PDF file. Using GPT-4 and the Assistants API, my bot can help you interact with the content of any PDF you upload.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/docseek.jpg" /><media:content medium="image" url="https://aliirz.com/images/docseek.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Using Google Gemini to build Karachi Chal</title><link href="https://aliirz.com/karachi-chal" rel="alternate" type="text/html" title="Using Google Gemini to build Karachi Chal" /><published>2024-05-05T14:03:00+00:00</published><updated>2024-05-05T14:03:00+00:00</updated><id>https://aliirz.com/karachi-chal</id><content type="html" xml:base="https://aliirz.com/karachi-chal">&lt;h2 id=&quot;the-inspiration-spark&quot;&gt;The Inspiration Spark&lt;/h2&gt;
&lt;p&gt;Picture this: I’m on a flight to Karachi, a megacity I’ve always felt a connection to, when it hits me. The sheer scale of the place, the energy – there had to be a better way to navigate it than generic travel guides. Enter Karachi Chal, my AI-powered itinerary planner! Sometimes, even when you think you’re escaping work to clear your head, inspiration strikes in the most unexpected places. That flight to Karachi turned into an accidental coding adventure! With its bustling streets and hidden gems, I knew there had to be a way to help visitors – and tourists like myself – experience the city’s true spirit. Powered by Google’s Gemini API, it quickly became more than a side project; it was a deep dive into building web apps with the power of advanced language models.&lt;/p&gt;

&lt;h2 id=&quot;gemini-api-your-ai-copilot&quot;&gt;Gemini API: Your AI Copilot&lt;/h2&gt;

&lt;p&gt;Gemini is a super-smart language model from Google AI that can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. It also has multimodal capabilities.&lt;/p&gt;

&lt;p&gt;For Karachi Chal, I needed more than just an AI that could spit out search results. Gemini’s the perfect fit because it can understand complex requests and go beyond the typical tourist traps. For example, if a user asks, “Help me find offbeat Karachi experiences, things most tourists wouldn’t know about. I am here for 3 days,” Gemini could tap into its knowledge of Karachi to suggest.&lt;/p&gt;

&lt;h2 id=&quot;the-code-behind-the-magic&quot;&gt;The Code Behind the Magic&lt;/h2&gt;

&lt;p&gt;Let’s start by bringing in the necessary tools. The first line imports the core Gemini functionalities from Google’s library. MarkdownIt will help us format the AI’s responses for the web, and your style.css keeps everything looking good. Of course, we need your super-secret API key to communicate with Gemini!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;GoogleGenerativeAI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HarmBlockThreshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HarmCategory&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;@google/generative-ai&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Bringing in the tools to work with Gemini&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MarkdownIt&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;markdown-it&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Library to make the AI&apos;s output look nice&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./style.css&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 

&lt;span class=&quot;c1&quot;&gt;// Your API Key - Keep it Safe!&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;API_KEY&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;VITE_GEMINI_KEY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is where I teach Gemini how to be the ultimate Karachi travel guide. By setting the ‘role’ to ‘user’, I’m making sure the AI understands this input is coming from someone asking for help. Inside the ‘parts’ is where I’ll carefully craft instructions for creating the perfect itinerary:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;contents&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;parts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// Your prompt text here &lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now here is the real Jugaar (hack), the prompt that makes Karachi Chal tick:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;kd&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;contents&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;parts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
                    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;s2&quot;&gt;`You are a knowledgeable travel guide specializing in Karachi. 
                    When a visitor asks you about their upcoming trip using the 
                    variable &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;promptInput&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;, provide a comprehensive response. 
                    Include detailed daily itineraries, top dining spots, and must-see attractions. 
                    Ensure you account for travel logistics, such as travel times and 
                    operational hours of venues.`&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;img src=&quot;images/idx-khi-chal.png&quot; alt=&quot;Karachi Chal dev in Google&apos;s project IDX&quot; /&gt;&lt;/p&gt;

&lt;p&gt;One of the coolest parts of building with AI is those ‘aha!’ moments. Gemini works by sending a stream of text rather than a single block, and figuring out how to handle that on the fly was a big win! Working with Markdown to make everything look good on the website added another layer to the challenge.&lt;/p&gt;

&lt;h2 id=&quot;the-end-result&quot;&gt;The End Result&lt;/h2&gt;

&lt;p&gt;For the input we used above, here is how Karachi Chal would respond:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-md&quot; data-lang=&quot;md&quot;&gt;Day 1: Discovering Karachi&apos;s Quirky Side

Morning:

Start your day by visiting the ethereal Khuda Ki Basti (God&apos;s Colony), a unique neighborhood adorned with vibrant street art and murals by local and international artists. Spend about an hour exploring its colorful streets.
Afternoon:

Head to the bustling Tower Market for a sensory overload. Wander through its maze-like alleys, marveling at the vibrant fabrics, handicrafts, and delicious street food. Allow 2-3 hours for shopping and lunch.
Evening:

Immerse yourself in the local culture at Pakka Qila (Association of the Faithful). Witness traditional wrestling matches or indulge in mouthwatering street delicacies at this vibrant public space. Stay for about 2 hours.
Day 2: Architectural Wonders and Culinary Delights

Morning:

Explore the grandeur of the Frere Hall (City Library), a majestic Gothic Revival building. Admire its intricate architecture and delve into its extensive collection of books. Visit for approximately 2 hours.
Afternoon:

Visit the picturesque Haleji Lake, a serene wetland home to diverse birdlife. Take a boat ride or stroll along its scenic shores, enjoying the tranquil atmosphere. Allow 3-4 hours for this excursion.
Evening:

Indulge in authentic Sindhi cuisine at Sohni Dharti Restaurant. Savor flavorsome dishes like sajji (grilled meat) and bhel puri (spicy puffed rice). Dinner takes about 2 hours.
Day 3: The Soul of Karachi

Morning:

Discover the fascinating history and culture of Karachi at the Pakistan Maritime Museum. Explore its exhibits on naval history, marine life, and the role of the Pakistani Navy. Plan for 2-3 hours at the museum.
Afternoon:

Immerse yourself in the vibrant atmosphere of Kemari Town, a historic fishing village. Witness the bustling fish market, interact with friendly locals, and savor fresh seafood at roadside stalls. Dedicate 2-3 hours to this experience.
Evening:

End your Karachi adventure at the Mohatta Palace, a stunning palace built in the Rajput architectural style. Admire its intricate carvings and serene gardens, while enjoying a memorable dinner at its in-house restaurant. Allow 2-3 hours for dinner and exploration.
Travel Logistics:

Getting Around: Use ride-sharing apps like Careem or Uber for convenient transportation.
Local Transport: Explore the city by rickshaw for an authentic experience.
Travel Times: Factor in approximately 30-60 minutes for travel between attractions.
Operating Hours: Venues typically open around 9 AM and close between 6 PM and 9 PM. Check specific venues for exact hours.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;img src=&quot;images/khi-chal.png&quot; alt=&quot;Karachi Chal&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The possibilities are endless with Karachi Chal! Think about tweaking the prompt for a budget-friendly trip, a focus on Karachi’s art scene, or even adding a time-of-year element (festival season vs. quieter months).&lt;/p&gt;

&lt;p&gt;If you’re a coder, data enthusiast, or just bursting with ideas to make Karachi Chal even better, join the adventure! Let’s turn this AI itinerary planner into the ultimate Karachi travel companion. Check out the &lt;a href=&quot;https://github.com/codeforpakistan/karachi-chal&quot;&gt;GitHub Repo&lt;/a&gt; and the &lt;a href=&quot;https://karachichal.com&quot;&gt;Website&lt;/a&gt; if you want to contribute or just explore the project.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="karachi" /><category term="ai" /><category term="city-guide" /><category term="open-source" /><category term="llm" /><summary type="html">The Inspiration Spark Picture this: I’m on a flight to Karachi, a megacity I’ve always felt a connection to, when it hits me. The sheer scale of the place, the energy – there had to be a better way to navigate it than generic travel guides. Enter Karachi Chal, my AI-powered itinerary planner! Sometimes, even when you think you’re escaping work to clear your head, inspiration strikes in the most unexpected places. That flight to Karachi turned into an accidental coding adventure! With its bustling streets and hidden gems, I knew there had to be a way to help visitors – and tourists like myself – experience the city’s true spirit. Powered by Google’s Gemini API, it quickly became more than a side project; it was a deep dive into building web apps with the power of advanced language models.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/arfat-jabbar-RtIVw8BGMWc-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/arfat-jabbar-RtIVw8BGMWc-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">ZenPad, A Minimal Markdown Editor for Distraction-Free Writing</title><link href="https://aliirz.com/zen-pad.minimal-markdown-editor" rel="alternate" type="text/html" title="ZenPad, A Minimal Markdown Editor for Distraction-Free Writing" /><published>2024-03-23T19:51:00+00:00</published><updated>2024-03-23T19:51:00+00:00</updated><id>https://aliirz.com/zen-pad.minimal-markdown-editor</id><content type="html" xml:base="https://aliirz.com/zen-pad.minimal-markdown-editor">&lt;p&gt;I recently launched &lt;a href=&quot;http://zenpad.aliirz.com&quot;&gt;Zenpad&lt;/a&gt;, inspired by my search for a distraction-free writing tool that’s straightforward yet powerful. Despite trying various platforms, I found them lacking in simplicity, prompting me to create Zenpad. Designed for writers who value focus, it requires no sign-up or sign-in, embodying the essence of minimalism.&lt;/p&gt;

&lt;p&gt;My philosophy is simple: if you can’t find the right tool, it’s time to build it. Zenpad stands as a testament to this belief, offering a clean, user-centric writing experience. Here’s to celebrating the spirit of open-source innovation and the joy of crafting tools that resonate with our needs.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="markdown" /><summary type="html">I recently launched Zenpad, inspired by my search for a distraction-free writing tool that’s straightforward yet powerful. Despite trying various platforms, I found them lacking in simplicity, prompting me to create Zenpad. Designed for writers who value focus, it requires no sign-up or sign-in, embodying the essence of minimalism.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/aliirz_In_a_serene_minimalist_workspace_under_the_soft_glow_of__31895718-3e48-409b-a82d-325b4e9b8ad9.png" /><media:content medium="image" url="https://aliirz.com/images/aliirz_In_a_serene_minimalist_workspace_under_the_soft_glow_of__31895718-3e48-409b-a82d-325b4e9b8ad9.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Sora, A New Horizon in AI-Generated Video Content</title><link href="https://aliirz.com/openai-sora" rel="alternate" type="text/html" title="Sora, A New Horizon in AI-Generated Video Content" /><published>2024-02-15T18:20:00+00:00</published><updated>2024-02-15T18:20:00+00:00</updated><id>https://aliirz.com/openai-sora</id><content type="html" xml:base="https://aliirz.com/openai-sora">&lt;p&gt;Like a RKO out of nowwhere, OpenAI has unveiled Sora, a AI model designed to transform text instructions into realistic and imaginative video scenes. This launch marks a significant milestone in AI’s capability to understand and simulate the physical world in motion, opening up unprecedented possibilities for creators across the globe.&lt;/p&gt;

&lt;h2 id=&quot;what-is-sora&quot;&gt;What is Sora?&lt;/h2&gt;

&lt;p&gt;Sora is not just any AI model; it is a technology capable of generating up to a minute-long videos that maintain visual quality and adhere closely to the given prompts. Developed by OpenAI, it represents a leap forward in the field, aiming to bridge the gap between imagination and visual representation without the need for extensive video production resources.  &lt;a href=&quot;https://openai.com/sora&quot;&gt;OpenAI’s website&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;impact-on-the-video-generation-ecosystem&quot;&gt;Impact on the Video Generation Ecosystem&lt;/h2&gt;

&lt;p&gt;The introduction of Sora into the market is set to redefine the competitive landscape for startups and established companies alike in the AI-generated video space. Here’s how it impacts other players:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://runwayml.com&quot;&gt;&lt;strong&gt;Runway AI&lt;/strong&gt;&lt;/a&gt;: A generative AI video editing platform, enabling users to produce short video clips from text prompts.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://stability.ai&quot;&gt;&lt;strong&gt;Stability AI&lt;/strong&gt;&lt;/a&gt;: Entered the video generation domain with Stable Video Diffusion, a model for generating videos from images.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.inworld.ai&quot;&gt;&lt;strong&gt;Inworld AI&lt;/strong&gt;&lt;/a&gt;: Specializes in creating AI-powered characters for video games and digital entertainment, using natural language processing for lifelike interactions.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.steve.ai&quot;&gt;&lt;strong&gt;Steve.ai&lt;/strong&gt;&lt;/a&gt;: An online platform transforming text prompts into animated videos, targeting content creators for efficient video production.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other notable companies in this space include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.synthesia.io&quot;&gt;&lt;strong&gt;Synthesia&lt;/strong&gt;&lt;/a&gt;: For professional-looking AI videos from text.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.deepbrainai.io&quot;&gt;&lt;strong&gt;Deepbrain AI&lt;/strong&gt;&lt;/a&gt;: For conversational AI avatars and AI video generator.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.pika.art&quot;&gt;&lt;strong&gt;Pika&lt;/strong&gt;&lt;/a&gt;: Focuses on editing and generating videos from captions and still images.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://typecast.ai&quot;&gt;&lt;strong&gt;Neosapience&lt;/strong&gt;&lt;/a&gt;: Featuring Typecast’s Online AI Voice Generator for video content.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;opportunities-for-creators-and-businesses&quot;&gt;Opportunities for Creators and Businesses&lt;/h2&gt;

&lt;p&gt;Sora opens up a world of possibilities for visual artists, filmmakers, and designers, providing them with a tool to bring their visions to life without the traditional barriers of video production. This democratization of content creation has the potential to spur a new wave of creativity and innovation, enabling personalized and engaging content across various sectors, including education, marketing, and entertainment.&lt;/p&gt;

&lt;p&gt;Look at some amazing video examples here &lt;a href=&quot;https://openai.com/sora&quot;&gt;OpenAI’s website&lt;/a&gt;.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="openai" /><category term="sora" /><summary type="html">Like a RKO out of nowwhere, OpenAI has unveiled Sora, a AI model designed to transform text instructions into realistic and imaginative video scenes. This launch marks a significant milestone in AI’s capability to understand and simulate the physical world in motion, opening up unprecedented possibilities for creators across the globe.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/openai-sora.png" /><media:content medium="image" url="https://aliirz.com/images/openai-sora.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Using Crew AI to detect fake news with your own LLM</title><link href="https://aliirz.com/fight-fake-news-with-crew-ai" rel="alternate" type="text/html" title="Using Crew AI to detect fake news with your own LLM" /><published>2024-02-07T08:19:35+00:00</published><updated>2024-02-07T08:19:35+00:00</updated><id>https://aliirz.com/fight-fake-news-with-crew-ai</id><content type="html" xml:base="https://aliirz.com/fight-fake-news-with-crew-ai">&lt;p&gt;I found out about &lt;a href=&quot;https://www.crewai.io/&quot;&gt;crew ai&lt;/a&gt; some time ago. While the use of multiple AT agents to perform a task is not something new. Crew AI serves as a framework to make this a lot more easier. The best part is that it lets you define your agents and their tasks in a very &lt;a href=&quot;https://github.com/joaomdmoura/crewAI-examples/tree/main/starter_template&quot;&gt;organized manner&lt;/a&gt;. I have been playing with it for a while now and I did a small experiment to see if I could use it to detect fake news.&lt;/p&gt;

&lt;p&gt;One of the most powerful features that Crew AI has is the ability to have your agents use  tools in their tasks. For example you can have a agent use the following tool to search the web&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@tool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Search the internet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;search_internet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Useful to search the internet 
about a a given topic and return relevant results&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;https://google.serper.dev/search&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dumps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;X-API-KEY&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;environ&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SERPER_API_KEY&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content-type&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;application/json&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;POST&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;organic&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;
        &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Title: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Link: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Snippet: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;snippet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-----------------&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;By default Crew AI uses openai’s api, you need to have the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OPENAI_API_KEY&lt;/code&gt; as a env var available. But would it not be fun if we could use our own model? I have been playing with &lt;a href=&quot;https://ollama.ai/library/openhermes&quot;&gt;openhermes&lt;/a&gt; so I decided to give it a shot and voila! I was able to use it with crew ai.&lt;/p&gt;

&lt;p&gt;Here is a small snippet of the code from my &lt;a href=&quot;https://github.com/aliirz/crews&quot;&gt;crews&lt;/a&gt; repo:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crewai&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Crew&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Process&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain.tools&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tool&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain.llms&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Ollama&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ollama_llm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Ollama&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;openhermes&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain.tools&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DuckDuckGoSearchRun&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;search_tool&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DuckDuckGoSearchRun&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Define your CrewAI agents and tasks
# Define Agents
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fact_checking_agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Fact-Checking Agent&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;goal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Verify the factual accuracy of the news article or statement.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;backstory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Expert in data verification and fact-checking, skilled in discerning truth from fiction in news reporting.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tools&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;search_tool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ollama_llm&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;political_analyst_agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Political Analyst Agent&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;goal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Provide context and political analysis on Pakistan.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;backstory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Specializes in South Asian geopolitics, focusing on Pakistan.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ollama_llm&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;media_bias_analyst_agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Media Bias Analyst Agent&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;goal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Assess potential biases in the news source.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;backstory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Expert in media studies, focusing on detecting biases in news reporting.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ollama_llm&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;public_sentiment_analyst_agent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Public Sentiment Analyst Agent&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;goal&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Gauge public reaction to the news.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;backstory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Skilled in analyzing public opinion and sentiment on social media and online forums.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tools&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;search_tool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;llm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ollama_llm&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Define a function to integrate the tools with CrewAI
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;analyze_news_article&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;fact_checking_task&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Analyze the news article: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; for factual accuracy. Final answer must be a detailed report on factual findings.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fact_checking_agent&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;political_analysis_task&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Analyze the political context of the news article: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;. Final answer must include an assessment of the current political situation and its credibility.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;political_analyst_agent&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;media_bias_analysis_task&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Evaluate the news source: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; for biases and report on potential influences on the article&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;s narrative. Final answer must include an analysis of media bias.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;media_bias_analyst_agent&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;public_sentiment_analysis_task&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Analyze public reaction to the news: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; on social media and forums. Final answer must summarize public sentiment.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;agent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;public_sentiment_analyst_agent&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


    &lt;span class=&quot;n&quot;&gt;crew&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Crew&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;agents&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fact_checking_agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;political_analyst_agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;media_bias_analyst_agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;public_sentiment_analyst_agent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#  agents
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;tasks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fact_checking_task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;political_analysis_task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;media_bias_analysis_task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;public_sentiment_analysis_task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#  tasks
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# currently the only way it works
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;crew&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;kickoff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;#  usage
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;analyze_news_article&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Feb 8 2024 Elections have been cancelled in Pakistan. The government has declared a state of emergency. The military has taken over the country.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you can see I am using DuckDuckGo as a tool and openhermes as the LLM. The result is a detailed report on the news article. I am still playing with it and I am sure I can make it better. But I am happy with the results so far. My news article is a fake news around the delay of elections in Pakistan. As I am writing this post, elections are due tomorrow. My crew was able to successfuly research and provide its findings on the news article. This was the output i got:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Based on the context provided, it appears that the news article is outdated or incorrect as elections are still scheduled for February 8, 2024 in Pakistan and no state of emergency or military takeover has been reported.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pretty cool right? I am excited to see what else we can do with this. I have barely began to scratch the surface. You can checkout crew ai &lt;a href=&quot;https://www.crewai.io/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="ollama" /><category term="openhermes" /><summary type="html">I found out about crew ai some time ago. While the use of multiple AT agents to perform a task is not something new. Crew AI serves as a framework to make this a lot more easier. The best part is that it lets you define your agents and their tasks in a very organized manner. I have been playing with it for a while now and I did a small experiment to see if I could use it to detect fake news.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/aliirz_a_crew_of_researchers_working_together_to_find_if_a_news_dca49ea5-e643-4dc2-b532-fd879522cd79.png" /><media:content medium="image" url="https://aliirz.com/images/aliirz_a_crew_of_researchers_working_together_to_find_if_a_news_dca49ea5-e643-4dc2-b532-fd879522cd79.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Gesture Recognition with Python OpenCV</title><link href="https://aliirz.com/gesture-recognition-with-python" rel="alternate" type="text/html" title="Gesture Recognition with Python OpenCV" /><published>2024-01-21T11:19:35+00:00</published><updated>2024-01-21T11:19:35+00:00</updated><id>https://aliirz.com/gesture-recognition-with-python</id><content type="html" xml:base="https://aliirz.com/gesture-recognition-with-python">&lt;p&gt;A long time ago I was part of a competition where people were presenting and building some great ideas. One such startup that really inspired me was trying to build an app to recognize ASL(American Sign Language) and PSL(Pakistan Sign Language). To no one’s surprise they won the competion, however down the line 4 years from that day, that startup now works as a event management company and provides sign language interpreters for such events.&lt;/p&gt;

&lt;p&gt;We promise big, but we deliver small. It has been part of a norm here in Pakistan. Anyhow, since I’ve never had much experience working with Computer Vision, I decided to give it a shot and see if how hard it would be build a simple gesture recognition python script. Turns out, its not that hard. I was able to build a simple app that recognizes a few gestures.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;images/gesturerecog.png&quot; alt=&quot;Gesture Recognition in action&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The only dependencies are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;opencv-python&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mediapipe&lt;/code&gt;. You can install them using pip:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;opencv-python mediapipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here is the code:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/aliirz/9a235a3973a511c13e04b0ff452b600b.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="todayilearned" /><category term="python" /><summary type="html">A long time ago I was part of a competition where people were presenting and building some great ideas. One such startup that really inspired me was trying to build an app to recognize ASL(American Sign Language) and PSL(Pakistan Sign Language). To no one’s surprise they won the competion, however down the line 4 years from that day, that startup now works as a event management company and provides sign language interpreters for such events.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/gesture.png" /><media:content medium="image" url="https://aliirz.com/images/gesture.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Code Roaster GPT</title><link href="https://aliirz.com/code-roaster-gpt" rel="alternate" type="text/html" title="Code Roaster GPT" /><published>2024-01-02T19:19:35+00:00</published><updated>2024-01-02T19:19:35+00:00</updated><id>https://aliirz.com/code-roaster-gpt</id><content type="html" xml:base="https://aliirz.com/code-roaster-gpt">&lt;p&gt;While experimenting with building my own GPTs, I stumbled upon a fascinating idea. What if we could train a GPT on code and utilize it to roast code? Intrigued by the concept, I decided to give it a shot. As a result Roasty was born. Roasty is a fiesty little GPT that roasts your code (and you). While its a novel idea, its the prompt that matters and the results. So far Roasty has roasted my code and me pretty well. It has also roasted some of my friends and their code.&lt;/p&gt;

&lt;div style=&quot;position: relative; padding-bottom: 56.25%; height: 0;&quot;&gt;&lt;iframe src=&quot;https://www.loom.com/embed/a31f7ae3721f43858ff86e4ddc7f7a29?sid=86db9780-7f4c-48ce-be64-a28efc516311&quot; frameborder=&quot;0&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot; allowfullscreen=&quot;&quot; style=&quot;position: absolute; top: 0; left: 0; width: 100%; height: 100%;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;

&lt;p&gt;As an example here is the code snippet from my &lt;a href=&quot;https://www.encodedecode.lol/&quot; target=&quot;_blank&quot;&gt;encodedecode.lol&lt;/a&gt; side project.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;form-group&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;textarea&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;form-control&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;inputText&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Ready for some Base64 sorcery? Input your text!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;floatingTextarea&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/textarea&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;d-flex justify-content-end&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;button&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;convertTo64&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;disabled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;isEncoded&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;btn btn-primary&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;{ &apos;marginRight&apos;: &apos;10px&apos; }&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Encode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/button&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;button&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;convertFrom64&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;disabled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!isEncoded&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;btn btn-secondary&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Decode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/button&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/template&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;defineComponent&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;vue&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
  
  &lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;defineComponent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;ConvertTo64&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nf&quot;&gt;convertTo64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;inputText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;btoa&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;inputText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;isEncoded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
      &lt;span class=&quot;nf&quot;&gt;convertFrom64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;inputText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;atob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;inputText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;isEncoded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;inputText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;isEncoded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is what Roasty had to say about it:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Ah, Vue.js meets Base64 – the peanut butter and jelly of web development, but with a side of &quot;What were they thinking?&quot;

First off, let&apos;s address the elephant in the room: `convertTo64` and `convertFrom64`. Ah, naming methods like they&apos;re Transformers characters. Optimus Encode and Decodetron, roll out! But seriously, how about `encodeToBase64` and `decodeFromBase64`? It&apos;s like a gift to your future self who won&apos;t remember what &quot;64&quot; stood for.

And then, `this.isEncoded`. I appreciate the effort to track state, but what happens when someone decodes and then re-encodes? Do we just flip-flop this boolean like a politician in election season? Consider tracking the state more robustly.

Oh, and speaking of robust – `btoa` and `atob` – the good ol&apos; built-in duo. They&apos;re great until they meet non-Latin1 characters and throw a tantrum like a toddler denied candy. Maybe consider handling that so your app doesn&apos;t crash when it encounters an emoji. 🙃

Now, let&apos;s talk about your template. It&apos;s like a minimalist painting - there&apos;s beauty in simplicity, but a few more strokes wouldn&apos;t hurt. How about some validation or user feedback? Let the user know if something went wrong, or if they&apos;re trying to decode a string that wasn&apos;t encoded in the first place. We don&apos;t want to be decoding gibberish, do we?

Lastly, the inline style in the button – `:style=&quot;{ &apos;marginRight&apos;: &apos;10px&apos; }&quot;`. Inline styles are like seasoning – a little goes a long way, but too much and you&apos;ll ruin the dish. Maybe consider a class? Keep it clean, keep it maintainable.

In summary:
1. Rename your methods for clarity.
2. Improve your state tracking.
3. Handle non-Latin1 characters.
4. Provide user feedback and validation.
5. Avoid inline styles.

But hey, you&apos;ve got the basics down. Now, just polish it until it shines brighter than a bald man&apos;s head under a spotlight! 🌟
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;iframe src=&quot;https://giphy.com/embed/RdKjAkFTNZkWUGyRXF&quot; width=&quot;480&quot; height=&quot;256&quot; frameborder=&quot;0&quot; class=&quot;giphy-embed&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;&lt;a href=&quot;https://giphy.com/gifs/RdKjAkFTNZkWUGyRXF&quot;&gt;via GIPHY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see it not only roasted me but also provided some useful feedback. I am planning to use this in my code reviews from now own. Specially when I am reviewing code from my friends. Let me know what you think about this idea. You can try it out &lt;a href=&quot;https://chat.openai.com/g/g-6CMx7oOl1-roasty-the-code-roaster/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="chatgpt" /><summary type="html">While experimenting with building my own GPTs, I stumbled upon a fascinating idea. What if we could train a GPT on code and utilize it to roast code? Intrigued by the concept, I decided to give it a shot. As a result Roasty was born. Roasty is a fiesty little GPT that roasts your code (and you). While its a novel idea, its the prompt that matters and the results. So far Roasty has roasted my code and me pretty well. It has also roasted some of my friends and their code.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/roasty.png" /><media:content medium="image" url="https://aliirz.com/images/roasty.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">The Importance of HTTP Status Codes in Microservice and API Development</title><link href="https://aliirz.com/Http-Status-Codes" rel="alternate" type="text/html" title="The Importance of HTTP Status Codes in Microservice and API Development" /><published>2023-10-20T04:33:35+00:00</published><updated>2023-10-20T04:33:35+00:00</updated><id>https://aliirz.com/Http-Status-Codes</id><content type="html" xml:base="https://aliirz.com/Http-Status-Codes">&lt;p&gt;Recently, I had a small argument with a colleague who suggested that one of our developers should determine whether a request failed or succeeded based on the returned string—specifically, whether it was empty or not. While this might seem like a straightforward approach, I strongly believe that decisions should be based on HTTP status codes, not the content of the response string. Here’s why.&lt;/p&gt;

&lt;h3 id=&quot;the-role-of-http-status-codes&quot;&gt;The Role of HTTP Status Codes&lt;/h3&gt;
&lt;p&gt;HTTP status codes are issued by a server in response to a client’s request. They fall into various categories, each serving a specific purpose:&lt;/p&gt;

&lt;p&gt;2xx (Success): Indicates that the client’s request was successfully received and processed.
3xx (Redirection): Suggests that further action needs to be taken to complete the request.
4xx (Client Error): Signifies that the client seems to have made an error.
5xx (Server Error): Indicates that the server failed to fulfill a valid request.&lt;/p&gt;

&lt;h3 id=&quot;why-are-they-important&quot;&gt;Why Are They Important?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Clarity and Consistency&lt;/strong&gt;: Using standard HTTP status codes makes it easier for developers to understand the outcome of an API call without having to dig into the response payload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debugging and Troubleshooting&lt;/strong&gt;: Status codes can quickly point developers to the root cause of an issue, whether it’s a client-side mistake or a server-side error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automation&lt;/strong&gt;: Automated systems can easily interpret these codes and take appropriate actions, such as retrying a failed request or logging an error for future investigation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monitoring and Analytics&lt;/strong&gt;: Tracking the frequency of various status codes can provide valuable insights into API health and usage patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Experience&lt;/strong&gt;: Proper use of status codes can help in creating a more responsive and user-friendly application by handling different scenarios gracefully.&lt;/p&gt;

&lt;h3 id=&quot;best-practices&quot;&gt;best-practices&lt;/h3&gt;
&lt;p&gt;Use the most specific status code for each operation. For example, use 201 Created for resource creation and 204 No Content for a successful delete operation.&lt;/p&gt;

&lt;p&gt;Avoid using generic status codes like 200 OK for all successful operations, as it doesn’t provide enough context about what happened in the server.&lt;/p&gt;

&lt;p&gt;Always include a message body to elaborate on the status code, especially in the case of client and server errors.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;HTTP status codes are an integral part of API and microservice development. They offer a standardized way to communicate the status of HTTP requests, making it easier for both humans and machines to understand what’s happening. By using HTTP status codes effectively, developers can build more robust, efficient, and user-friendly applications.&lt;/p&gt;

&lt;p&gt;So, the next time you find yourself in a debate about whether to use status codes or response strings to indicate the outcome of an API call, remember the many benefits that come with sticking to standard HTTP status codes. It could make all the difference in your project’s success.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="tutorials" /><category term="best-practices" /><summary type="html">Recently, I had a small argument with a colleague who suggested that one of our developers should determine whether a request failed or succeeded based on the returned string—specifically, whether it was empty or not. While this might seem like a straightforward approach, I strongly believe that decisions should be based on HTTP status codes, not the content of the response string. Here’s why.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/aliirz_http_status_codes_ce4348d4-bc9f-41cc-bdf7-8f307b45f638.png" /><media:content medium="image" url="https://aliirz.com/images/aliirz_http_status_codes_ce4348d4-bc9f-41cc-bdf7-8f307b45f638.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Code for All Summit 2023</title><link href="https://aliirz.com/code-for-all-summit-2023" rel="alternate" type="text/html" title="Code for All Summit 2023" /><published>2023-10-20T04:33:35+00:00</published><updated>2023-10-20T04:33:35+00:00</updated><id>https://aliirz.com/code-for-all-summit-2023</id><content type="html" xml:base="https://aliirz.com/code-for-all-summit-2023">&lt;p&gt;This year marked the 10th anniversary of the &lt;a href=&quot;https://codeforall.org/2023/06/05/call-for-proposals-code-for-all-summit-2023/&quot;&gt;Code for All&lt;/a&gt;, a premier gathering for civic tech enthusiasts worldwide. The summit provided a unique platform to discuss, explore, and evaluate the impact of civic tech on a global scale. I had the honor of participating in a panel discussion on open-source technology and delivering a lightning talk on one of our community efforts, “Flood Light.”&lt;/p&gt;

&lt;h4 id=&quot;the-open-source-panel-more-than-just-hype&quot;&gt;The Open-Source Panel: More Than Just Hype&lt;/h4&gt;

&lt;p&gt;The panel discussion aimed to assess the true replicability of open-source software across civic tech. I was joined by experts like Olivia Vereha from Code for Romania and Xavier Frankline from Code for Africa. We discussed why open-source works, citing examples from organizations like Mozilla and civic tech projects like &lt;a href=&quot;https://decidim.org/&quot;&gt;Decidim&lt;/a&gt;. The consensus was clear: open-source is not just a buzzword; it’s a viable approach for civic tech solutions.&lt;/p&gt;

&lt;h4 id=&quot;flood-light-a-community-led-crisis-response&quot;&gt;Flood Light: A Community-Led Crisis Response&lt;/h4&gt;

&lt;p&gt;In 2022, Pakistan faced a catastrophic climate event that led to widespread devastation. In response, Code for Pakistan launched Flood Light, an initiative to create a comprehensive data platform for flood mapping. My colleague Mubassir Hayat and I shared how this effort successfully mapped over 1,500 relief camps and connected those in need with international donors and volunteers. You can watch the full lightning talk &lt;a href=&quot;https://www.youtube.com/watch?v=eAl-P5i7YSw&amp;amp;list=PL6kG8TTskjRP3Qfkzu10VdAFT-rBY4H-9&amp;amp;index=14&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;key-takeaways-from-flood-light&quot;&gt;Key Takeaways from Flood Light&lt;/h4&gt;

&lt;p&gt;We highlighted the transformative power of community-led initiatives in crisis response. The project was a quick solution developed overnight using &lt;a href=&quot;https://www.ushahidi.com/&quot;&gt;Ushahidi&lt;/a&gt;, collecting over 2,000 data points through crowdsourcing. This data was then used by the government and aid organizations to provide relief to the affected people.&lt;/p&gt;

&lt;h4 id=&quot;other-highlights-and-future-directions&quot;&gt;Other Highlights and Future Directions&lt;/h4&gt;

&lt;p&gt;The summit had several sessions on AI and civic tech, which resonated with our ongoing project, &lt;a href=&quot;https://github.com/codeforpakistan/numainda&quot;&gt;Numainda&lt;/a&gt;. It was motivating to see that we are on the right track. I was particularly inspired by Olivia Vereha’s stories and look forward to networking more with like-minded organizations like Code for Romania.&lt;/p&gt;

&lt;h4 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;The Code for All Summit 2023 was an enriching experience that left me motivated to continue our work at Code for Pakistan. The summit served as a reminder of the transformative power of technology when used for the greater good. As we move forward, our focus remains on empowering the community and creating a lasting impact.&lt;/p&gt;

&lt;h4 id=&quot;additional-resources&quot;&gt;Additional Resources&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://codeforall.org/events/code-for-all-summit-2023/&quot;&gt;Code for All Summit 2023&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/codeforpakistan/numainda&quot;&gt;Numainda on GitHub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=eAl-P5i7YSw&amp;amp;list=PL6kG8TTskjRP3Qfkzu10VdAFT-rBY4H-9&amp;amp;index=14&quot;&gt;Flood Light Lightning Talk&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=oxYLs9sz8QA&amp;amp;list=PL6kG8TTskjRP3Qfkzu10VdAFT-rBY4H-9&amp;amp;index=66&quot;&gt;Open-Source Panel Discussion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to share, comment, and stay tuned for more updates on our projects and community efforts!&lt;/p&gt;

&lt;h4 id=&quot;tags&quot;&gt;Tags&lt;/h4&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CodeForAllSummit2023&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CivicTech&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#OpenSource&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CommunityLedInitiatives&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#FloodLight&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CrisisResponse&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#numainda&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#AI&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#Networking&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CodeForPakistan&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CodeForRomania&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#CodeForAfrica&lt;/code&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="tutorials" /><category term="best-practices" /><summary type="html">This year marked the 10th anniversary of the Code for All, a premier gathering for civic tech enthusiasts worldwide. The summit provided a unique platform to discuss, explore, and evaluate the impact of civic tech on a global scale. I had the honor of participating in a panel discussion on open-source technology and delivering a lightning talk on one of our community efforts, “Flood Light.”</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Code-for-All-Summit-Website.jpg" /><media:content medium="image" url="https://aliirz.com/images/Code-for-All-Summit-Website.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">insults.dev, an LLM based Insult Generator for devs</title><link href="https://aliirz.com/chat-gpt-insult-generator" rel="alternate" type="text/html" title="insults.dev, an LLM based Insult Generator for devs" /><published>2023-09-04T19:45:00+00:00</published><updated>2023-09-04T19:45:00+00:00</updated><id>https://aliirz.com/chat-gpt-insult-generator</id><content type="html" xml:base="https://aliirz.com/chat-gpt-insult-generator">&lt;p&gt;In the grand tradition of friendly banter among developers, I embarked on a journey to create a tool that could generate light-hearted, non-offensive insults for programmers. Why, you ask? Well, because who doesn’t love a good-natured jest about their favorite (or not-so-favorite) programming language? And thus, insults.dev was born.&lt;/p&gt;

&lt;p&gt;Insults.dev is a web application that serves up playful jabs at developers based on their chosen programming language or framework. Built using Vue.js for the frontend and FastAPI for the backend. The real star of the show, however, is OpenAI’s GPT-3, a language model so advanced it can generate text that’s almost indistinguishable from human writing. And in this case, it’s been trained to be a comedic genius.&lt;/p&gt;

&lt;p&gt;Prompt engineering is a bit like telling a joke. You need to set it up just right to get the punchline to land. In the case of insults.dev, the punchline is the insult, and the setup is the prompt I feed to GPT-3. It took a bit of trial and error, but eventually, I found the sweet spot that consistently produced insults that were funny, relevant, and just a bit cheeky. Here is what my generate_insult function looks like:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;generate_insult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;        Generate insult for a developer of &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;You are a developer insult generator that gets a &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;                programming language or framework as input from the user and &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\
&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;                    generates a not very offensive insult.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;openai&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ChatCompletion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gpt-3.5-turbo-0613&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;insult&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;choices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;insult&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prompt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This project is part of my learning journey to get better at prompt engineering and build more significant applications that utilize LLMs. The code is all available under MIT License &lt;a href=&quot;https://github.com/aliirz/insults.dev&quot;&gt;here&lt;/a&gt; at Github. I hope you enjoy it as much as I enjoyed building it. And if you have any suggestions for improvements, please feel free to open an issue or submit a pull request.&lt;/p&gt;

&lt;div style=&quot;width:100%;height:0;padding-bottom:100%;position:relative;&quot;&gt;&lt;iframe src=&quot;https://giphy.com/embed/l0K4mbH4lKBhAPFU4&quot; width=&quot;100%&quot; height=&quot;100%&quot; style=&quot;position:absolute&quot; frameborder=&quot;0&quot; class=&quot;giphy-embed&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://giphy.com/gifs/dab-dabbing-bill-gates-l0K4mbH4lKBhAPFU4&quot;&gt;via GIPHY&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="gpt-3" /><category term="prompt-engineering" /><category term="vue" /><category term="python" /><summary type="html">In the grand tradition of friendly banter among developers, I embarked on a journey to create a tool that could generate light-hearted, non-offensive insults for programmers. Why, you ask? Well, because who doesn’t love a good-natured jest about their favorite (or not-so-favorite) programming language? And thus, insults.dev was born.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/aliirz_two_software_developers_shouting_at_each_other_while_hol_068209cd-1bc4-4d02-92cb-cff624119ea7.png" /><media:content medium="image" url="https://aliirz.com/images/aliirz_two_software_developers_shouting_at_each_other_while_hol_068209cd-1bc4-4d02-92cb-cff624119ea7.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Up &amp;amp; Running with PostgreSQL with Docker</title><link href="https://aliirz.com/up-running-with-postgresql-with-docker" rel="alternate" type="text/html" title="Up &amp;amp; Running with PostgreSQL with Docker" /><published>2023-07-05T19:03:00+00:00</published><updated>2023-07-05T19:03:00+00:00</updated><id>https://aliirz.com/up-running-with-postgresql-with-docker</id><content type="html" xml:base="https://aliirz.com/up-running-with-postgresql-with-docker">&lt;p&gt;If you are like me and need a quick way to spin up a PostgreSQL instance with PG admin, here is a docker compose file that you can use to do that.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3&apos;&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;postgres:15&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;always&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.env&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;5432:5432&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;db-data:/var/lib/postgresql/data&lt;/span&gt;

  &lt;span class=&quot;na&quot;&gt;pgadmin&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;dpage/pgadmin4&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;always&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.env&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;8090:80&quot;&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;pgadmin-data:/var/lib/pgadmin&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;depends_on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;db&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;db-data&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;pgadmin-data&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;your .env file should look something like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;POSTGRES_USER=postgres
POSTGRES_PASSWORD=example
POSTGRES_DB=mydatabase
PGADMIN_DEFAULT_EMAIL=admin@example.com
PGADMIN_DEFAULT_PASSWORD=example
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now all you need to dop is run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker-compose -f &amp;lt;yourfile&amp;gt;.yml up -d&lt;/code&gt; and you should be good to go. The PG admin will be available at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://localhost:8090&lt;/code&gt; and you can use the credentials from your .env file to login. You will need to grab your docker container’s ip address to connect to the database from your local machine. You can do that by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;docker inspect &amp;lt;container-id&amp;gt; | grep &quot;IPAddress&quot;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@ikukevk?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Kevin Ku&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/photos/w7ZyuGYNpRQ?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="docker" /><category term="postgresql" /><summary type="html">If you are like me and need a quick way to spin up a PostgreSQL instance with PG admin, here is a docker compose file that you can use to do that.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/kevin-ku-w7ZyuGYNpRQ-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/kevin-ku-w7ZyuGYNpRQ-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">My Favorite Video Games in Wes Anderson Style</title><link href="https://aliirz.com/video-games-as-wes-anderson-creations" rel="alternate" type="text/html" title="My Favorite Video Games in Wes Anderson Style" /><published>2023-06-30T07:03:00+00:00</published><updated>2023-06-30T07:03:00+00:00</updated><id>https://aliirz.com/video-games-as-wes-anderson-creations</id><content type="html" xml:base="https://aliirz.com/video-games-as-wes-anderson-creations">&lt;p&gt;I recently tweeted a &lt;a href=&quot;https://twitter.com/aliirz/status/1674700441291210753&quot; target=&quot;_blank&quot;&gt;thread&lt;/a&gt; about this but just in case adding them all here as well.&lt;/p&gt;

&lt;h2 id=&quot;the-witcher&quot;&gt;The Witcher&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz23_egacAAeomc?format=jpg&amp;amp;name=medium&quot; alt=&quot;The Witcher&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;spider-man&quot;&gt;Spider-Man&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz24FEOagAckGL5?format=jpg&amp;amp;name=medium&quot; alt=&quot;Spider-Man&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;god-of-war&quot;&gt;God of War&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz24IPWaMAEZi5e?format=jpg&amp;amp;name=medium&quot; alt=&quot;God of War&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-legend-of-zelda&quot;&gt;The Legend of Zelda&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz24Lt0aUAATrHa?format=jpg&amp;amp;name=medium&quot; alt=&quot;Zelda&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;metal-gear-solid&quot;&gt;Metal Gear Solid&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz24OPmaYAAw-qZ?format=jpg&amp;amp;name=medium&quot; alt=&quot;MGS&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;animal-crossing&quot;&gt;Animal Crossing&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz25OdoakAAfIHE?format=jpg&amp;amp;name=medium&quot; alt=&quot;Animal Crossing&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;mass-effect&quot;&gt;Mass Effect&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz25zbkaYAAKqOa?format=jpg&amp;amp;name=medium&quot; alt=&quot;Mass Effect&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;final-fantasy&quot;&gt;Final Fantasy&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz26v5WaYAIOolT?format=jpg&amp;amp;name=medium&quot; alt=&quot;Final Fantasy&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;skyrim&quot;&gt;Skyrim&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz268LeaAAAcxWw?format=jpg&amp;amp;name=medium&quot; alt=&quot;Skyrim&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;cyberpunk-2077&quot;&gt;Cyberpunk: 2077&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://pbs.twimg.com/media/Fz27FYbagAAeM7p?format=jpg&amp;amp;name=medium&quot; alt=&quot;Cyberpunk-2077&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Personally I would love to see a collab between Kojima San and Mr. Anderson. I think they would make a great team.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="midjourney" /><summary type="html">I recently tweeted a thread about this but just in case adding them all here as well.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/jonathan-kemper-hpz88a0NUS8-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/jonathan-kemper-hpz88a0NUS8-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Docker Environment Variables vs Arguments</title><link href="https://aliirz.com/Docker-Args-and-Env-Vars" rel="alternate" type="text/html" title="Docker Environment Variables vs Arguments" /><published>2023-05-20T10:03:00+00:00</published><updated>2023-05-20T10:03:00+00:00</updated><id>https://aliirz.com/Docker-Args-and-Env-Vars</id><content type="html" xml:base="https://aliirz.com/Docker-Args-and-Env-Vars">&lt;p&gt;I have worked with docker for over 7 years now and I still get confused about the difference between environment variables and arguments. In this post I try to simplify the distinction and explain when to use what.&lt;/p&gt;

&lt;h2 id=&quot;whats-the-difference-between-env-and-arg-variables-and-why-should-i-care&quot;&gt;Whats the difference between ENV and ARG variables and why should I care?&lt;/h2&gt;

&lt;h3 id=&quot;arg-and-env-in-dockerfile&quot;&gt;ARG and ENV in Dockerfile&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;ARG and ENV are ways to define variables in a Dockerfile.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;arg-variables&quot;&gt;ARG variables&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;ARG variables are only available during the build process.&lt;/li&gt;
  &lt;li&gt;ARG variables are used to pass values to the Dockerfile.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;env-variables&quot;&gt;ENV variables&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;ENV variables are available to running containers.&lt;/li&gt;
  &lt;li&gt;ENV variables are used to set environment variables for running containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;using-arg-and-env-together&quot;&gt;Using ARG and ENV together&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;You can use ARG values to set ENV values. This is a common way to set default values for environment variables.&lt;/li&gt;
  &lt;li&gt;For example, you could use an ARG variable to specify the name of a package to install, and then use an ENV variable to set the path to the installed package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following image from VSUPALOV illustrated this beautifully.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://vsupalov.com/images/docker-env-vars/docker_environment_build_args.png&quot; alt=&quot;Illustration credits VSUPALOV&quot; title=&quot;image credits https://vsupalov.com/docker-arg-vs-env/&quot; /&gt;.&lt;/p&gt;

&lt;h2 id=&quot;how-do-i-use-args-and-env-vars&quot;&gt;How do I use ARGs and ENV Vars?&lt;/h2&gt;

&lt;h3 id=&quot;using-args&quot;&gt;Using ARGs&lt;/h3&gt;
&lt;p&gt;As stated above these need to be passed and defined before the build process. You would define an ARG in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt; like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ARG my_mighty_arg
RUN &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;the value of my mighty arg is &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$my_mighty_arg&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;What this does is it lets Docker know that this image we are builidng should expect an argument called my_mighty_arg. A value for which we will pass when we are building our image like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker build &lt;span class=&quot;nt&quot;&gt;--build-arg&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;my_mighty_arg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;a_mighty_value .&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;so when we run this we should see something like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;the value of my mighty arg is a_mighty_value&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Thats it the ARG has served its purpose and will not be available beyond the docker build scope.&lt;/p&gt;

&lt;h3 id=&quot;using-env-vars&quot;&gt;Using ENV VARS&lt;/h3&gt;
&lt;p&gt;On the other hand ENV VARS are available to the running container. Imagine passing information to your continaer via env var that populates itself through a build time ARG. You can define an ENV VAR in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt; like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ARG my_might_arg
ENV &lt;span class=&quot;nv&quot;&gt;env_var_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$my_might_arg&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Another way is to simple pass the ENV VAR in the command line:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker run &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;env_var_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;a_mighty_value .&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;conclustion&quot;&gt;Conclustion&lt;/h3&gt;
&lt;p&gt;In conclusion, ARG and ENV variables are both useful tools for defining variables in a Dockerfile. ARG variables are only available during the build process and are used to pass values to the Dockerfile, while ENV variables are available to running containers and are used to set environment variables for running containers. You can use ARG values to set ENV values, which is a common way to set default values for environment variables. By understanding the difference between ARG and ENV variables, you can better manage your Docker images and containers and ensure that your applications run smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Photo by &lt;a href=&quot;https://unsplash.com/@ourselp?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Philippe Oursel&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/s/photos/docker?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="docker" /><summary type="html">I have worked with docker for over 7 years now and I still get confused about the difference between environment variables and arguments. In this post I try to simplify the distinction and explain when to use what.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/philippe-oursel-06y6wukkSKg-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/philippe-oursel-06y6wukkSKg-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Learning SwiftUI by building a URL Shortener iOS App</title><link href="https://aliirz.com/Swiftui-url-shortener" rel="alternate" type="text/html" title="Learning SwiftUI by building a URL Shortener iOS App" /><published>2023-03-22T05:19:00+00:00</published><updated>2023-03-22T05:19:00+00:00</updated><id>https://aliirz.com/Swiftui-url-shortener</id><content type="html" xml:base="https://aliirz.com/Swiftui-url-shortener">&lt;h2 id=&quot;rediscovering-ios-development-from-objective-c-to-swiftui&quot;&gt;Rediscovering iOS Development: From Objective-C to SwiftUI&lt;/h2&gt;
&lt;p&gt;I ws a iOS developer in a past life who started his career more than eight years ago, I have seen firsthand the remarkable evolution of the iOS ecosystem. Back in the day, Objective-C was the go-to language for developing iOS applications, and we had to deal with manual memory management without the luxury of Automatic Reference Counting (ARC). Today, we have SwiftUI, a powerful and intuitive framework that makes it easier than ever to create beautiful user interfaces across all Apple platforms.&lt;/p&gt;

&lt;h2 id=&quot;starting-with-swiftui&quot;&gt;Starting with SwiftUI&lt;/h2&gt;
&lt;p&gt;Apple introduced SwiftUI at WWDC 2019 as a powerful, easy-to-use UI toolkit that enables developers to design apps for iOS, macOS, watchOS, and tvOS using Swift code. With its declarative syntax, SwiftUI simplifies the process of building user interfaces by allowing developers to describe the UI’s appearance and behavior.&lt;/p&gt;

&lt;p&gt;As I began my SwiftUI journey, I found Apple’s official SwiftUI tutorials to be an excellent starting point. They cover the fundamentals of building user interfaces, as well as more advanced topics like data flow and animations. Additionally, I discovered several online resources, such as articles, YouTube videos, and Stack Overflow threads, that provided invaluable insights and assistance throughout my learning process.&lt;/p&gt;

&lt;h2 id=&quot;building-a-url-shortener-ios-app&quot;&gt;Building a URL Shortener iOS App&lt;/h2&gt;
&lt;p&gt;After familiarizing myself with SwiftUI concepts and syntax, I decided to create a &lt;a href=&quot;https://github.com/aliirz/Swift-Url-Shortener&quot;&gt;URL shortener iOS app&lt;/a&gt;. This project would serve as a practical way to solidify my understanding and apply the knowledge I had acquired.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;images/url-shorten-app.png&quot; alt=&quot;image of the app running on simulator&quot; title=&quot;Default UI but its honest work&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;The app I built is straightforward: users enter a long URL into a text field, tap a button to generate a short URL using the Bitly API, and the resulting short URL is copied to the user’s clipboard. To ensure smooth interactions with the Bitly API, I chose to integrate the Alamofire library, which simplifies the process of making network requests.&lt;/p&gt;

&lt;p&gt;During the development of the app, I encountered several challenges that deepened my understanding of SwiftUI. First, I learned about the @State, @ObservedObject, and @Published property wrappers, which are crucial for managing data flow and state changes in SwiftUI. Second, I explored how to present alerts based on state changes and handle user input validation. Overall, this project served as an excellent hands-on introduction to SwiftUI.&lt;/p&gt;

&lt;h2 id=&quot;moving-forward&quot;&gt;Moving Forward&lt;/h2&gt;
&lt;p&gt;My experience building the URL shortener app reinforced the importance of practice and real-world application when learning a new programming language or framework. By diving into SwiftUI and working on a practical project, I was able to grasp concepts more effectively and identify areas that required further study.&lt;/p&gt;

&lt;p&gt;This journey has been a testament to how far iOS development has come since my early days working with Objective-C. As I continue to explore SwiftUI and apply my knowledge to more complex projects, I’m excited about the endless possibilities—from building productivity apps to creating games or even designing tools to help fellow developers. I’m eager to see where my SwiftUI journey takes me next and how it will shape my future as a developer.&lt;/p&gt;

&lt;p&gt;The app code is open source and available on &lt;a href=&quot;https://github.com/aliirz/Swift-Url-Shortener&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="swiftui" /><summary type="html">Rediscovering iOS Development: From Objective-C to SwiftUI I ws a iOS developer in a past life who started his career more than eight years ago, I have seen firsthand the remarkable evolution of the iOS ecosystem. Back in the day, Objective-C was the go-to language for developing iOS applications, and we had to deal with manual memory management without the luxury of Automatic Reference Counting (ARC). Today, we have SwiftUI, a powerful and intuitive framework that makes it easier than ever to create beautiful user interfaces across all Apple platforms.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/animation_500_lfk7n0ml.gif" /><media:content medium="image" url="https://aliirz.com/images/animation_500_lfk7n0ml.gif" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">KYC using Plaid in a swiftui app</title><link href="https://aliirz.com/Plaid-for-KYC-in-swiftui" rel="alternate" type="text/html" title="KYC using Plaid in a swiftui app" /><published>2023-03-09T15:19:00+00:00</published><updated>2023-03-09T15:19:00+00:00</updated><id>https://aliirz.com/Plaid-for-KYC-in-swiftui</id><content type="html" xml:base="https://aliirz.com/Plaid-for-KYC-in-swiftui">&lt;p&gt;I am working on something very cool these days. I am not ready to make it public yet but I can tell you that it’s a fintech app. And it’s going to be awesome!&lt;/p&gt;

&lt;p&gt;Going back to my roots as an iOS engineer I took a deep dive into SwiftUI. I am in love with its imperative style and the fact that it’s so easy to use. I am also a big fan of Combine and the fact that it’s built into SwiftUI makes it even better.&lt;/p&gt;

&lt;p&gt;We have to use Plaid for a key function of the app to do KYC. I was a bit worried about how to do it in SwiftUI. But it turned out to be pretty easy. Here’s how you can do it in your SwiftUI app.&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;A Plaid account
Xcode 13 or later
A basic understanding of SwiftUI and MVVM architecture&lt;/p&gt;

&lt;h2 id=&quot;step-1-install-plaid-sdk&quot;&gt;Step 1: Install Plaid SDK&lt;/h2&gt;

&lt;p&gt;The first step is to install the Plaid SDK in your project. Plaid provides SDKs for iOS, Android, and web applications. In this tutorial, we will be using the iOS SDK.&lt;/p&gt;

&lt;p&gt;You can install the SDK using Cocoapods, Carthage, or Swift Package Manager. For this tutorial, we will use Cocoapods. Add the following line to your Podfile:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;pod &lt;span class=&quot;s1&quot;&gt;&apos;Plaid&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, run the following command to install the SDK:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;pod &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-2-create-a-plaid-account&quot;&gt;Step 2: Create a Plaid Account&lt;/h2&gt;

&lt;p&gt;If you haven’t already, create a Plaid account and sign up for the KYC service. You will need to provide some information about your app and your company. After you sign up, you will receive a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client_id&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public_key&lt;/code&gt; that you will use to authenticate your requests.&lt;/p&gt;

&lt;h2 id=&quot;step-3-create-a-plaid-configuration&quot;&gt;Step 3: Create a Plaid Configuration&lt;/h2&gt;

&lt;p&gt;Create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidConfiguration&lt;/code&gt; object with your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client_id&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public_key&lt;/code&gt;. You can also set other options such as the environment (sandbox or production) and the country.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-swift&quot; data-lang=&quot;swift&quot;&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;configuration&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PlaidConfiguration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;clientID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;your_client_id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;publicKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;your_public_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sandbox&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;US&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-4-present-plaid-link-view&quot;&gt;Step 4: Present Plaid Link View&lt;/h2&gt;

&lt;p&gt;Plaid Link is a pre-built UI component that allows users to securely connect their bank accounts. To present the Plaid Link view, create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidLinkView&lt;/code&gt; with your configuration and present it using a sheet.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-swift&quot; data-lang=&quot;swift&quot;&gt;&lt;span class=&quot;kd&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ContentView&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;@State&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;isPresentingPlaidLinkView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;@State&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;plaidLinkToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;some&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;VStack&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kt&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Connect Bank Account&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;isPresentingPlaidLinkView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sheet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;isPresented&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;$isPresentingPlaidLinkView&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;PlaidLinkView&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plaidLinkToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;token&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;plaidLinkToken&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;token&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// handle success&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;failure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// handle failure&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;isPresentingPlaidLinkView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-5-kyc-using-plaid&quot;&gt;Step 5: KYC using Plaid&lt;/h2&gt;
&lt;p&gt;You can use Plaid to perform Know Your Customer (KYC) verification using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidLinkView&lt;/code&gt;. KYC verification is an important step in financial transactions to ensure that you are complying with regulations and avoiding fraud.&lt;/p&gt;

&lt;p&gt;To perform KYC verification using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidLinkView&lt;/code&gt;, you can use Plaid’s Identity API. The Identity API allows you to retrieve various types of personal information about the user, such as name, address, and date of birth, from their linked financial accounts. You can use this information to verify the user’s identity and perform KYC checks.&lt;/p&gt;

&lt;p&gt;Here’s an example of how you could use the Identity API to retrieve the user’s name and address after they successfully link their financial account using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidLinkView&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-swift&quot; data-lang=&quot;swift&quot;&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;linkView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PlaidLinkView&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;makeTestConfiguration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;onSuccess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;completion&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;PLKPlaid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;createToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sandbox&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;publicKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;YOUR_PUBLIC_KEY&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;institution&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tartan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;selectAccount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;accountFilters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nv&quot;&gt;publicToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;publicToken&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;tokenResponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;request&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PLKGetIdentityRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                    &lt;span class=&quot;nv&quot;&gt;accessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accessToken&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;kt&quot;&gt;PLKPlaid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;getIdentity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;identityResponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;identityResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;owners&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;identityResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;owners&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addresses&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;city&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// Use the name and address for KYC verification&lt;/span&gt;
                        &lt;span class=&quot;nf&quot;&gt;completion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;failure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// Handle the error&lt;/span&gt;
                        &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Failed to retrieve identity: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;localizedDescription&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                        &lt;span class=&quot;nf&quot;&gt;completion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;failure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// Handle the error&lt;/span&gt;
                &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Failed to create token: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;localizedDescription&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;nf&quot;&gt;completion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;onFailure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Handle the failure&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Plaid Link exited with error: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;localizedDescription&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;present&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linkView&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In this example, we create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PlaidLinkView&lt;/code&gt; and present it. When the user successfully links their financial account, the onSuccess closure is called with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PLKSuccess&lt;/code&gt; object and a completion handler. Inside the closure, we call the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PLKPlaid.createToken&lt;/code&gt; method to exchange the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;publicToken&lt;/code&gt; for an access token. If the exchange is successful, we use the access token to retrieve the user’s name and address using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PLKGetIdentityRequest&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PLKPlaid.client().getIdentity&lt;/code&gt; method. If there is an error, we handle it by printing an error message. If the user exits Plaid Link before linking their account, the onFailure closure is called with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PLKExit&lt;/code&gt; object and an optional error. In this example, we handle the failure by printing an error message.&lt;/p&gt;

&lt;p&gt;You can modify this example to retrieve other types of personal information using the Identity API, such as date of birth and social security number, depending on your KYC requirements. Be sure to review Plaid’s documentation and comply with their requirements and regulations for handling user data.&lt;/p&gt;

&lt;p&gt;You can checkout Plaid’s documentation &lt;a href=&quot;https://plaid.com/docs/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="swiftui" /><summary type="html">I am working on something very cool these days. I am not ready to make it public yet but I can tell you that it’s a fintech app. And it’s going to be awesome!</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/plaid-kyc.png" /><media:content medium="image" url="https://aliirz.com/images/plaid-kyc.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Using inject and provide in vue 3</title><link href="https://aliirz.com/Inject-and-Provide-in-vue-3" rel="alternate" type="text/html" title="Using inject and provide in vue 3" /><published>2023-03-05T19:19:00+00:00</published><updated>2023-03-05T19:19:00+00:00</updated><id>https://aliirz.com/Inject-and-Provide-in-vue-3</id><content type="html" xml:base="https://aliirz.com/Inject-and-Provide-in-vue-3">&lt;p&gt;Vue 3 has some cool new features, including “inject” and “provide”, which allow you to share data between parent and child components without having to pass it down as props. This makes your components more modular and reusable.&lt;/p&gt;

&lt;p&gt;“Provide” is used in the parent component to provide data, which can be anything like a string, object, or function. “Inject” is used in the child component to get access to that data.&lt;/p&gt;

&lt;p&gt;For example, let’s say you have a “message” variable in your parent component that you want to share with your child component. You can use “provide” to make that happen:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Parent Component&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;provide&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;vue&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello from parent!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;nf&quot;&gt;provide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then, in your child component, you can use “inject” to get that “message” variable:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Child Component&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;inject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;vue&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;inject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;By using “provide” and “inject”, you can make your Vue 3 components more efficient and organized. Plus, the syntax is super easy to use!&lt;/p&gt;

&lt;p&gt;You can read more &lt;a href=&quot;https://vuejs.org/guide/components/provide-inject.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="vue3" /><category term="javascript" /><summary type="html">Vue 3 has some cool new features, including “inject” and “provide”, which allow you to share data between parent and child components without having to pass it down as props. This makes your components more modular and reusable.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/araza_vue_js_logo_disney_like_art_style_c455cfcb-7fb1-44ea-9d35-1beafb11c720.png" /><media:content medium="image" url="https://aliirz.com/images/araza_vue_js_logo_disney_like_art_style_c455cfcb-7fb1-44ea-9d35-1beafb11c720.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Job Opening MEAN Stack Developer</title><link href="https://aliirz.com/Job-Opening-Mean-stack-dev" rel="alternate" type="text/html" title="Job Opening MEAN Stack Developer" /><published>2022-12-14T16:52:00+00:00</published><updated>2022-12-14T16:52:00+00:00</updated><id>https://aliirz.com/Job-Opening-Mean-stack-dev</id><content type="html" xml:base="https://aliirz.com/Job-Opening-Mean-stack-dev">&lt;p&gt;&lt;strong&gt;Position&lt;/strong&gt;: Mean Stack Developer (Full-time)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experience&lt;/strong&gt; : 2+ years&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Location&lt;/strong&gt; : Islamabad, Pakistan (Remote)&lt;/p&gt;

&lt;h2 id=&quot;job-description&quot;&gt;Job Description&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;A flexible, proactive attitude to work and must have an Agile mindset.&lt;/li&gt;
  &lt;li&gt;Previous working experience as a MEAN Stack Developer for at least 2 years.&lt;/li&gt;
  &lt;li&gt;Expert Level Knowledge of HTML, CSS and JavaScript (including ES6).&lt;/li&gt;
  &lt;li&gt;Strong knowledge of data structures and algorithms&lt;/li&gt;
  &lt;li&gt;Excellent communications skills both verbal and written.&lt;/li&gt;
  &lt;li&gt;Understanding of non-relational and relational databases such as MongoDB, SQL.&lt;/li&gt;
  &lt;li&gt;Good hands-on experience using Angular&lt;/li&gt;
  &lt;li&gt;Experience in integrating third party APIs and services.&lt;/li&gt;
  &lt;li&gt;Ability to learn quickly and operate in a fast-paced environment.&lt;/li&gt;
  &lt;li&gt;Basic knowledge of python and flask api.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;responsibilities&quot;&gt;Responsibilities&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Developing web-based applications using the MEAN stack, including Angular, Node.js, and MongoDB&lt;/li&gt;
  &lt;li&gt;Creating RESTful services with Node.js&lt;/li&gt;
  &lt;li&gt;Writing unit test and integration tests&lt;/li&gt;
  &lt;li&gt;Writing re-useable, testable, and efficient code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;nice-to-haves&quot;&gt;Nice to Haves&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Experience working with a remote team.&lt;/li&gt;
  &lt;li&gt;Understanding of Continuous Integration and Deployment process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you think you fit the bill, please send your resume to SaqibHussain990@gmail.com with the subject line “MEAN Stack Developer”. Please include a link to your portfolio or GitHub profile.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="job opening" /><summary type="html">Position: Mean Stack Developer (Full-time)</summary></entry><entry><title type="html">Same day skunk works</title><link href="https://aliirz.com/Same-day-skunk-works" rel="alternate" type="text/html" title="Same day skunk works" /><published>2022-11-22T08:56:00+00:00</published><updated>2022-11-22T08:56:00+00:00</updated><id>https://aliirz.com/Same-day-skunk-works</id><content type="html" xml:base="https://aliirz.com/Same-day-skunk-works">&lt;p&gt;I came across this really interesting experiment by &lt;a href=&quot;https://ae.studio&quot;&gt;A.E Studio&lt;/a&gt;. They have taken this initiative to launch a tool every day. Most of us who build Saas for a living understand the importance of skunkworks software. Check out their intiative &lt;a href=&quot;https://www.samedayskunkworks.com&quot;&gt;Same Day Skunk Works&lt;/a&gt;. Maybe you will find the motivation to build that Saas you have been thinking about for a while.&lt;/p&gt;

&lt;p&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/LJCEdNx7pfg&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="100daysofcode" /><summary type="html">I came across this really interesting experiment by A.E Studio. They have taken this initiative to launch a tool every day. Most of us who build Saas for a living understand the importance of skunkworks software. Check out their intiative Same Day Skunk Works. Maybe you will find the motivation to build that Saas you have been thinking about for a while.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/same-day-skunk-works.png" /><media:content medium="image" url="https://aliirz.com/images/same-day-skunk-works.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Proof of Stake vs Proof of Work</title><link href="https://aliirz.com/Proof-of-stake-vs-proof-of-work" rel="alternate" type="text/html" title="Proof of Stake vs Proof of Work" /><published>2022-11-01T21:28:00+00:00</published><updated>2022-11-01T21:28:00+00:00</updated><id>https://aliirz.com/Proof-of-stake-vs-proof-of-work</id><content type="html" xml:base="https://aliirz.com/Proof-of-stake-vs-proof-of-work">&lt;p&gt;I have loved the ethereum ecosystem ever since its inception. Sadly I have not yet gottent the opportunity to do any mainstream project on it other than some code labs for practice. We are living in wonderful times, we have witnessed a true transiton in the that breaks a monopoly and makes the system more fair. Allow me to explain in a few lines.&lt;/p&gt;

&lt;p&gt;The Ethereum network is a decentralized blockchain that allows for the creation of smart contracts, decentralized applications (Dapps), and other decentralized applications (dapps). The network has two types of consensus: Proof of Work and Proof of Stake.&lt;/p&gt;

&lt;p&gt;Proof of Work (PoW) is a system in which miners compete to be the first to solve a hash problem and earn the right to add a block to the chain. Miners are rewarded with ether for their work.&lt;/p&gt;

&lt;p&gt;Proof of Stake (PoS) is a system where users who hold tokens on their Ethereum wallets earn interest for their holdings through transaction fees. Users can also choose to stake their currency, which means they lock up their funds as collateral until they receive more tokens than they’ve staked. This means that users essentially lend their money to people who have asked them if they want to use it as collateral while they mine new ether or look for blocks to win rewards from mining pools.&lt;/p&gt;

&lt;p&gt;To summarize here is a little matrix:&lt;/p&gt;

&lt;div class=&quot;table-container&quot;&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;th&gt;Proof of Work&lt;/th&gt;
            &lt;th&gt;Proof of Stake&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Miners compete to solve a hash problem and earn the right to add a block to the chain&lt;/td&gt;
            &lt;td&gt;Users who hold tokens on their Ethereum wallets earn interest for their holdings through transaction fees&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Miners are rewarded with ether for their work&lt;/td&gt;
            &lt;td&gt;Users can also choose to stake their currency, which means they lock up their funds as collateral until they receive more tokens than they&apos;ve staked&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Requires a lot of compute power&lt;/td&gt;
            &lt;td&gt;Does not require a lot of compute power&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@dvlden?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Nenad Novaković&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/s/photos/ethereum?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="ethereum" /><summary type="html">I have loved the ethereum ecosystem ever since its inception. Sadly I have not yet gottent the opportunity to do any mainstream project on it other than some code labs for practice. We are living in wonderful times, we have witnessed a true transiton in the that breaks a monopoly and makes the system more fair. Allow me to explain in a few lines.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/nenad-novakovic-L2QB-rG5NM0-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/nenad-novakovic-L2QB-rG5NM0-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">What is docker</title><link href="https://aliirz.com/What-is-Docker" rel="alternate" type="text/html" title="What is docker" /><published>2022-10-25T11:33:35+00:00</published><updated>2022-10-25T11:33:35+00:00</updated><id>https://aliirz.com/What-is-Docker</id><content type="html" xml:base="https://aliirz.com/What-is-Docker">&lt;p&gt;Docker is a containerization platform that allows us to deploy our applications inside a container and then we can easily ship that container anywhere.&lt;/p&gt;

&lt;p&gt;Docker uses the host operating system kernel, this makes docker containers really lightweight because you don’t have to have a guest OS inside your container. This also means that you can run any type of application you want inside it since the OS is the same as the host OS.&lt;/p&gt;

&lt;p&gt;Docker containers are isolated from each other, they share the same host OS, this means that if a container gets compromised other containers will not get affected.&lt;/p&gt;

&lt;p&gt;You can create multiple services using docker e.g. If your project consists of front-end and back-end technologies, you can create separate images for both front &amp;amp; back then connect them together to form a complete application.&lt;/p&gt;

&lt;p&gt;Docker lets you build, run, test and deploy your code in an easy way&lt;/p&gt;

&lt;p&gt;Here is a slide deck I created to explain docker in a simple way:&lt;/p&gt;

&lt;iframe src=&quot;https://docs.google.com/presentation/d/e/2PACX-1vQ_tlhDyxUOXyLL23fkwUraw2jn7yhKZIsn7jmY12t1FI-YuDSq_yKzVyomDGnAwyPjpaBoMaLcqlyi/embed?start=false&amp;amp;loop=false&amp;amp;delayms=5000&quot; frameborder=&quot;0&quot; width=&quot;960&quot; height=&quot;569&quot; allowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot; webkitallowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;</content><author><name>Ali Raza</name></author><category term="docker" /><summary type="html">Docker is a containerization platform that allows us to deploy our applications inside a container and then we can easily ship that container anywhere.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/Moby-logo.png" /><media:content medium="image" url="https://aliirz.com/images/Moby-logo.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">FloodLight</title><link href="https://aliirz.com/Flood-Light" rel="alternate" type="text/html" title="FloodLight" /><published>2022-09-01T08:33:35+00:00</published><updated>2022-09-01T08:33:35+00:00</updated><id>https://aliirz.com/Flood-Light</id><content type="html" xml:base="https://aliirz.com/Flood-Light">&lt;p&gt;Pakistan has been hit by the worst flood ever this year. At the time of writing this post, the flood affected a total of over 1.5 million people. Here are a few stats:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Deaths&lt;/th&gt;
      &lt;th&gt;INJURED&lt;/th&gt;
      &lt;th&gt;ROADS DESTROYED&lt;/th&gt;
      &lt;th&gt;BRIDGES DESTROYED&lt;/th&gt;
      &lt;th&gt;HOUSES DESTROYED&lt;/th&gt;
      &lt;th&gt;LIVESTOCK DEATHS&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1061&lt;/td&gt;
      &lt;td&gt;1575&lt;/td&gt;
      &lt;td&gt;3475km&lt;/td&gt;
      &lt;td&gt;157&lt;/td&gt;
      &lt;td&gt;992870&lt;/td&gt;
      &lt;td&gt;727144&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;While many organizations are doing the best they can to assist. Our small team at Code for Pakistan took it upon ourselves to try and crowdsource as much data as we can. Hence floodlight, something we cooked up in a few hours. You can check it out &lt;a href=&quot;https://pak-flood.ushahidi.io&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@jeanbeller?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Jéan Béller&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/s/photos/flood?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="civic tech" /><category term="code for all" /><category term="code for pakistan" /><category term="gov 2.0" /><category term="pakistan flood" /><category term="open data" /><category term="crowd sourcing" /><summary type="html">Pakistan has been hit by the worst flood ever this year. At the time of writing this post, the flood affected a total of over 1.5 million people. Here are a few stats:</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/jean-beller-BN5tccq1qYk-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/jean-beller-BN5tccq1qYk-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Covid Positive Day 1</title><link href="https://aliirz.com/covid-diaries-episode-1" rel="alternate" type="text/html" title="Covid Positive Day 1" /><published>2022-01-06T15:53:35+00:00</published><updated>2022-01-06T15:53:35+00:00</updated><id>https://aliirz.com/covid-diaries-episode-1</id><content type="html" xml:base="https://aliirz.com/covid-diaries-episode-1">&lt;p&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/l1Qlez28YRw&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@cdc?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;CDC&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="covid-diaries" /><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/cdc-k0KRNtqcjfw-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/cdc-k0KRNtqcjfw-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Dockerize your angular app</title><link href="https://aliirz.com/Dockerize-your-angular-app" rel="alternate" type="text/html" title="Dockerize your angular app" /><published>2021-12-31T19:24:35+00:00</published><updated>2021-12-31T19:24:35+00:00</updated><id>https://aliirz.com/Dockerize-your-angular-app</id><content type="html" xml:base="https://aliirz.com/Dockerize-your-angular-app">&lt;p&gt;Happy 2020 Too! If you stubmled across this post searching for how to run your uber cool angular app using docker, you are at the right place. Lets start at the begining. This is how you would normally create a new angular app:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ng new my-app&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Cool! Now here is what I do with my Dockerfile:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;FROM node:14-alpine as build

WORKDIR /usr/local/app

COPY ./ /usr/local/app/

RUN npm &lt;span class=&quot;nb&quot;&gt;install

&lt;/span&gt;RUN npm run start&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now normally this will be it but I am going kick it up a notch.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;images/3flgzv.png&quot; alt=&quot;I am gonna pull a pro gamer move&quot; title=&quot;Pro Gamer!!!&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I am going to run my app on nginx using multi stage docker builds. This will help us run the app as if it would run on a production server:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;FROM node:14-alpine as build

WORKDIR /usr/local/app

COPY ./ /usr/local/app/

RUN npm &lt;span class=&quot;nb&quot;&gt;install

&lt;/span&gt;RUN npm run build

FROM nginx:latest

COPY &lt;span class=&quot;nt&quot;&gt;--from&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;build /usr/local/app/dist/my-app /usr/share/nginx/html

EXPOSE 80&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Thats it! Thats the post.&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@carrier_lost?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Ian Taylor&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/s/photos/docker?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="angular" /><category term="docker" /><summary type="html">Happy 2020 Too! If you stubmled across this post searching for how to run your uber cool angular app using docker, you are at the right place. Lets start at the begining. This is how you would normally create a new angular app:</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/ian-taylor-jOqJbvo1P9g-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/ian-taylor-jOqJbvo1P9g-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Adding RSS feed to your Jekyll Powered Site</title><link href="https://aliirz.com/adding-rss-feed-to-your-jekyll-site" rel="alternate" type="text/html" title="Adding RSS feed to your Jekyll Powered Site" /><published>2021-12-13T20:33:35+00:00</published><updated>2021-12-13T20:33:35+00:00</updated><id>https://aliirz.com/adding-rss-feed-to-your-jekyll-site</id><content type="html" xml:base="https://aliirz.com/adding-rss-feed-to-your-jekyll-site">&lt;p&gt;You just built your uber cool jekyll site. You just deployed it on your server. Whats this?! No RSS Feeds! Don’t sweat, I got you. See its pretty simple. you just have to do two things.&lt;/p&gt;

&lt;h2 id=&quot;add-the-jekyll-feed-gem-to-your-gemfile&quot;&gt;Add the jekyll-feed gem to your Gemfile&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem &lt;span class=&quot;s1&quot;&gt;&apos;jekyll-feed&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;add-it-to-your-_configyml-file-under-plugins&quot;&gt;Add it to your _config.yml file under plugins&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;na&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;

&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;jekyll-feed&lt;/span&gt;
  &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;run-bundle-install&quot;&gt;Run bundle install&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;bundle &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s it. Once you build or run your website, your RSS feed will be accessible at yoursite.com/feed.xml. You are welcome. 🦄&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@retrosupply?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;RetroSupply&lt;/a&gt; on &lt;a href=&quot;https://unsplash.com/s/photos/blog?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="jekyll" /><summary type="html">You just built your uber cool jekyll site. You just deployed it on your server. Whats this?! No RSS Feeds! Don’t sweat, I got you. See its pretty simple. you just have to do two things.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/retrosupply-jLwVAUtLOAQ-unsplash.jpg" /><media:content medium="image" url="https://aliirz.com/images/retrosupply-jLwVAUtLOAQ-unsplash.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Fund for Engineers who want to buy an Xbox</title><link href="https://aliirz.com/Fund-for-engineers-who-want-an-xbox" rel="alternate" type="text/html" title="Fund for Engineers who want to buy an Xbox" /><published>2021-12-10T12:01:35+00:00</published><updated>2021-12-10T12:01:35+00:00</updated><id>https://aliirz.com/Fund-for-engineers-who-want-an-xbox</id><content type="html" xml:base="https://aliirz.com/Fund-for-engineers-who-want-an-xbox">&lt;p&gt;I am planning to make a fund to help engineers like me who can afford an Xbox but are not being allowed to buy one. You can help this glorious purpose by taking a simple poll:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://n8dchycsbzy.typeform.com/to/q1BDwcDP&quot;&gt;Click here and support the cause&lt;/a&gt;&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="gaming" /><summary type="html">I am planning to make a fund to help engineers like me who can afford an Xbox but are not being allowed to buy one. You can help this glorious purpose by taking a simple poll:</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://svbtleusercontent.com/uF6K3eMyHzAJCom8s4Rgqb0xspap.png" /><media:content medium="image" url="https://svbtleusercontent.com/uF6K3eMyHzAJCom8s4Rgqb0xspap.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Pakistan’s National Anthem - Why do we forget?</title><link href="https://aliirz.com/National-Anthem-why-we-forget" rel="alternate" type="text/html" title="Pakistan’s National Anthem - Why do we forget?" /><published>2021-10-15T12:01:35+00:00</published><updated>2021-10-15T12:01:35+00:00</updated><id>https://aliirz.com/National-Anthem-why-we-forget</id><content type="html" xml:base="https://aliirz.com/National-Anthem-why-we-forget">&lt;p&gt;While searching for something entirely different we came across a discussion on &lt;a href=&quot;https://www.quora.com/Is-the-national-anthem-of-Pakistan-remembered-and-understood-by-most-Pakistanis-If-not-why&quot;&gt;quora&lt;/a&gt; that prompted us to think, why can’t any of us remember our national anthem?&lt;/p&gt;

&lt;p&gt;“Wish we had a way of reading the national anthem without having to search for it on google”, said Saqib. The rest is history. We immediately bought a &lt;a href=&quot;http://www.qomitarana.com/&quot;&gt;domain&lt;/a&gt;, set up a GitHub &lt;a href=&quot;https://github.com/aliirz/qomitarana&quot;&gt;repo&lt;/a&gt; and hunted for TTF files for a variant Nastaliq font. Within 30 minutes we deployed &lt;a href=&quot;http://www.qomitarana.com/&quot;&gt;qomitarana.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the next time you need to remind yourself what our national anthem’s words are. Remember it’s just a URL away. Oh, and the Qomi Tarana project is open source. Feel free to contribute and make it grow. Pakistan Zindabad!&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="coding" /><summary type="html">While searching for something entirely different we came across a discussion on quora that prompted us to think, why can’t any of us remember our national anthem?</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://svbtleusercontent.com/wRocTxq5nNKzGoNoAmzgjS0xspap.jpg" /><media:content medium="image" url="https://svbtleusercontent.com/wRocTxq5nNKzGoNoAmzgjS0xspap.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Comments on clean code</title><link href="https://aliirz.com/Comments-on-clean-code" rel="alternate" type="text/html" title="Comments on clean code" /><published>2021-09-09T12:01:35+00:00</published><updated>2021-09-09T12:01:35+00:00</updated><id>https://aliirz.com/Comments-on-clean-code</id><content type="html" xml:base="https://aliirz.com/Comments-on-clean-code">&lt;p&gt;So Recently at &lt;a href=&quot;https://codeforpakistan.org&quot;&gt;Code for Pakistan&lt;/a&gt; our VP Tech. made it abundantly clear that we ought to watch Uncle Bob’s &lt;a href=&quot;https://www.youtube.com/playlist?list=PLmmYSbUCWJ4x1GO839azG_BBw8rkh-zOj&quot;&gt;clean code&lt;/a&gt; video lectures. It’s a really good series of videos that make you think about the code you write everyday.&lt;/p&gt;

&lt;p&gt;This post is not about the video series but rather about the comments I found very true and witty. Whenever Uncle Bob asks the audience to focus on a particular slide the editor cuts away and focuses on the Uncle Bob’s face. Still don’t know what I am talking about? I will let the following comments explain:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I love that no matter what background we’re coming from, no matter part of the world we are from, we are united in our hatred for the video editor.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Uncle Bob: look at this piece of code
Cameraman: ah I think it’s the signal for a zoom shot of uncle bob’s face&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Uncle Bob: Look at this
Editor: haha you wish&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;“clean code - lesson 2”
starts talking about the origin on the moon
camera man points at an empty sofa
Me: wtf am I watching&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;I love the lecture, but I want to make the person who edited the video write on an old chalk blackboard “I will not obscure information” about 5000x&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;I have got a big list of slangs for the editor&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Whoever edited this: when he says “look at this” - show the board, not the person!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope the comments explain the level of unprofessionalism of the video editing. Thats all for now, keep writing clean code you all!&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="coding" /><category term="best-practices" /><summary type="html">So Recently at Code for Pakistan our VP Tech. made it abundantly clear that we ought to watch Uncle Bob’s clean code video lectures. It’s a really good series of videos that make you think about the code you write everyday.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://svbtleusercontent.com/bKUUewg3nNqwuTF4biKe2v0xspap_small.png" /><media:content medium="image" url="https://svbtleusercontent.com/bKUUewg3nNqwuTF4biKe2v0xspap_small.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Awesome Civic Tech Ideas</title><link href="https://aliirz.com/Awesome-civic-tech-ideas" rel="alternate" type="text/html" title="Awesome Civic Tech Ideas" /><published>2020-11-28T12:01:35+00:00</published><updated>2020-11-28T12:01:35+00:00</updated><id>https://aliirz.com/Awesome-civic-tech-ideas</id><content type="html" xml:base="https://aliirz.com/Awesome-civic-tech-ideas">&lt;p&gt;Have you ever wondered what you can do more for your city? Are you a developer with some really good software skills? Do you hunger to solve problems that a common citizen faces?&lt;/p&gt;

&lt;p&gt;If you are trying to find an awesome idea to work on in your free time, then look no further because we at &lt;a href=&quot;https://codeforpakistan.org/&quot;&gt;Code for Pakistan&lt;/a&gt; has this amazing curated list of civic tech ideas on our &lt;a href=&quot;https://github.com/codeforpakistan/Project-Ideas&quot;&gt;Github&lt;/a&gt;. It’s an open-source list we are trying to maintain.&lt;/p&gt;

&lt;p&gt;Have a really cool idea that you think should be on the list? Feel free to &lt;a href=&quot;https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo&quot;&gt;fork&lt;/a&gt; and submit a &lt;a href=&quot;https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork&quot;&gt;pull request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you do end up working on any of the above ideas, please do let me know. I would love to help in any way I can.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="civic tech" /><category term="code for all" /><category term="code for pakistan" /><category term="gov 2.0" /><summary type="html">Have you ever wondered what you can do more for your city? Are you a developer with some really good software skills? Do you hunger to solve problems that a common citizen faces?</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://svbtleusercontent.com/nyCH3EWsA7j3Cy7Wni5n3X0xspap_small.jpg" /><media:content medium="image" url="https://svbtleusercontent.com/nyCH3EWsA7j3Cy7Wni5n3X0xspap_small.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Redeploying gov.uk Part-1</title><link href="https://aliirz.com/Redeploying-gov-uk" rel="alternate" type="text/html" title="Redeploying gov.uk Part-1" /><published>2020-11-26T12:01:35+00:00</published><updated>2020-11-26T12:01:35+00:00</updated><id>https://aliirz.com/Redeploying-gov-uk</id><content type="html" xml:base="https://aliirz.com/Redeploying-gov-uk">&lt;p&gt;Some unique and exciting circumstances require us to redeploy &lt;a href=&quot;https://www.gov.uk/&quot;&gt;gov.uk&lt;/a&gt; for a government stakeholder. If I am honest, this seems like a huge undertaking. As cool as this sounds, the whole project scares me. I mean, look at this architecture diagram:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://svbtleusercontent.com/fSpW7BwhZVr5QnMdHn3q5k0xspap.png&quot;&gt;&lt;img src=&quot;https://svbtleusercontent.com/fSpW7BwhZVr5QnMdHn3q5k0xspap_small.png&quot; alt=&quot;download (8).png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get this behemoth of a project right, I am trying to understand its guts. It’s not your typical off the mill web application that you can fork, customize, and rebuild. It is more of a tech stack to build applications on top off.&lt;/p&gt;

&lt;p&gt;The recommended way to build applications for gov.uk is to use their &lt;a href=&quot;https://github.com/alphagov/govuk-docker&quot;&gt;docker based dev environment&lt;/a&gt;. Let’s see how far I get. This is the first of a series of posts I will be making on this expedition&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="civic tech" /><category term="code for all" /><category term="code for pakistan" /><category term="gov 2.0" /><summary type="html">Some unique and exciting circumstances require us to redeploy gov.uk for a government stakeholder. If I am honest, this seems like a huge undertaking. As cool as this sounds, the whole project scares me. I mean, look at this architecture diagram:</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://svbtleusercontent.com/tnT8s842edwq6iqy1PsBqG0xspap_small.png" /><media:content medium="image" url="https://svbtleusercontent.com/tnT8s842edwq6iqy1PsBqG0xspap_small.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Up and Running with TimescaleDB</title><link href="https://aliirz.com/Up-and-Running-TimescaleDB" rel="alternate" type="text/html" title="Up and Running with TimescaleDB" /><published>2020-04-08T05:33:35+00:00</published><updated>2020-04-08T05:33:35+00:00</updated><id>https://aliirz.com/Up-and-Running-TimescaleDB</id><content type="html" xml:base="https://aliirz.com/Up-and-Running-TimescaleDB">&lt;p&gt;I’ve been getting into time-series databases over the past few months. I got into playing with TimescaleDB and was super impressed with its capabilities. One of the important things to understand is that TimescaleDB is just Postgres at its core which means technically TimescaleDB is an extension. Following is my usual MO to quickly run an instance of TimescaleDB.&lt;/p&gt;

&lt;p&gt;Getting a docker container up:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker run &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; timescaledb &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; 5434:5434 &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;password timescale/timescaledb:latest-pg11
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Connecting to said docker container:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; timescaledb psql &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; postgres
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Creating your database:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;CREATE database tstutorial&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Connecting to your new database:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;se&quot;&gt;\c&lt;/span&gt; tstutorial
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Adding the TimescaleDB extension:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s it! Now you have a dockerized TimescaleDB instance up and running.&lt;/p&gt;</content><author><name>Ali Raza</name></author><category term="open-source" /><category term="tutorials" /><category term="todayilearned" /><summary type="html">I’ve been getting into time-series databases over the past few months. I got into playing with TimescaleDB and was super impressed with its capabilities. One of the important things to understand is that TimescaleDB is just Postgres at its core which means technically TimescaleDB is an extension. Following is my usual MO to quickly run an instance of TimescaleDB.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aliirz.com/images/w9kjeawx02a2owwc5u08.webp" /><media:content medium="image" url="https://aliirz.com/images/w9kjeawx02a2owwc5u08.webp" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>