<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Squadbase Tech Blog - Medium]]></title>
        <description><![CDATA[Tutorials and technical guides for building AI apps with Streamlit, Next.js and Morph and deliver to your team. - Medium]]></description>
        <link>https://medium.com/morph-tech-blog?source=rss----547c56bba22c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Squadbase Tech Blog - Medium</title>
            <link>https://medium.com/morph-tech-blog?source=rss----547c56bba22c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:02:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/morph-tech-blog" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Your GA4 Reports Feel Useful But Don’t Help You Decide Anything]]></title>
            <link>https://medium.com/morph-tech-blog/why-your-ga4-reports-feel-useful-but-dont-help-you-decide-anything-2ad21aba1827?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ad21aba1827</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[google-analytics]]></category>
            <dc:creator><![CDATA[Genki Daido]]></dc:creator>
            <pubDate>Mon, 20 Apr 2026 16:01:04 GMT</pubDate>
            <atom:updated>2026-04-21T00:33:28.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDjPGftTAi9xDqWjdYHugA.png" /></figure><p>GA4 reports look great on the surface — pageviews, sessions, conversions all updating daily. But the moment someone asks “why,” the dashboard goes quiet. Here’s what changes when you route that data through BigQuery.</p><h3>Introduction</h3><p>We build Squadbase, a platform that lets anyone create BI dashboards through natural language — no SQL or chart builders required.</p><p><a href="https://www.squadbase.dev/en?utm_source=medium&amp;utm_medium=social">Squadbase | Vibe Coding for Business Intelligence</a></p><p>Among the data sources Squadbase connects to — including BigQuery, Snowflake, PostgreSQL, and Google Analytics — the combination of GA4 data exported to BigQuery is one of the most practically useful for teams trying to go deeper than standard web analytics. This article explores why GA4’s standard reporting reaches a structural ceiling, what changes when you route that data through BigQuery, and how teams without dedicated analysts can still do meaningful analysis.</p><h3>GA4 Gives You Numbers, Not Answers</h3><p>Most teams that adopt GA4 go through a similar arc. Setup goes smoothly. Events are firing. Pageviews, sessions, and conversion counts are updating daily. Then someone asks: did our campaign actually drive purchases, or just traffic? Which user behaviors predict conversion? How do first-time visitors from paid search behave differently over their first three visits compared to organic ones?</p><p>The dashboard goes quiet.</p><p>This isn’t a skill gap. It’s a design constraint. GA4’s standard interface and Data API are built around a predefined set of dimensions and metrics. They’re optimized for retrieving reports that have already been defined — not for restructuring data around questions that haven’t been anticipated. When your question requires filtering users by a sequence of events, joining with external data, or building custom cohorts, standard GA4 tooling runs out of room fast.</p><h3>What Changes When You Export to BigQuery</h3><p>GA4’s BigQuery Export sends event-level raw data directly to BigQuery — every event, every user ID, every timestamp, every parameter. What you get isn’t a summary: it’s the full behavioral record, structured as rows, queryable in SQL.</p><p>This changes the nature of the question you’re allowed to ask. Instead of selecting from available report combinations, you reconstruct user behavior from the event stream. That means you can build analyses like: funnel completion rates for a specific traffic source and device type; time-to-conversion broken down by campaign; behavioral differences between users who converted and users who didn’t; or event data joined with CRM records or ad spend to trace from click to revenue.</p><p>The shift isn’t about storage location. It’s about whether your data has enough structure preserved to support arbitrary questions. GA4’s standard reports are designed for monitoring. BigQuery is designed for investigation.</p><h3>The Bottleneck That Follows</h3><p>Getting data into BigQuery solves one problem and reliably surfaces another: now you need SQL to use it.</p><p>In many teams, this creates a dependency. Marketers and business owners who want answers have to submit requests to analysts or engineers. Analysts have to re-learn the schema, write the query, format the output, and hand it back. The feedback loop between question and answer stretches from hours to days. Data that could inform weekly decisions ends up informing monthly retrospectives.</p><p>The data infrastructure is in place. The bottleneck has just moved upstream.</p><h3>Natural Language as the Missing Layer</h3><p>This is the problem Squadbase is designed to address. When BigQuery is connected, team members can ask questions in plain language — “show me how conversion rates differ by traffic source over the last 30 days” — and Squadbase handles the SQL generation, execution, and visualization automatically. The resulting chart or table is added to a shared dashboard that anyone on the team can access and build on.</p><p>Dashboards aren’t static exports. They can be updated through conversation: ask a follow-up, refine the filter, add a new segment. When the underlying data structure in BigQuery changes, dashboards can be adjusted the same way.</p><p>The goal isn’t to replace analysts. It’s to remove the friction that prevents non-analysts from participating in analysis at all.</p><h3>The Structure That Makes Decisions Faster</h3><p>When only some people on a team can query data, a hidden cost accumulates. Decisions wait. Campaigns run longer than they should without evaluation. Post-mortems are thorough in retrospect but slow in the moment. The team has good data and slow judgment.</p><p>What changes when more people can ask their own questions — marketing leads, product managers, sales operators — is that the feedback loop between action and evaluation shortens. GA4 data routed through BigQuery and surfaced via natural language queries gives teams that structure without requiring every member to become a data practitioner.</p><h3>From Monitoring to Investigation</h3><p>GA4’s standard reporting is well-suited to what it was designed for: tracking defined metrics over time. But the questions that drive decisions — why did this campaign perform differently? which behaviors indicate intent? — require a different kind of access to the same data.</p><p>The combination of event-level BigQuery export and a natural language interface brings those questions within reach for the full team, not just the members who write SQL. That’s the case for this architecture, and it’s what we built Squadbase to support.</p><p>Originally published at the blog below.</p><p><a href="https://www.squadbase.dev/en/blog/when-ga4-analytics-hits-its-limits-connect-bigquery-to-go-from-just-looking?utm_source=medium&amp;utm_medium=social">When GA4 Analytics Hits Its Limits - Connect BigQuery to Go from &quot;Just Looking&quot; to &quot;Actionable Data&quot; | Squadbase Blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ad21aba1827" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/why-your-ga4-reports-feel-useful-but-dont-help-you-decide-anything-2ad21aba1827">Why Your GA4 Reports Feel Useful But Don’t Help You Decide Anything</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Ways to Securely Share Your Next.js AI App Within Your Organization]]></title>
            <link>https://medium.com/morph-tech-blog/4-ways-to-securely-share-your-next-js-ai-app-within-your-organization-f59b3afa8072?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/f59b3afa8072</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Keita Mitsuhashi]]></dc:creator>
            <pubDate>Thu, 22 May 2025 06:17:53 GMT</pubDate>
            <atom:updated>2025-05-22T06:21:02.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xuihreu08VC1JSsUQJ0WCw.jpeg" /></figure><p>This article summarizes the key points of “<a href="https://www.squadbase.dev/en/blog/4-user-authentication-approaches-for-delivering-nextjs-ai-apps-inside-your-organization">4 Ways to Implement User Authentication for Sharing Next.js AI Apps Privately Within Your Organization</a>”. If you’d like full code samples and a deeper trade-off analysis, be sure to check out the complete version:</p><p><a href="https://www.squadbase.dev/en/blog/4-user-authentication-approaches-for-delivering-nextjs-ai-apps-inside-your-organization">https://www.squadbase.dev/en/blog/4-user-authentication-approaches-for-delivering-nextjs-ai-apps-inside-your-organization</a></p><h3>Four Authentication Methods for Sharing Next.js AI Apps Privately</h3><p>With the arrival of the Vercel AI SDK, Next.js has become a leading framework for building AI applications. However, if you want to share your Next.js–based AI app only within your organization, you need a proper user authentication layer. Below is a concise comparison of four implementation patterns that minimize development effort.</p><h3>Three Essentials for Organization-Scoped Authentication</h3><p><strong>Sign-up Restriction</strong><br> Prevent unauthorized sign-ups even if the URL leaks by allowing only invited users to register — or by disabling self-service sign-up entirely.</p><p><strong>Role Management</strong><br>When running multiple apps concurrently, you need a system that grants each user different permissions per app.</p><p><strong>Log Collection &amp; Monitoring</strong><br>For data governance, it’s important to link auth data with access and error logs so you can trace who did what.</p><h3>1. <a href="https://squadbase.dev/ja">Squadbase</a></h3><p><strong>Features</strong>: Built-in invite-only auth, role management, and analytics.</p><p><strong>Pros</strong>: Zero code changes — just deploy. CI/CD integration automatically handles secure deployments.</p><p><strong>Cons</strong>: You depend on Squadbase hosting.</p><h3>2. Clerk</h3><p><strong>Features</strong>: Rich Next.js UI components, invite-only sign-up, and SSO configurable from the dashboard.</p><p><strong>Pros</strong>: Add a modern login experience in just a few lines of code.</p><p><strong>Cons</strong>: Organization-level role management costs $25+/month; switching roles across multiple apps requires extra work.</p><h3>3. Auth0</h3><p><strong>Features</strong>: Enterprise-grade auth with OAuth, SAML, Okta integration, and more.</p><p><strong>Pros</strong>: Fine-grained roles and audit logging out of the box.</p><p><strong>Cons</strong>: Higher learning curve; invitation flows and per-app scoping add complexity.</p><h3>4. IP Whitelisting (Middleware)</h3><p><strong>Features</strong>: Restrict access by IP range instead of individual users.</p><p><strong>Pros</strong>: Extremely simple to implement.</p><p><strong>Cons</strong>: No user tracking or role management — only suitable for minimal access controls (e.g., office LAN).</p><p>For detailed code examples, setup instructions, and a full trade-off discussion, visit the complete article:</p><p><a href="https://www.squadbase.dev/en/blog/4-user-authentication-approaches-for-delivering-nextjs-ai-apps-inside-your-organization">https://www.squadbase.dev/en/blog/4-user-authentication-approaches-for-delivering-nextjs-ai-apps-inside-your-organization</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f59b3afa8072" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/4-ways-to-securely-share-your-next-js-ai-app-within-your-organization-f59b3afa8072">4 Ways to Securely Share Your Next.js AI App Within Your Organization</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Guide — Adding User Authentication to Your Streamlit App]]></title>
            <link>https://medium.com/morph-tech-blog/quick-guide-adding-user-authentication-to-your-streamlit-app-ce17978d04a8?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/ce17978d04a8</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[streamlit]]></category>
            <dc:creator><![CDATA[Keita Mitsuhashi]]></dc:creator>
            <pubDate>Thu, 08 May 2025 09:04:26 GMT</pubDate>
            <atom:updated>2025-05-08T09:04:25.999Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quick Guide — Adding User Authentication to Your Streamlit App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtWnMwwAN8PFvrPUc4Mkaw.png" /></figure><p>This post is a condensed summary of my full article “<a href="https://www.squadbase.dev/en/blog/3-ways-to-implement-user-authentication-with-streamlit">3 Ways to Implement User Authentication with Streamlit.</a>” If you want the code samples and a deeper trade-off analysis, head over to the complete piece.</p><p><a href="https://www.squadbase.dev/en/blog/3-ways-to-implement-user-authentication-with-streamlit">https://www.squadbase.dev/en/blog/3-ways-to-implement-user-authentication-with-streamlit</a></p><p><a href="https://streamlit.io/">Streamlit</a> makes it almost absurdly easy to turn a Python script into a living web application, but unless your tool is a one-off demo, you <strong>need to know who’s using it</strong>. Below is a whistle-stop tour of the three approaches to authentication, distilled from a longer piece I just published. Use it to pick the right path, then head over to the full article for hands-on code and deeper trade-offs.</p><h3>1. Open ID Connect (OIDC)</h3><h4><strong>What it is</strong></h4><p>The protocol Streamlit now supports natively (≥ v1.32). Login is delegated to any OIDC-compliant identity provider — Google Identity, Auth0, Azure AD, Okta, Keycloak…</p><h4><strong>Why do teams like it</strong></h4><p>You reuse a single sign-on (SSO) system your company already trusts, so passwords stay out of your codebase.</p><h4><strong>Snags</strong></h4><ul><li>No IdP, no party — you must provision one and wire up every new app.</li><li>Role metadata, SAML bridges, multi-tenant rules, etc., vary wildly by IdP, so feature parity across projects is hard.</li></ul><h3>2. Streamlit Authenticator</h3><h4><strong>What it is</strong></h4><p>A community package that bakes username-and-password login directly into your Streamlit code with a handful of lines and a YAML file.</p><h4><strong>Why do teams like it</strong></h4><p>Zero external services; perfect for hack days or proof-of-concepts that won’t hit the public internet.</p><h4><strong>Snags</strong></h4><ul><li>No SSO, no social logins, no SAML.</li><li>You must roll your own “forgot-password” flows, profile edits, audit logs… and redeploy for every user change.</li><li>That innocuous YAML turns into a bookkeeping nightmare once you pass a dozen users.</li></ul><h3>3. Squadbase</h3><h4><strong>What it is</strong></h4><p><a href="https://squadbase.dev/">Squadbase</a> is a deployment platform built for <em>internal</em> AI and data apps (Streamlit, Next.js, even Ollama). Connect a Git repo; Squadbase builds, hosts, and guards the URL behind its own auth layer.</p><h4><strong>Why do teams like it</strong></h4><ul><li>Authentication and SSO <strong>out of the box</strong>, no code changes.</li><li>Project-level roles you can query via SDK — neatly separated from “who can deploy” platform roles.</li><li>Automatic runtime logs and per-user analytics in one dashboard, so ops and product folks speak the same language.</li></ul><h4><strong>Snags</strong></h4><p>It’s an external platform, so you’ll evaluate it the same way you would Vercel or Netlify — pricing, region coverage, vendor fit, the usual diligence.</p><h3>Decision Cheat-Sheet</h3><ul><li>Org already runs Okta / Azure AD etc., and you only need <em>basic</em> gating → <strong>OIDC</strong></li><li>Hackathon, internal demo, or “let’s-just-ship-it” prototype → <strong>Streamlit Authenticator</strong></li><li>Multiple internal apps, role-based logic, need logs &amp; analytics, minimal DevOps → <a href="https://squadbase.dev/"><strong>Squadbase</strong></a></li></ul><h3>One More Step — Deep Dive &amp; Copy-Paste Code</h3><p>This is just the appetizer. The full article walks through:</p><ul><li>Copy-ready code snippets for OIDC <strong>and</strong> Streamlit Authenticator</li><li>Environment-variable tricks for portable deployments</li><li>A look at how Squadbase wires up project roles and analytics under the hood</li><li>A pros/cons matrix to help you defend the decision to your security team</li></ul><p>👉 <strong>Read the complete guide here</strong>: <a href="https://www.squadbase.dev/en/blog/3-ways-to-implement-user-authentication-with-streamlit">3 ways to implement user authentication with Streamlit</a></p><p>Feel free to drop questions or war stories in the comments — happy building!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce17978d04a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/quick-guide-adding-user-authentication-to-your-streamlit-app-ce17978d04a8">Quick Guide — Adding User Authentication to Your Streamlit App</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a Internal Data App with Google Sheets Backend Using Streamlit]]></title>
            <link>https://medium.com/morph-tech-blog/how-to-build-a-internal-data-app-with-google-sheets-backend-using-streamlit-ee8c0157aad0?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/ee8c0157aad0</guid>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[streamlit-app-deployment]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Hayato Onodera]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 07:21:19 GMT</pubDate>
            <atom:updated>2025-05-11T19:20:58.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRNcr7TGCHVYXNGfHR2uRw.jpeg" /></figure><blockquote>In this article, we’ll walk you through the process of building an internal-use data app using Streamlit with a spreadsheet as the backend. We’ll also explore scenarios where Streamlit is a particularly good fit.</blockquote><p>In our <strong>previous article</strong>, we introduced several ways to build data apps using spreadsheets as the backend.</p><p>This time, we’ll dive deeper into one of the code-based frameworks we mentioned — <strong>Streamlit</strong> — and explain how to build a data app that’s suitable for internal operations.</p><p>You can check out the previous article here:<a href="https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152">https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152</a></p><h3>Step-by-Step Guide</h3><h3>Google Cloud / Google Sheets Configuration</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FU0I00Ycqcbc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU0I00Ycqcbc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FU0I00Ycqcbc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c5983a6f7d6c27932195ace2facb618/href">https://medium.com/media/3c5983a6f7d6c27932195ace2facb618/href</a></iframe><p><strong>1. Enable the Google Sheets API</strong>Log in to the Google Developers Console, create a new project, and enable the Google Sheets API.</p><p><strong>2. Generate a Service Account and Download the JSON Key</strong>Go to APIs &amp; Services &gt; Credentials and create a new service account.Under the Keys tab of the service account, create a new key and download it in JSON format.</p><p><strong>3. Grant Access to the Service Account on the Target Spreadsheet</strong>Click the Share button on the Google Spreadsheet and add the service account. This allows the service account to access the spreadsheet data.</p><h3>Setting Up and Building with Streamlit</h3><p>In this section, we’ll build a Streamlit app using the directory structure shown below.</p><pre>project-name/<br>│<br>├── app.py               <br>└── service_key.json    </pre><ol><li>Move to your project directory and install the Streamlit framework.</li></ol><pre>cd project-name<br>pip install streamlit</pre><p>2. Place the JSON file you obtained in Step-by-Step Guide<em> 2</em> as service_key.json.</p><p>3. Write your code in app.py to build the Streamlit application.</p><pre>import streamlit as st<br>from google.oauth2 import service_account<br>import gspread<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>from datetime import datetime<br><br><br># Add a title to the app<br>st.title(&#39;Dashboard&#39;)<br><br># Google Sheets Authentication<br>scopes = [ &#39;https://www.googleapis.com/auth/spreadsheets&#39;, &#39;https://www.googleapis.com/auth/drive&#39;<br>]<br>credentials = service_account.Credentials.from_service_account_file( &quot;./service_key.json&quot;, scopes=scopes<br>)<br>gc = gspread.authorize(credentials)<br><br># Get data from Google Sheets<br>SP_SHEET_KEY = &#39;{Sheet ID}&#39; # sheet id (which can be found in the URL of the Google Sheet, after https://docs.google.com/spreadsheets/d/)<br>sh = gc.open_by_key(SP_SHEET_KEY)<br>SP_SHEET = &#39;test&#39; # Sheet name<br>worksheet = sh.worksheet(SP_SHEET)<br>data = worksheet.get_all_values() # Get all data from the sheet<br>df = pd.DataFrame(data[1:], columns=data[0]) # Convert data to DataFrame<br><br># Display original DataFrame (limited to 100 rows with scrolling)<br>st.subheader(&#39;Original Data&#39;)<br>st.dataframe(df.head(100), height=400)  # height parameter adds scrolling capability<br><br># Check if &#39;Created Date&#39; column exists<br>if &#39;Created Date&#39; in df.columns:<br>    # Convert to datetime format (adjust format as needed)<br>    df[&#39;Created Date&#39;] = pd.to_datetime(df[&#39;Created Date&#39;])<br>    <br>    # Group by date and count records<br>    count_by_date = df.groupby(df[&#39;Created Date&#39;].dt.date).size().reset_index()<br>    count_by_date.columns = [&#39;Created Date&#39;, &#39;Count&#39;]<br>    <br>    # Sort by Created Date in descending order<br>    count_by_date = count_by_date.sort_values(&#39;Created Date&#39;, ascending=False)<br>    <br>    # Create two columns for side-by-side display<br>    st.subheader(&#39;Record Count by Date&#39;)<br>    col1, col2 = st.columns([3, 2])  # Adjust the ratio to make the first column wider<br>    <br>    # Display grouped DataFrame in the first column<br>    with col1:<br>        st.dataframe(count_by_date.head(100), height=400)<br>    <br>    # Create line chart in the second column<br>    with col2:<br>        # For the chart, we need to sort by date in ascending order<br>        chart_data = count_by_date.sort_values(&#39;Created Date&#39;, ascending=True)<br>        st.line_chart(chart_data.set_index(&#39;Created Date&#39;))<br>else:<br>    st.error(&quot;&#39;Created Date&#39; column not found in the DataFrame. Please check the column name.&quot;)<br>    st.write(&quot;Available columns:&quot;, df.columns.tolist())</pre><p>4. Open the app in your browser to verify that it works.</p><pre>streamlit run app.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTMolx8VHx96ULsPy5jbIg.png" /></figure><h3>Adding Authentication for Internal Use</h3><p>When running Streamlit apps internally, authentication becomes essential.</p><p>Here, we’ll cover <strong>three methods</strong> for implementing authentication.</p><p>If you’re only deploying a single app, the first method might be sufficient.</p><p>However, if you have multiple apps or plan to scale in the future, we recommend using either the second or third approach.</p><h3>1. Add Authentication to Each App Individually</h3><p>As of version 1.42.0, Streamlit supports <strong>OpenID Connect (OIDC)</strong> for user authentication.You can use this built-in feature to add flexible authentication to your app.</p><ul><li><strong>Pros</strong>: Highly flexible authentication</li><li><strong>Cons</strong>: Requires implementation for each app, which increases development effort</li></ul><p>Official documentation: <a href="https://docs.streamlit.io/develop/concepts/connections/authentication">https://docs.streamlit.io/develop/concepts/connections/authentication</a></p><h3>2. Use Snowflake in Streamlit</h3><p>Snowflake in Streamlit allows you to build and host Streamlit apps directly on the Snowflake platform.Since authentication to Snowflake also applies to your Streamlit app, no additional authentication implementation is required.</p><ul><li><strong>Pros</strong>: No need to implement authentication individually for each app</li><li><strong>Cons</strong>: Requires a Snowflake account / Limited to fewer components compared to open-source Streamlit</li></ul><p>Official documentation: <a href="https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit">https://docs.snowflake.com/en/developer-guide/streamlit/about-streamlit</a></p><h3>3. Use Squadbase</h3><p>Squadbase is a cloud platform that supports Streamlit deployment.By deploying your Streamlit app to Squadbase, you can leverage Squadbase<strong> built-in authentication</strong>, eliminating the need to implement it manually.</p><ul><li><strong>Pros</strong>: No need for individual authentication implementation / Centralized app management</li><li><strong>Cons</strong>: Involves using an external service (Squadbase)</li></ul><p>Official documentation: <a href="https://www.squadbase.dev/en">https://www.squadbase.dev/en</a></p><h3>Conclusion</h3><p>Streamlit is a great tool for data scientists and analysts who are comfortable with Python and want to build data applications powered by machine learning or AI.</p><p>It’s especially well-suited for internal tools like:</p><ul><li>Workflow automation apps using LLMs</li><li>Demand forecasting tools</li><li>Internal chatbots that reference company documents</li></ul><p>There are endless ways to apply Streamlit — so we encourage you to give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee8c0157aad0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/how-to-build-a-internal-data-app-with-google-sheets-backend-using-streamlit-ee8c0157aad0">How to Build a Internal Data App with Google Sheets Backend Using Streamlit</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: Deploying a User-Authenticated Streamlit App in Just 5 Minutes.]]></title>
            <link>https://medium.com/morph-tech-blog/tutorial-deploying-a-user-authenticated-streamlit-app-in-just-5-minutes-f9d2a81b9a50?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/f9d2a81b9a50</guid>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[morph]]></category>
            <category><![CDATA[streamlit-app-deployment]]></category>
            <dc:creator><![CDATA[Naoto Shibata]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 09:04:04 GMT</pubDate>
            <atom:updated>2025-03-25T09:04:04.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pOdfrmJZPDhRtsQLFPeqcg.jpeg" /></figure><blockquote><em>This tutorial explains how to deploy a Streamlit data app to the cloud with user authentication using Morph. With this method, there’s no need for Docker builds typically required when deploying Streamlit apps to Cloud Run. This makes sharing apps within your team simpler and quicker.</em></blockquote><p>Morph is a cloud service designed to automatically deploy internal data and AI apps from your GitHub repository to the cloud, providing built-in user authentication for easy sharing.</p><p>Now that Morph supports Streamlit deployment, this tutorial will guide you through deploying a Streamlit application. Make sure you’ve logged in to morph-data.io beforehand.</p><p><a href="https://morph-data.io/">Morph - AI-powered Data Apps with Code</a></p><h3>TL;DR</h3><p>The sample code from this tutorial is available in the repository below:</p><p><a href="https://github.com/shibatanaoto/streamlit-morph-sample">GitHub - shibatanaoto/streamlit-morph-sample</a></p><p>Fork the above repository and follow the video tutorial linked below to deploy your Streamlit app to the cloud and share it with invited members:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FW4NEHIQqQbg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DW4NEHIQqQbg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FW4NEHIQqQbg%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/92967f85f4d67e652feaae3505c91eaf/href">https://medium.com/media/92967f85f4d67e652feaae3505c91eaf/href</a></iframe><h3>Preparation</h3><p>Install the necessary packages before starting:</p><pre>pip install streamlit pandas</pre><h3>Building a Simple Streamlit App</h3><p>As this tutorial focuses mainly on deployment, we’ll use a simple Streamlit app. First, create a file named <a href="http://main.py/">main.py</a>. (Do not change this filename.)</p><pre>import streamlit as st<br>import pandas as pd<br>import numpy as np<br><br>st.markdown(&quot;# Hello world!!!&quot;)<br>df: pd.DataFrame = pd.DataFrame(<br>    np.random.randn(30, 3),<br>    columns=[&quot;x&quot;, &quot;y&quot;, &quot;z&quot;]<br>)<br>st.line_chart(df)</pre><p>Run the app locally to check it.</p><pre>streamlit run main.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*FrJjqHwyK1KWOR3LOhoXwg.png" /></figure><h3>Configuring Morph Deployment</h3><p>Next, create a file named `morph_project.yml` in the same directory as <a href="http://main.py/">main.py</a>. Enter the following configuration, adjusting the runtime version according to your Python environment (supported versions are Python 3.9 to 3.12):</p><pre>version: &#39;1&#39;<br><br>build:<br>  framework: streamlit<br>  runtime: python3.12<br>deployment:<br>  provider: gcp</pre><p>Detailed documentation for morph_project.yml, including how to adjust CPU and memory based on your needs, can be found here:</p><p><a href="https://docs.morph-data.io/reference/en/framework/morph-project">morph_project.yml - Docs</a></p><p>After configuration, generate a requirements.txt file with your dependencies and push the changes to GitHub:</p><pre>pip freeze &gt; requirements.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gWdTJPCDa3Yua76c9AXVg.png" /></figure><h3>Deploying to Morph</h3><p>Log in to <a href="https://morph-data.io/">https://morph-data.io</a>, click the “+Create” button on the homepage, connect your GitHub repository, and select the repository and branch. Deployment starts automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksZNZbpatCleXzOh0Y_hIw.png" /></figure><p>On the homepage, you’ll see a list of your created apps. Select the app with the same name as your repository. Under the “Deployments” tab, you can view the build status. Once it shows “Ready,” the deployment is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FV3gok_WktGMCn6HDpx08g.png" /></figure><p>Click the “Open” button to view the deployed app. There might be a slight cold start delay initially, but you should see your application successfully loaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AEuMSbMAgJuY-TkPxp5yRg.png" /></figure><p>The deployed app has built-in user authentication, meaning only members invited via the “Member Access” dashboard can access it.</p><p>To invite members, use the following screen. You can invite 5 members in Free plan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdG5aoHb-uzTPqhBuD2wPw.png" /></figure><p>Morph simplifies deploying Streamlit apps to the cloud and securely sharing them with your team.</p><p>Morph is also expanding support for full-stack frameworks like Next.js and HonoX. If you have requests for additional frameworks, feel free to reach out 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9d2a81b9a50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/tutorial-deploying-a-user-authenticated-streamlit-app-in-just-5-minutes-f9d2a81b9a50">Tutorial: Deploying a User-Authenticated Streamlit App in Just 5 Minutes.</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Notion Data “AI Ready” by Transferring it to Pinecone with Trigger.dev]]></title>
            <link>https://medium.com/morph-tech-blog/making-notion-data-ai-ready-by-transferring-it-to-pinecone-with-trigger-dev-607369d63f63?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/607369d63f63</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[notion]]></category>
            <category><![CDATA[pinecone]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Keita Mitsuhashi]]></dc:creator>
            <pubDate>Thu, 20 Mar 2025 02:12:41 GMT</pubDate>
            <atom:updated>2025-05-21T05:06:29.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31iUFesqzxku0DQuN85grg.jpeg" /></figure><p>Hi, I’m Keita, a front-end developer at <a href="https://squadbase.dev/">Squadbase</a>.</p><p>When developing products, there are often moments when you wonder, “Why is this feature specified this way?” or “This customer is saying something, but I feel like we’ve seen a similar ticket before.” It was in those moments that I thought: <em>I want to perform semantic searches on our project management tool data!</em></p><p>In this article, as the first step, I will explain how to transfer data into Pinecone — a vector database — in order to vectorize its content and prepare it for integration with AI. I use Trigger.dev for the data transfer.</p><h3>What is <a href="https://www.pinecone.io/">Pinecone</a>?</h3><p><a href="https://www.pinecone.io/">The vector database to build knowledgeable AI | Pinecone</a></p><p>Pinecone is a fully managed vector database that efficiently stores and retrieves high-dimensional embedding vectors generated by machine learning models. With approximate nearest neighbor search algorithms like HNSW, it enables fast semantic search even on large-scale datasets. The API makes it easy to upsert data or run queries, and it can be used just like a typical NoSQL database. By vectorizing the data, you can perform searches based on similarity in semantic space rather than simple string matching, making it a great fit for AI integration.</p><p>Similar tools include Weaviate and Chroma.</p><h3>What is <a href="https://trigger.dev/">Trigger.dev</a>?</h3><p><a href="https://trigger.dev/">https://trigger.dev/</a></p><p>Trigger.dev is an event-driven workflow automation platform. It allows you to write background tasks in TypeScript and provides a smooth development experience through a combination of CLI and web dashboard tools. It supports triggering tasks via webhooks or scheduled execution with cron expressions.</p><h3>Initializing the Project</h3><p>Start by initializing your project with the Trigger.dev CLI. You will be prompted to log in, so be sure to sign up and create your project beforehand.</p><p>For this example, I selected the <strong>Scheduled Task</strong> template.</p><pre>npx trigger.dev@latest init</pre><p>Once the initialization is complete, you’ll see files like the following:</p><pre>// src/trigger/example.ts<br>import { logger, schedules, wait } from &quot;@trigger.dev/sdk/v3&quot;;<br><br>export const firstScheduledTask = schedules.task({<br>  id: &quot;first-scheduled-task&quot;,<br>  // Every hour<br>  cron: &quot;0 * * * *&quot;,<br>  // Set an optional maxDuration to prevent tasks from running indefinitely<br>  maxDuration: 300, // Stop executing after 300 secs (5 mins) of compute<br>  run: async (payload, { ctx }) =&gt; {<br>    // The payload contains the last run timestamp that you can use to check if this is the first run<br>    // And calculate the time since the last run<br>    const distanceInMs =<br>      payload.timestamp.getTime() - (payload.lastTimestamp ?? new Date()).getTime();<br>    logger.log(&quot;First scheduled tasks&quot;, { payload, distanceInMs });<br>    // Wait for 5 seconds<br>    await wait.for({ seconds: 5 });<br>    // Format the timestamp using the timezone from the payload<br>    const formatted = payload.timestamp.toLocaleString(&quot;en-US&quot;, {<br>      timeZone: payload.timezone,<br>    });<br>    logger.log(formatted);<br>  },<br>});</pre><h3>Fetching Data from Notion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cf6OFaHTh8GIT0XnK1ItQ.png" /></figure><p>To integrate with Notion, use the <a href="https://github.com/makenotion/notion-sdk-js">@notionhq/client</a>. With Notion’s Integration, you can implement data integration — please refer to the <a href="https://developers.notion.com/docs/create-a-notion-integration">guide</a> to create your integration and grant access to the target database.</p><p>Since the Notion API response is in the rich text AST format, I use the <a href="https://github.com/souvikinator/notion-to-md">notion-to-md</a> package to convert it into Markdown format.</p><p>The following code shows how to query the database and obtain each page’s content in Markdown. Make sure to specify your NOTION_API_KEY and NOTION_DATABASE_ID in your .env file.</p><pre>// src/fetch-notion.ts<br><br>import { isFullPage, Client as NotionClient } from &quot;@notionhq/client&quot;;<br>import { NotionConverter } from &quot;notion-to-md&quot;;<br>import { MDXRenderer } from &quot;notion-to-md/plugins/renderer&quot;;<br>import { DefaultExporter } from &quot;notion-to-md/plugins/exporter&quot;;<br>import { PageObjectResponse } from &quot;@notionhq/client/build/src/api-endpoints&quot;;<br>const notion = new NotionClient({<br>  auth: process.env.NOTION_API_KEY,<br>});<br>const buffer: Record&lt;string, string&gt; = {};<br>const n2m = new NotionConverter(notion)<br>  .withRenderer(new MDXRenderer())<br>  .withExporter(<br>    new DefaultExporter({<br>      outputType: &quot;buffer&quot;,<br>      buffer: buffer,<br>    })<br>  );<br>  <br>export async function fetchNotion() {<br>  const databaseId = process.env.NOTION_DATABASE_ID!;<br>  const notionResponse = await notion.databases.query({<br>    database_id: databaseId,<br>  });<br>  const pages = notionResponse.results;<br>  const results: (Record&lt;string, string&gt; &amp; { text: string })[] = [];<br>  for (const page of pages) {<br>    // Check if the page is a full page object<br>    if (!isFullPage(page)) {<br>      continue;<br>    }<br>    await n2m.convert(page.id);<br>    const bodyString = buffer[page.id];<br>    <br>    console.log(bodyString);<br> }<br>}</pre><h3>Formatting Notion Data</h3><ul><li>In this app, a batch process is executed every hour, and only data that was updated within that hour is transferred to Pinecone. Adjust the query conditions for the database accordingly.</li><li>While Pinecone can store numbers and strings, it cannot store objects or null values. Therefore, the data must be formatted.</li></ul><p>Taking these two points into account, the fetchNotion function becomes as follows:</p><pre>import { isFullPage, Client as NotionClient } from &quot;@notionhq/client&quot;;<br>import { NotionConverter } from &quot;notion-to-md&quot;;<br>import { MDXRenderer } from &quot;notion-to-md/plugins/renderer&quot;;<br>import { DefaultExporter } from &quot;notion-to-md/plugins/exporter&quot;;<br>import { PageObjectResponse } from &quot;@notionhq/client/build/src/api-endpoints&quot;;<br><br>const notion = new NotionClient({<br>  auth: process.env.NOTION_API_KEY,<br>});<br>const buffer: Record&lt;string, string&gt; = {};<br>const n2m = new NotionConverter(notion)<br>  .withRenderer(new MDXRenderer())<br>  .withExporter(<br>    new DefaultExporter({<br>      outputType: &quot;buffer&quot;,<br>      buffer: buffer,<br>    })<br>  );<br><br>// turn notion propeties into plain text<br>function extractPlainText(<br>  property: PageObjectResponse[&quot;properties&quot;][string]<br>): string {<br>  // Return an empty string if the property or its type is missing<br>  if (!property || !property.type) return &quot;&quot;;<br>  switch (property.type) {<br>    // For title and rich_text, concatenate the plain_text from each item<br>    case &quot;title&quot;:<br>    case &quot;rich_text&quot;: {<br>      const content =<br>        property.type === &quot;title&quot; ? property.title : property.rich_text;<br>      if (Array.isArray(content)) {<br>        return content.map((item) =&gt; item.plain_text).join(&quot;&quot;);<br>      }<br>      return &quot;&quot;;<br>    }<br>    // For select and status, return the name of the selected option<br>    case &quot;select&quot;:<br>      return property.select ? property.select.name : &quot;&quot;;<br>    case &quot;status&quot;:<br>      return property.status ? property.status.name : &quot;&quot;;<br>    // For date, return the start date<br>    case &quot;date&quot;:<br>      return property.date ? property.date.start : &quot;&quot;;<br>    // For created_by, return the creator&#39;s name if available<br>    case &quot;created_by&quot;:<br>      if (property.created_by &amp;&amp; &quot;name&quot; in property.created_by) {<br>        return property.created_by.name || &quot;&quot;;<br>      }<br>      break;<br>    // For people, return a comma-separated list of user names<br>    case &quot;people&quot;:<br>      if (Array.isArray(property.people) &amp;&amp; property.people.length &gt; 0) {<br>        return property.people.map((person: any) =&gt; person.name).join(&quot;, &quot;);<br>      }<br>      break;<br>    // For relation, return a comma-separated list of relation ids (or empty string if missing)<br>    case &quot;relation&quot;:<br>      if (Array.isArray(property.relation) &amp;&amp; property.relation.length &gt; 0) {<br>        return property.relation.map((rel: any) =&gt; rel.id || &quot;&quot;).join(&quot;, &quot;);<br>      }<br>      break;<br>    default:<br>      break;<br>  }<br>  // Return an empty string if no valid value is found<br>  return &quot;&quot;;<br>}<br>export async function fetchNotion() {<br>  const databaseId = process.env.NOTION_DATABASE_ID!;<br>  const one_hour_ago = new Date(Date.now() - 60 * 60 * 1000).toISOString();<br>  const notionResponse = await notion.databases.query({<br>    database_id: databaseId,<br>    filter: {<br>      and: [<br>        {<br>          last_edited_time: {<br>            after: one_hour_ago,<br>          },<br>          timestamp: &quot;last_edited_time&quot;,<br>        },<br>      ],<br>    },<br>  });<br>  const pages = notionResponse.results;<br>  const results: (Record&lt;string, string&gt; &amp; { text: string })[] = [];<br>  for (const page of pages) {<br>    // Check if the page is a full page object<br>    if (!isFullPage(page)) {<br>      continue;<br>    }<br>    await n2m.convert(page.id);<br>    const bodyString = buffer[page.id];<br>    results.push({<br>      _id: page.id,<br>      created_time: page.created_time,<br>      last_edited_time: page.last_edited_time,<br>      ...Object.keys(page.properties).reduce((acc, key) =&gt; {<br>        acc[key] = extractPlainText(page.properties[key]);<br>        return acc;<br>      }, {} as Record&lt;string, string&gt;),<br>      text: bodyString,<br>    });<br>  }<br>  return results;<br>}</pre><h3>Transferring Data to Pinecone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0t0V-P4ZOOfZG43lMylNA.png" /></figure><p>Now for the final step: transferring the data to Pinecone. After signing up for Pinecone and obtaining an API key, add it to your .env file. Also, initialize your index. Choose an embedding model and cloud provider that best suits your needs.</p><p>In this example, I use the Integrated embedding. The fields specified here will serve as the targets for semantic search.</p><p>Once everything is set up, edit your Trigger.dev code as follows. It’s very simple — make sure to set PINECONE_API_KEY and PINECONE_INDEX_NAME in your .env file.</p><pre>import { logger, schedules } from &quot;@trigger.dev/sdk/v3&quot;;<br>import { Pinecone } from &quot;@pinecone-database/pinecone&quot;;<br>import { fetchNotion } from &quot;../fetch-notion&quot;;<br><br>const pc = new Pinecone({<br>  apiKey: process.env.PINECONE_API_KEY!,<br>});<br>const index = pc.index(process.env.PINECONE_INDEX_NAME!);<br>export const notionToPineconeTask = schedules.task({<br>  id: &quot;notion-to-pinecone-batch&quot;,<br>  cron: &quot;0 * * * *&quot;,<br>  maxDuration: 300,<br>  run: async (payload, { ctx }) =&gt; {<br>    logger.log(&quot;Trigger task started&quot;, { payload });<br>    const pages = await fetchNotion();<br>    await index.namespace(&quot;ns1&quot;).upsertRecords(pages);<br>    logger.log(&quot;Notion to Pinecone transfer completed&quot;);<br>  },<br>});</pre><h3>Testing and Deployment</h3><p>Test your script using a combination of the Trigger.dev CLI and the web dashboard. Run the following command and then log in to the Trigger.dev dashboard:</p><pre>npx trigger.dev@latest dev</pre><p>Also, be sure to set your environment variables within the Trigger.dev dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VORGsTgOxoSxiVsEGPXquQ.png" /></figure><p>From the <strong>Test</strong> tab, select the task you created and click <strong>Run Test</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P208guIluPn8zppARHDDTw.png" /></figure><p>This completes the Notion → Pinecone transfer script! 🎉</p><h3>Final thoughts</h3><p>I originally wanted to try Trigger.dev while building an in-house application, and it turned out to be far more comfortable than I had expected. I particularly appreciated that even cron tasks can be easily tested from the dashboard. That said, if this were a customer-facing feature, you would likely write dedicated test scripts to ensure quality — so I view the Trigger.dev test functionality as a development aid rather than a full testing solution. Overall, I believe it’s perfect for batch processing in internal applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=607369d63f63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/making-notion-data-ai-ready-by-transferring-it-to-pinecone-with-trigger-dev-607369d63f63">Making Notion Data “AI Ready” by Transferring it to Pinecone with Trigger.dev</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a Data App with Google Sheets Backend Using Evidence]]></title>
            <link>https://medium.com/morph-tech-blog/how-to-build-a-data-app-with-google-sheets-backend-using-evidence-38e00f938365?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/38e00f938365</guid>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[evidence]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[dashboard]]></category>
            <dc:creator><![CDATA[Hayato Onodera]]></dc:creator>
            <pubDate>Tue, 18 Mar 2025 12:09:12 GMT</pubDate>
            <atom:updated>2025-03-18T12:08:52.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ln7_GGe3qLJM6lN5W1tKVA.jpeg" /></figure><blockquote>In this article, we will introduce the process of building a data app with a spreadsheet backend using Evidence. We will also explore the use cases where Evidence is particularly well-suited.</blockquote><p>In the previous article, we introduced multiple methods for building a data app with a spreadsheet backend. This time, we will focus on one of the code-based frameworks mentioned earlier, Evidence, providing a detailed introduction and step-by-step guide.</p><p>Here is the previous article:<a href="https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152">https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152</a></p><h3>What is Evidence?</h3><p>Evidence is an open-source framework primarily built on SvelteKit, a JavaScript framework. It requires a Node.js environment to operate.</p><p>One of the key features of Evidence is that it allows users to build dashboard-like data applications using SQL and Markdown syntax. Unlike traditional BI tools, which require complex GUI operations, Evidence enables users to create and manage interactive dashboards entirely in a code-based manner.</p><h3>Step-by-Step Guide</h3><h3>Google Cloud / Google Sheets Configuration</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FU0I00Ycqcbc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU0I00Ycqcbc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FU0I00Ycqcbc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c5983a6f7d6c27932195ace2facb618/href">https://medium.com/media/3c5983a6f7d6c27932195ace2facb618/href</a></iframe><p><strong>1. Enable the Google Sheets API<br></strong>Log in to the Google Developers Console, create a new project, and enable the Google Sheets API.</p><p><strong>2. Generate a Service Account and Download the JSON Key<br></strong>Go to APIs &amp; Services &gt; Credentials and create a new service account.<br>Under the Keys tab of the service account, create a new key and download it in JSON format.</p><p><strong>3. Grant Access to the Service Account on the Target Spreadsheet<br></strong>Click the Share button on the Google Spreadsheet and add the service account. This allows the service account to access the spreadsheet data.</p><h3>Setting Up and Configuring Evidence</h3><ol><li>Install the Evidence framework and start the development server.</li></ol><pre>npx degit evidence-dev/template project-name<br>cd project-name<br>npm install<br>npm run sources<br>npm run dev</pre><p>2. Install the Google Sheets plugin by running:</p><pre>npm install @evidence-dev/connector-gsheets</pre><p>3. After installation, add the following to the end of evidence.config.yaml:</p><pre>&quot;@evidence-dev/connector-gsheets&quot;: { }</pre><p>4. Run npm run dev to launch the Evidence page in the browser. Click on the &quot;...&quot; at the top and navigate to the Settings page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6L2gKtzXGvehW9VN1V5EQ.png" /></figure><p>5. Click +New Sources. Select gsheets as the Source Type, enter a directory name, and click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYQ8vxfcve7XOq2cunhDyA.png" /></figure><p>6. Upload the JSON file obtained in step 2 of the Google Cloud / Google Sheets Configuration section by clicking Choose file. Once the upload is complete, click Test Configuration to verify the connection. If there are no issues, click Save to store the connection settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8i4NM-SKm4KUtJWUoVbDg.png" /></figure><p>7. Once the connection settings are saved, two files, connection.options.yml and connection.yml, will be generated in the directory created in step 5. Modify connection.yml as follows:</p><ul><li>your_workbook_name: The name of the Google Spreadsheet file</li><li>your_sheet_id: The Google Spreadsheet ID (the string after https://docs.google.com/spreadsheets/d/ in the URL)</li></ul><pre>name: [your_source_name]<br>type: gsheets<br>options: {}<br>sheets:<br>[your_workbook_name]: [your_sheet_id]</pre><p>8. Create a new file named spreadsheet.md under the pages directory to build the app.</p><pre>## Check data connection<br>```sql gsheets<br>select * from googlesheets.test_test<br>```<br><br>## Count group by date<br>```sql count_groupby_date<br>select &quot;Created Date&quot; as date , <br>        count(*) as count <br>from googlesheets.test_test<br>    group by &quot;Created Date&quot;<br>    order by &quot;Created Date&quot; DESC<br>```<br><br>## Dashboard<br>&lt;Grid cols=2&gt;<br>    &lt;DataTable data={count_groupby_date}/&gt;<br><br>    &lt;LineChart <br>        data = {count_groupby_date}    <br>        y = count <br>        title = &#39;chart&#39; <br>    /&gt;<br>&lt;/Grid&gt;</pre><p>9. Open the developed app in your browser to verify that everything is working correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGymVso9_PBnG2HlGBoVTw.png" /></figure><h3>Summary</h3><p>Evidence is ideal for <strong>data teams that primarily work with SQL and need to build data apps for analysis and reporting tasks</strong>.</p><p>Use cases where Evidence excels include KPI tracking, sharing business metrics (such as financial reports, sales performance dashboards, and marketing analytics reports), and <strong>creating regularly updated dashboards managed by data analyst teams</strong>.</p><p>Traditionally, data aggregation (using SQL) and visualization (using GUI-based BI tools or Python) were separate processes. However, with Evidence, dashboards can be created and managed entirely with SQL, making it a powerful tool for the right use cases.</p><p>We encourage you to give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38e00f938365" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/how-to-build-a-data-app-with-google-sheets-backend-using-evidence-38e00f938365">How to Build a Data App with Google Sheets Backend Using Evidence</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build an Internal Data Application Using Google Sheets as a Data Source]]></title>
            <link>https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/8970b8641152</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[evidence]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[spreadsheets]]></category>
            <dc:creator><![CDATA[Hayato Onodera]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 17:27:50 GMT</pubDate>
            <atom:updated>2025-03-13T17:31:45.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQ5R9Y7zcJmI5rKP7AW95Q.jpeg" /></figure><blockquote>This article introduces multiple approaches to building an internal data application using google sheets as the backend. In addition to summarizing the advantages and disadvantages of each approach, we will also discuss the differences from the perspective of AI functionality, which has been gaining increasing demand.</blockquote><p>Many teams manage their daily data using Google Sheets due to its high convenience. But when you decide to build a data application using google sheets as the backend, what are your options?</p><h3>Code-Based / Low-Code / No-Code</h3><p>The methods for building an internal data application can be categorized into three approaches: code-based development, low-code tools, and no-code tools. Below are the descriptions and representative tools for each approach.</p><h3>Code-Based</h3><p>This approach involves building a data application with code. While it requires coding, the frameworks introduced below provide pre-built components that enable rapid development. Additionally, since they are open-source, you can choose your deployment environment.</p><p><strong>[Representative Tools]</strong></p><ul><li>Streamlit: <a href="https://streamlit.io/">https://streamlit.io/</a></li><li>Evidence: <a href="https://evidence.dev/">https://evidence.dev/</a></li><li>Morph: <a href="https://www.morph-data.io/ja">https://www.morph-data.io/</a></li></ul><h3>Low-Code</h3><p>This approach combines coding and GUI-based development. For simple applications with minimal functionality/UI, it is possible to build using only the GUI, while some parts can be customized with code. Compared to no-code, low-code allows for more flexibility, but it still has limitations compared to full code-based development.</p><p><strong>[Representative Tools]</strong></p><ul><li>Appsmith: <a href="https://www.appsmith.com/">https://www.appsmith.com/</a></li><li>Retool: <a href="https://retool.com/">https://retool.com/</a></li><li>OutSystems：<a href="https://www.outsystems.com/?sc_lang=en">https://www.outsystems.com/?sc_lang=en</a></li></ul><h3>No-Code</h3><p>This approach allows users to build data applications entirely through GUI-based tools, making it accessible to non-engineers. However, it has significant limitations in terms of handling complex processing and UI customization. Additionally, the development skill is heavily dependent on familiarity with the specific tool, making knowledge transfer a challenge.</p><p><strong>[Representative Tools]</strong></p><ul><li>AppSheet: <a href="https://about.appsheet.com/home/">https://about.appsheet.com/home/</a></li><li>Glide: <a href="https://www.glideapps.com/">https://www.glideapps.com/</a></li><li>Softr: <a href="https://www.softr.io/">https://www.softr.io/</a></li></ul><h3>Compatibility with AI Features</h3><p>One of the most significant emerging needs is AI integration. Let’s examine how well each category supports AI functionality.</p><h3>Code-Based</h3><p>With a code-based approach, you can leverage open-source AI frameworks such as Langchain and CrewAI, allowing for the highest level of flexibility in AI development. This approach supports model switching, fine-tuning with custom datasets, and other advanced AI functionalities. Since internal business workflows vary widely between companies and often involve complex logic, this approach is <strong>the most recommended for building AI-powered applications tailored to your business needs</strong>.</p><h3>Low-Code</h3><p>In general, AI functionality in low-code platforms relies on pre-integrated external APIs. While parameters and prompts can be tuned, you cannot perform additional training with new datasets or freely select AI models. This makes low-code a suitable choice for single-task AI use cases but limits its flexibility. Therefore, the AI compatibility of low-code is considered <strong>moderate</strong>.</p><h3>No-Code</h3><p>With a no-code approach, you can only use the AI features provided by the platform. While these features are easy to use, they lack customization options, making them useful only for specific use cases. No-code is ideal for Proof of Concept (PoC) and quick experiments, but for building production-ready applications, <strong>AI compatibility is low</strong>.</p><h3>Comparison of Code-Based Frameworks</h3><p>Next, let’s focus on code-based frameworks and try building a simple application using google sheets as the backend. For this example, we will create a dashboard to manage user inquiry data stored in a spreadsheet.</p><h3>Streamlit</h3><p>First, we will build the application with Streamlit. Streamlit allows you to complete the development using a single Python file.</p><pre>import streamlit as st<br>from google.oauth2 import service_account<br>import gspread<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>from datetime import datetime<br># Add a title to the app<br>st.title(&#39;Dashboard&#39;)<br># Google Sheets Authentication<br>scopes = [ &#39;https://www.googleapis.com/auth/spreadsheets&#39;, &#39;https://www.googleapis.com/auth/drive&#39;<br>]<br>json_file_path = os.path.join(os.path.dirname(__file__), &quot;../credential.json&quot;)<br>credentials = service_account.Credentials.from_service_account_file(json_file_path, scopes=scopes)<br>gc = gspread.authorize(credentials)<br># Get data from Google Sheets<br>SP_SHEET_KEY = &#39;{Sheet ID}&#39; # sheet id (which can be found in the URL of the Google Sheet, after https://docs.google.com/spreadsheets/d/)<br>sh = gc.open_by_key(SP_SHEET_KEY)<br>SP_SHEET = &#39;test&#39; # Sheet name<br>worksheet = sh.worksheet(SP_SHEET)<br>data = worksheet.get_all_values() # Get all data from the sheet<br>df = pd.DataFrame(data[1:], columns=data[0]) # Convert data to DataFrame<br># Display original DataFrame (limited to 100 rows with scrolling)<br>st.subheader(&#39;Original Data&#39;)<br>st.dataframe(df.head(100), height=400) # height parameter adds scrolling capability<br># Check if &#39;Created Date&#39; column exists<br>if &#39;Created Date&#39; in df.columns:<br> # Convert to datetime format (adjust format as needed)<br> df[&#39;Created Date&#39;] = pd.to_datetime(df[&#39;Created Date&#39;])<br> <br> # Group by date and count records<br> count_by_date = df.groupby(df[&#39;Created Date&#39;].dt.date).size().reset_index()<br> count_by_date.columns = [&#39;Created Date&#39;, &#39;Count&#39;]<br> <br> # Sort by Created Date in descending order<br> count_by_date = count_by_date.sort_values(&#39;Created Date&#39;, ascending=False)<br> <br> # Create two columns for side-by-side display<br> st.subheader(&#39;Record Count by Date&#39;)<br> col1, col2 = st.columns([3, 2]) # Adjust the ratio to make the first column wider<br> <br> # Display grouped DataFrame in the first column<br> with col1:<br> st.dataframe(count_by_date.head(100), height=400)<br> <br> # Create line chart in the second column<br> with col2:<br> # For the chart, we need to sort by date in ascending order<br> chart_data = count_by_date.sort_values(&#39;Created Date&#39;, ascending=True)<br> st.line_chart(chart_data.set_index(&#39;Created Date&#39;))<br>else:<br> st.error(&quot;&#39;Created Date&#39; column not found in the DataFrame. Please check the column name.&quot;)<br> st.write(&quot;Available columns:&quot;, df.columns.tolist())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTMolx8VHx96ULsPy5jbIg.png" /></figure><h3>Evidence</h3><p>Next, let’s try Evidence. Evidence is built with the SvelteKit JavaScript framework, so you need a Node.js environment to use it.</p><pre>## Check data connection<br>```sql gsheets<br>select * from googlesheets.test_test<br>```<br><br>## Count group by date<br>```sql count_groupby_date<br>select &quot;Created Date&quot; as date , <br>        count(*) as count <br>from googlesheets.test_test<br>    group by &quot;Created Date&quot;<br>    order by &quot;Created Date&quot; DESC<br>```<br><br>## Dashboard<br>&lt;Grid cols=2&gt;<br>    &lt;DataTable data={count_groupby_date}/&gt;<br><br>    &lt;LineChart <br>        data = {count_groupby_date}    <br>        y = count <br>        title = &#39;chart&#39; <br>    /&gt;<br>&lt;/Grid&gt;</pre><p>The app will look like this. One nice touch is that the SQL source code is displayed alongside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGymVso9_PBnG2HlGBoVTw.png" /></figure><h3>Morph</h3><p>Finally, we will use the Morph framework. Morph is unique in that it allows you to structure your application using separate Python and Markdown files. Additionally, Python functions are written in a standard function format, making it easier to learn.</p><pre># Get spreadsheet data<br><br>import pandas as pd<br>import gspread<br>from oauth2client.service_account import ServiceAccountCredentials<br>import os<br>import morph<br>from morph import MorphGlobalContext<br>@morph.func<br>def get_gsheets(context: MorphGlobalContext):<br>    # Configure authentication information<br>    json_path = os.path.join(os.path.dirname(__file__), &quot;../credential.json&quot;)<br>    scope = [&#39;https://spreadsheets.google.com/feeds&#39;, &#39;https://www.googleapis.com/auth/drive&#39;]<br>    # get certification information<br>    credentials = ServiceAccountCredentials.from_json_keyfile_name(json_path, scope)<br>    client = gspread.authorize(credentials)<br>    # Open Spreadsheet<br>    spreadsheet = client.open_by_key(&quot;Sheet ID&quot;)<br>    worksheet = spreadsheet.worksheet(&quot;Sheet name&quot;)<br>    # Get data and convert to a DataFrame<br>    data = worksheet.get_all_values()<br>    df = pd.DataFrame(data[1:], columns=data[0])<br>    return df</pre><pre>## Display of aggregated table<br><br>import pandas as pd<br>import morph<br>from morph import MorphGlobalContext<br>@morph.func()<br>@morph.load_data(&quot;get_gsheets&quot;)<br>def group_by_date(context: MorphGlobalContext):<br>    df = context.data[&quot;get_gsheets&quot;]<br>    # Group by Created Date and count records, then sort by date in descending order<br>    grouped_df = df.groupby(&#39;Created Date&#39;).size().reset_index(name=&#39;count&#39;)<br>    grouped_df = grouped_df.sort_values(&#39;Created Date&#39;, ascending=False)<br>    return grouped_df</pre><pre># Display of Chart<br><br>import plotly.express as px<br>import pandas as pd<br>import morph<br>from morph import MorphGlobalContext<br>@morph.func()<br>@morph.load_data(&quot;group_by_date&quot;)<br>def group_by_date_chart(context: MorphGlobalContext):<br>    df = context.data[&quot;group_by_date&quot;]<br>    df[&#39;Created Date&#39;] = pd.to_datetime(df[&#39;Created Date&#39;])<br>    df[&#39;count&#39;] = pd.to_numeric(df[&#39;count&#39;], errors=&#39;coerce&#39;)<br>    # Create a line chart using plotly<br>    fig = px.line(df, x=&#39;Created Date&#39;, y=&#39;count&#39;, title=&#39;Record Count by Created Date&#39;)<br>    return fig.to_html()</pre><pre>{/* Frontend */}<br>## Dashboard<br>&lt;DataTable<br>  loadData=&quot;get_gsheets&quot;<br>  height={300}<br> /&gt;<br>&lt;Grid cols=&quot;2&quot;&gt;<br>    &lt;div&gt;<br>        ## Table<br>        &lt;DataTable<br>            loadData=&quot;group_by_date&quot;<br>            height={300}<br>        /&gt;<br>    &lt;/div&gt;<br>    &lt;div&gt;<br>        ## Chart<br>        &lt;Embed<br>            loadData=&quot;group_by_date_chart&quot;<br>            height={300}<br>            width={800}<br>        /&gt;<br>    &lt;/div&gt;<br>&lt;/Grid&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahEho0eM7KWKgBb174s8pg.png" /></figure><h3>Summary of Comparisons</h3><p>If you are familiar with Python, <strong>Streamlit and Morph</strong> will feel the most intuitive. If you are a data analyst proficient in SQL but not experienced with Python, you might prefer <strong>Evidence</strong>.</p><p>For dashboard applications, <strong>Evidence</strong> is a strong option because it provides many pre-built chart components, reducing the amount of code needed. If you need additional AI functionalities or features beyond dashboards, <strong>Streamlit or Morph</strong> would be better choices.</p><p>If you want maximum flexibility in UI customization, <strong>Morph</strong> stands out because it allows you to create custom React components and apply styling flexibly using MDX files.</p><h3>Pros, Cons, and Recommended Use Cases</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUkdRBoCwszGfwPxlT2sPA.png" /></figure><h3>Conclusion</h3><p>When comparing no-code, low-code, and code-based approaches for developing data applications with google sheets as the backend, there is a trade-off between flexibility, speed, and engineering requirements. For simple single-function applications or PoC use cases, no-code and low-code are viable options due to their speed. However, for building <strong>enterprise-grade internal data applications that meet specific operational needs, code-based approaches are more advantageous</strong>.</p><p>Considering the increasing demand for AI integration, <strong>Python frameworks such as Streamlit and Morph are strong contenders</strong> for future-proof data applications. Give them a try and see which one fits your needs!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8970b8641152" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/how-to-build-an-internal-data-application-using-spreadsheets-as-a-data-source-8970b8641152">How to Build an Internal Data Application Using Google Sheets as a Data Source</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Custom Chat App with Web Search in 3 Minutes Using Open AI’s New Responses API]]></title>
            <link>https://medium.com/morph-tech-blog/create-a-custom-chat-app-with-web-search-in-3-minutes-using-open-ais-new-responses-api-0e37871d0095?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/0e37871d0095</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[app-development]]></category>
            <dc:creator><![CDATA[Keita Mitsuhashi]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 02:03:02 GMT</pubDate>
            <atom:updated>2025-03-13T02:03:01.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0h6V_oumRwc4Ox-LyflMCQ.jpeg" /></figure><p>Open AI recently announced its <a href="https://openai.com/index/new-tools-for-building-agents/">new Responses API</a>. Responses API combines existing Chat Completion API and Assistant API into one simple interface integrating new tools.</p><p>In the latest <a href="https://platform.openai.com/docs/quickstart?api-mode=responses&amp;lang=python">developer documentation</a>, you can find plenty of code samples that support the new Responses API.</p><p>In this article, we’ll build a custom chat app with web search capabilities in just 3 minutes using the <a href="https://github.com/morph-data/morph">Morph framework</a> and the Responses API. The entire implementation was done in less than 30 lines of code.</p><p>This sample uses Python12 and uv.</p><h3>Project Setup</h3><p>First, install the morph command.</p><pre>pip install morph-data</pre><p>Next, initialize the project and install the dependency packages.</p><pre>morph new responses-api<br>cd responses-api</pre><pre>uv add openai</pre><h3>Building the Backend</h3><p>Inside the src directory, create a file called <a href="http://chat.py/">chat.py</a>. The code is simple. The latest OpenAI SDK provides a client that supports the Responses API.</p><pre># src/chat.py<br><br>import morph<br>from morph import MorphGlobalContext<br>from openai import OpenAI<br>@morph.func<br>def chat(context: MorphGlobalContext):<br>  client = OpenAI()<br>  # Add custom prompt if needed<br>  stream = client.responses.create(<br>    model=&quot;gpt-4o&quot;,<br>    tools=[{&quot;type&quot;: &quot;web_search_preview&quot;}], # Enable web search.<br>    input=context.vars[&quot;prompt&quot;],<br>    stream=True<br>  )<br>  for event in stream:<br>    if (event.type == &#39;response.output_text.delta&#39;):<br>      yield event.delta</pre><h3>Building the Frontend</h3><p>With the Morph framework, the frontend is built using Markdown. You can also use React components within Markdown.</p><pre>{/* src/pages/index.mdx */}<br># Open AI Responses API<br>A simple demo app using Open AI Responses API.<br>&lt;Chat height={700} postData=&#39;chat&#39; /&gt;</pre><h3>Outcome</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHAu-lmRiL_0SEOewVskMw.gif" /></figure><h3>Conclusion</h3><p>OpenAI’s Responses API has made the codebase extremely simple. With its integrated interface and flexible tool usage, even complex processes and agent-like behaviors can be achieved with a single API call, enabling a variety of workflows without the need for an LLM framework.</p><p>Furthermore, using Morph made it easy to create an app that leverages the Responses API. Give it a try! It’s highly recommended for quickly testing out new APIs and Python-based LLM frameworks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e37871d0095" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/create-a-custom-chat-app-with-web-search-in-3-minutes-using-open-ais-new-responses-api-0e37871d0095">Create a Custom Chat App with Web Search in 3 Minutes Using Open AI’s New Responses API</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Python Libraries + Tips for Enhancing OCR Accuracy in LLM APIs]]></title>
            <link>https://medium.com/morph-tech-blog/3-python-libraries-tips-for-enhancing-ocr-accuracy-in-llm-apis-9339eb11dfaf?source=rss----547c56bba22c---4</link>
            <guid isPermaLink="false">https://medium.com/p/9339eb11dfaf</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shunsuke Sakata]]></dc:creator>
            <pubDate>Wed, 12 Mar 2025 01:18:19 GMT</pubDate>
            <atom:updated>2025-03-12T01:18:19.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFYlHn34Cj-6l1TE8o0Xqw.jpeg" /></figure><h3>Four Data Preprocessing Techniques for Invoice OCR Using Generative AI</h3><blockquote><em>By leveraging generative AI, it has become easier to implement OCR that can handle flexible formats. However, to ensure accuracy, data preprocessing is crucial. In this article, we will introduce preprocessing techniques for invoice OCR using generative AI.</em></blockquote><h3>Benefits of OCR Using Generative AI</h3><p>Traditional OCR primarily relies on predefined algorithms, rule-based approaches, or machine learning models to recognize character patterns when extracting text from images. However, it commonly struggles with challenges such as “unexpected layouts,” “special formats,” and “noise.”</p><p>In contrast, OCR powered by generative AI has the distinct advantage of comprehensively understanding image data to extract text more effectively. This enables it to handle “complex layouts,” “handwritten text,” and “documents with mixed tables and diagrams” — areas where traditional OCR often falls short. Additionally, generative AI-based OCR offers greater flexibility and can even perform error correction and interpretation, enhancing overall accuracy.</p><h3>Improving the Accuracy of OCR Using Generative AI</h3><p>While OCR powered by generative AI can handle diverse formats, it may sometimes be less stable in terms of accuracy compared to traditional OCR.</p><p>This is where data preprocessing becomes crucial.</p><p>In this article, we will introduce data processing techniques using Python libraries and machine learning approaches to enhance OCR performance.</p><h3>Trimming Images Using the Pillow Library in Python</h3><p>When passing images to generative AI, removing as much irrelevant information as possible can significantly improve accuracy.</p><p>For structured documents like invoices, where the format is somewhat standardized, you can incorporate an <strong>automatic image trimming process</strong> using Python’s <strong>Pillow</strong> library. This helps eliminate unnecessary margins or background noise, ensuring that the OCR focuses only on the essential text areas.</p><p><a href="https://pypi.org/project/pillow/">https://pypi.org/project/pillow/</a></p><p>Furthermore, instead of directly applying OCR to the trimmed image, converting the trimmed image into Markdown using generative AI has shown improvements in accuracy.</p><pre>from PIL import Image<br><br># Open the image. <br>image = Image.open(&#39;invoice_sample.jpg&#39;)<br><br># Trimming area.<br>crop_area = (100,2400,1962,3100)<br><br># Execute trimming.<br>cropped_image = image.crop(crop_area)<br><br># Save the trimmed image. <br>cropped_image.save(&#39;invoice_sample_cropped.jpg&#39;)<br><br># Display the trimmed image.<br>cropped_image.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*vo5ouuVcPAvvfw6jfCA4aQ.png" /></figure><p>Furthermore, when the trimmed image is converted into Markdown, it is output as shown below. It can also be confirmed that the numbers are correctly converted.</p><pre>| Description              | Units       | Rate (USD) | Amount (USD) |<br>|--------------------------|-------------|------------|--------------|<br>| Basic Service Charge     | 1 month     | 850        | 850          |<br>| Electricity Usage        | 320 kWh     | 25/kWh     | 8,000        |<br>| Fuel Adjustment Charge   | 320 kWh     | 1.5/kWh    | 480          |<br>| Renewable Energy Fee     | 320 kWh     | 2.2/kWh    | 704          |<br>| Environmental Fee        | Flat rate   | 150        | 150          |</pre><h3>Adjusting Image Contrast Using OpenCV in Python</h3><p>By using the OpenCV library to adjust image contrast, it is possible to enhance readability and preprocess images for better OCR accuracy.</p><p>Manually correcting each image would be a tedious task, so an <strong>automated optimization</strong> approach can be used to adjust the image’s average brightness or median value to a target level. For example, a suitable gamma value can be determined based on the principle of bringing the <strong>average brightness</strong> of the image closer to <strong>128</strong> (the midpoint of the 0–255 range).</p><p>By adjusting the settings according to the characteristics of the images being processed, the accuracy of text recognition can be further improved.</p><pre>import cv2<br>import numpy as np<br><br># Load the image.<br>image = cv2.imread(&#39;invoice_sample_dark.png&#39;)<br><br># Parameter.<br>brightness = 70  # 例: +50明るくする<br><br># Adjust the brightness.<br>bright_image = cv2.convertScaleAbs(image, alpha=1.0, beta=brightness)<br><br># Save the image.<br>cv2.imwrite(&#39;invoice_sample_bright.png&#39;, bright_image)<br><br># Display the original and adjusted image.<br>cv2.imshow(&#39;Original Image&#39;, image)<br>cv2.imshow(&#39;Brightness Adjusted Image&#39;, bright_image)<br><br>cv2.waitKey(0)<br>cv2.destroyAllWindows()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*TkgMrlkRoGSfUVznOSdYrg.png" /></figure><h3>Combining Open-Source OCR with Python’s pytesseract Library</h3><p>Python provides an open-source OCR library called pytesseract, which allows text extraction from images. By using this library, it is possible to convert image-based text into machine-readable text.</p><p>Passing this extracted text along with the image to generative AI can help reduce numerical errors, such as incorrect decimal places.</p><p>Although recognizing handwritten text can be challenging, pytesseract is free to use, making it an easy way to experiment with improving OCR accuracy.</p><pre>import pytesseract<br>from PIL import Image<br><br># For Windows only, specify the Tesseract installation path (adjust the installation path accordingly).<br># pytesseract.pytesseract.tesseract_cmd = r&#39;C:\Program Files\Tesseract-OCR\tesseract.exe&#39;<br><br># Load the image.<br>image = Image.open(&#39;invoice_sample.jpg&#39;)<br><br># Execute OCR to extract text.<br>text = pytesseract.image_to_string(image, lang=&#39;eng&#39;)<br><br># Display the extracted text.<br>print(text)<br><br># Save the text to a file (optional).<br>with open(&#39;invoice_sample_text.txt&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:<br>    f.write(text)</pre><p>OCR result text file</p><pre>```<br>—J+- AZU—yyayk 2025-03-07 13.42.53<br><br>Sample Invoice - Power Company<br><br>ABC Power Company<br>123 Energy Street, Tokyo, Japan<br>Phone: 03-1234-5678<br><br>nail sbcpower.co.jp<br><br>456 Residential Ave, Shibuya, Tokyo 150-0002<br><br>Account Number: 000123456789<br><br>Invoice Number: INV-20250307-00123<br><br>Billing Date: March 7, 2025 1 i i<br>Billing Period: February 1, 2025 — February 28, 2025<br><br>Usage Summary:<br><br>Description Units Rate (USD) Amount (USD) | \ iil |<br>Basic Service Charge 1 month 850 850. AAT |<br>Electricity Usage 320 kWh 25/kWh 8,000<br><br>Fuel Adjustment Charge 320 kWh 1.5/kKWh 480<br><br>Renewable Energy Fee 320 kWh 2.2/kKWh 704<br><br>Environmental Fee Flat rate 150 |) eo<br><br>Subtotal: $10,184<br>Consumption Tax (10%): $1,018<br>Total Amount Due: $11,202<br>```</pre><h3>Combine OCR tools (Azure Vision AI)</h3><p>If pytesseract does not successfully extract text, you can also leverage existing OCR services.</p><p>For example, Azure Vision AI’s OCR service can accurately extract text from images. The extracted text is returned in JSON format via API. However, since this method only retrieves text data, table structures and other visual information from the image may be lost.</p><p>By having generative AI supplement the missing image information and combining it with the accurately extracted text, it becomes possible to extract specific information with higher accuracy.</p><p>Here is the result using Azure Vision Studio’s “Extract text from images” feature.</p><pre>SampleInvoice-PowerCompany<br>ABCPowerCompany<br>123EnergyStreet,Tokyo,Japan<br>Phone:03-1234-5678<br>Email:billing@abcpower.co.jp<br>Invoiceto:<br>JohnDoe<br>456ResidentialAve,Shibuya,Tokyo150-0002<br>AccountNumber:000123456789<br>InvoiceNumber:INV-20250307-00123<br>BillingDate:March7,2025<br>BillingPeriod:February1,2025-February28,2025<br>UsageSummary:<br>Description<br>Unit<br>Rate(USD)<br>Amount(USD)<br>BasicServiceCharge<br>1month<br>850<br>850<br>ElectricityUsage<br>320kWh<br>25/kWh<br>8,000<br>FuelAdjustmentCharge<br>320kWh<br>1.5/kWh<br>480<br>+<br>RenewableEnergyFee<br>320kWh<br>2.2/kWh<br>704<br>EnvironmentalFee<br>Flatrate<br>150<br>150<br>Subtotal:$10,184<br>ConsumptionTax(10%):$1,018<br>TotalAmountDue:$11,202</pre><h3>Summary: Easily Integrate OCR into Workflows with Generative AI</h3><p>As we have seen so far, by performing data preprocessing, it is possible to easily achieve high-accuracy OCR using generative AI.</p><p>Python also offers various powerful libraries. By leveraging the strengths of Python and cloud services, we can effectively utilize generative AI in real-world applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9339eb11dfaf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/morph-tech-blog/3-python-libraries-tips-for-enhancing-ocr-accuracy-in-llm-apis-9339eb11dfaf">3 Python Libraries + Tips for Enhancing OCR Accuracy in LLM APIs</a> was originally published in <a href="https://medium.com/morph-tech-blog">Squadbase Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>