AI 资讯
Building a typed CMS for business data with PHP, OpenAPI, and MCP
In my previous article, I introduced the NeNe series: a family of small, self-hosted business tools for teams operating in Japan. Previous article: https://dev.to/hideyukimori/i-am-building-self-hosted-business-tools-for-small-teams-in-japan-4i26 This article is a deeper look at one of those tools: NeNe Records . Repository: https://github.com/hideyukiMORI/nene-records NeNe Records is an API-first typed CMS and flexible entity platform built on NENE2 , my small PHP framework for AI-readable business APIs. It is not trying to be a WordPress clone. It is not trying to run WordPress plugins or themes. The goal is different: manage business data and public content through typed schemas, documented APIs, and clear AI tool boundaries. Why not just use WordPress? WordPress is useful. It has proven that a generic content model can support blogs, pages, shops, media, and many small business workflows. But when I think about business data, a few problems keep coming back: untyped metadata plugin-specific data shapes hooks and filters that can change behavior from many places API contracts that depend heavily on plugins AI integrations that may not know where the real application boundary is The postmeta model is flexible, but it often becomes stringly typed storage. That is fine for many websites. But for business data, I usually want the API to know more: this field is text this field is an enum this field is an image this field is a relation this field is required this record belongs to this organization this operation requires this role That is the space where NeNe Records lives. Typed records instead of metadata chaos The core model is simple: Entity Type -> Field Definition -> Record An Entity Type defines what kind of data exists. Examples: posts pages products events internal documents A Field Definition describes the shape of a field: text markdown html blocks int enum bool datetime image file relation A Record is the actual data. The important part is that the schema
开发者
Shifting Platform Development from Projects to Products
A company shifted from project- to product-thinking after their platform outgrew single-team use. The limitations that they felt with their platform were one-off deliveries, lack of product vision, and weak feedback loops. They have moved toward a self-service, API-driven, multi-tenant infrastructure with clearer ownership and better abstractions. By Ben Linders
AI 资讯
How to Automate OG Image Generation for Your Blog Using a Screenshot API
Every blog post needs an OG image. Without one, your links look blank on Twitter, LinkedIn, and Slack — just a plain URL that nobody clicks. Most developers solve this by spinning up a headless browser, loading an HTML template, taking a screenshot, and uploading it somewhere. It works, but now you're maintaining a Puppeteer instance, dealing with font rendering quirks, and burning server resources on something that should be simple. There's a faster approach: design your OG images as HTML templates and let a screenshot API handle the rendering. The Idea: HTML Templates as OG Images Think of your OG image as a tiny webpage. You already know HTML and CSS. Build a 1200×630 template with your blog title, author name, maybe a gradient background — whatever fits your brand. Host it or pass it as raw HTML. Then call an API to screenshot it. Done. A basic template might look like this: <div style= "width:1200px;height:630px;display:flex;align-items:center; justify-content:center;background:linear-gradient(135deg,#1a1a2e,#16213e); font-family:Inter,sans-serif;padding:60px" > <div style= "color:#fff;text-align:center" > <h1 style= "font-size:48px;margin:0" > {{title}} </h1> <p style= "font-size:24px;color:#8892b0;margin-top:20px" > {{author}} · {{date}} </p> </div> </div> Replace the placeholders on your server, then send the resulting HTML (or a URL pointing to it) to the API. Calling the API With ScreenshotRun , a single curl request captures the rendered template as a PNG: curl -X POST "https://api.screenshotrun.com/v1/screenshot" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://yourblog.com/og-template?title=My+Post+Title", "viewport_width": 1200, "viewport_height": 630, "format": "png" }' The response gives you the image file. Save it to your CDN, set the og:image meta tag, and you're done. No browser to manage, no Chrome binary eating RAM on your CI server. Wiring It Into Your Build If you publish with a static sit
AI 资讯
Stop Treating LLM API Errors Like Normal HTTP Errors
Most backend engineers already know how to handle HTTP errors. 400 means the request is bad. 401 means auth failed. 429 means rate limited. 500 means something broke upstream. Retry a few times, add exponential backoff, log the response body, move on. That works fine for many APIs. It works badly for LLM APIs. LLM providers may use normal HTTP status codes, but the operational meaning behind those errors is different enough that treating them like ordinary REST failures can make your app slower, more expensive, and harder to debug. The mistake I kept making Early on, I handled LLM failures the same way I handled every other external API: if ( response . status === 429 || response . status >= 500 ) { retryWithBackoff (); } Simple. Familiar. Dangerous. That logic misses the actual question your app needs to answer: What kind of LLM failure happened, and what should the product do next? Because an LLM API failure is rarely just "one HTTP request failed." It can break: a user-facing chat response a background agent run a document generation job a tool-calling workflow a batch evaluation pipeline a structured JSON generation step And each one needs different handling. Not all 429s mean the same thing For a normal API, 429 Too Many Requests usually means: Slow down and retry later. With LLM APIs, 429 can mean several different things. It might be a temporary rate limit: { "error" : { "message" : "Rate limit reached" , "type" : "rate_limit_error" } } Retrying with backoff may help here. But it might also mean quota exhaustion: { "error" : { "message" : "You exceeded your current quota" , "type" : "insufficient_quota" } } Retrying this does not help. It just adds latency, noisy logs, and a worse user experience. It could also be model-specific pressure. One model may be overloaded while another model from the same provider, or a different provider, would work fine. So your handler should distinguish between: temporary rate limit hard quota exhaustion model-level capacity is
AI 资讯
Integrating Claude/OpenAI API into a Laravel App: A Practical Guide
After 12+ years of building PHP applications, I recently added AI-powered features to a production Laravel dashboard — automatic report summaries generated from raw analytics data. What surprised me wasn't how hard it was. It was how little good PHP-focused content exists on this topic. Almost every LLM tutorial assumes you're writing Python. So here's the guide I wish I had: integrating the Claude API and OpenAI API into a Laravel app, with a clean architecture you can actually ship to production. What we'll build: a ReportSummaryService that takes raw data and returns a human-readable summary — with a driver pattern so you can switch between Claude and OpenAI with one config change. Step 1: Get Your API Keys Claude: Sign up at the Claude Console , generate a key under Account Settings. OpenAI: Get a key from the OpenAI Platform . Add them to your .env : AI_PROVIDER=claude ANTHROPIC_API_KEY=sk-ant-xxxxx ANTHROPIC_MODEL=claude-sonnet-4-6 OPENAI_API_KEY=sk-xxxxx OPENAI_MODEL=gpt-5-mini ⚠️ Never hardcode API keys. Never commit them. If you've ever pushed a key to Git, rotate it immediately. (You know this. I'm saying it anyway.) Now register them in config/services.php — this is the Laravel way, so you can use config() everywhere and benefit from config caching: 'anthropic' => [ 'key' => env ( 'ANTHROPIC_API_KEY' ), 'model' => env ( 'ANTHROPIC_MODEL' , 'claude-sonnet-4-6' ), ], 'openai' => [ 'key' => env ( 'OPENAI_API_KEY' ), 'model' => env ( 'OPENAI_MODEL' , 'gpt-5-mini' ), ], 'ai' => [ 'provider' => env ( 'AI_PROVIDER' , 'claude' ), ], Step 2: Understand the Two APIs (They're 95% Similar) Both are simple REST APIs. You POST JSON, you get JSON back. Claude (Messages API): POST https://api.anthropic.com/v1/messages Headers: x-api-key: YOUR_KEY anthropic-version: 2023-06-01 content-type: application/json OpenAI (Chat Completions API): POST https://api.openai.com/v1/chat/completions Headers: Authorization: Bearer YOUR_KEY content-type: application/json The key differenc
AI 资讯
العودة إلى Fable 5: كيفية إعادة توجيه أحمال عمل API بأمان
عندما توقف Claude Fable 5 عن العمل في 12 يونيو 2026 بموجب ضوابط التصدير الأمريكية، فعل فريقك ما فعلته أغلب الفرق: أعاد توجيه الإنتاج إلى Claude Opus 4.8 أو Sonnet 4.6، أصلح الأوامر المعطلة، وتجاوز الانقطاع. رُفعت الضوابط في 30 يونيو، وعاد Fable 5 للعمل اعتبارًا من 1 يوليو عبر Claude.ai ، وواجهة برمجة التطبيقات API، وClaude Code، وCowork. أكدت Anthropic إعادة النشر الكامل في إعلانها الرسمي . جرّب Apidog اليوم الخطوة السهلة هي التراجع عن آخر تغيير في التكوين واعتبار المشكلة منتهية. لا تفعل ذلك. الخدمة التي تعود إليها ليست بالضرورة مطابقة سلوكيًا لما استخدمته قبل الانقطاع: أُعيد تدريب طبقة الأمان، وقد تختلف جاهزية المنصات السحابية حسب المنطقة، وأصبح Opus 4.8 الذي استخدمته لثلاثة أسابيع خط الأساس العملي للمقارنة. تعامل مع العودة إلى Fable 5 كترحيل إنتاجي: تحقق، اختبر، قارن، ثم اطرح تدريجيًا. جرد ما تغير أثناء غيابك بين 12 يونيو و1 يوليو، تغيرت ثلاثة أشياء. وشيء واحد بقي كما هو. 1. أُعيد تدريب مصنف الأمان يأتي Fable 5 المعاد نشره مع مصنف أمان أُعيد تدريبه لاستهداف تقنية كسر حماية أُبلغ عنها أثناء الانقطاع. تقول Anthropic إنه يحظر أكثر من 99% من محاولات استخدام هذه التقنية. النقطة المهمة للتطبيقات الإنتاجية: الطلبات المصنفة لا تفشل بالضرورة. تُعاد توجيهها تلقائيًا إلى Claude Opus 4.8. الرد يحمل إشعارًا بذلك. أكثر من 95% من الجلسات لا ترى أي تراجع. هذا يعني أن أوامرك تعمل الآن أمام طبقة أمان مختلفة قليلًا. لا تفترض أن نتائج أوائل يونيو ما زالت صالحة؛ أعد الاختبار. 2. تحقق من حالة المنصة السحابية أعاد Amazon Bedrock دعم Fable 5 في 1 يوليو، في نفس يوم واجهة برمجة التطبيقات الأساسية، لكن ملفات تعريف الاستنتاج الإقليمية قد تُطرح بشكل غير متساوٍ. قد يكون Google Vertex AI وMicrosoft Foundry ما زالا في مرحلة اللحاق. توجيه Anthropic للمنصات المعلقة هو "بأسرع وقت ممكن"، بدون تاريخ محدد. إذا كنت تستخدم موفرًا سحابيًا، لا تغيّر الإنتاج قبل التحقق من: توفر Fable 5 على المنصة. توفره في المنطقة التي تستخدمها. توافق اسم النموذج أو ملف تعريف الاستنتاج مع تكوينك الحالي. 3. خطط الاشتراك لها تاريخ يجب مراقبته إذا كان أعضاء الفريق يستخدمون Claude عبر خطط الاشتراك بدلًا من مفاتيح API، فهناك تغ
AI 资讯
Most AI developer tools didn't add AI. They added a chat window.
AI is changing how we build software, but I think a lot of developer tools are solving yesterday's...
开发者
GraphQL Query & Mutation Architecture, A Production Deep Dive
Author: Erwin Wilson Ceniza Published: July 2, 2026 Tags: GraphQL | HotChocolate | BatchDataLoader | CQRS | Outbox Pattern | Apollo Federation | .NET | Architecture | EMR | API Design GraphQL Query & Mutation Architecture - A Production Deep Dive Code-first GraphQL with HotChocolate, BatchDataLoader, CQRS, and a transactional outbox pattern, with real examples from a production EMR system serving three portals from a single schema. Table of Contents Interactive Data Traversal The Architecture at 30,000 Feet Why GraphQL Won for Healthcare Data Shapes Simple Queries vs. Complex REST, The Comparison That Sold Me The Resolver Layer, Code-First, Schema-Last How GraphQL Smoothly Orchestrates the Application Services N+1 Is the Silent Killer, How BatchDataLoaders Eliminate It Mutation Architecture - CQRS + Transactional Outbox Security at the Resolver Level, Custom Middleware Attributes Type Extensions, Why I Stopped Writing DTO Mappers Projections, Filtering, Sorting, and Paging Apollo Federation, Future-Proofing the Graph GraphQL Client on Mobile, Sharing Query Logic Across Portals Why I Chose Ionic for the Patient Mobile App The Retrospective, What I'd Keep and What I'd Change A step-by-step walkthrough of how the app consumes (reads) and creates (writes) data through the services. interactive <script type="module"> const C = document.currentScript.parentElement; C.style.cssText='width:100%;font-family:system-ui,-apple-system,sans-serif'; const S = document.createElement('style'); S.textContent=` .gv *{box-sizing:border-box;margin:0;padding:0} .gv{background:var(--bg-secondary,#111);border-radius:12px;overflow:hidden;border:1px solid var(--border,#333);min-height:440px} .gv-tabs{display:flex;border-bottom:1px solid var(--border,#333);background:var(--bg-card,#1a1a1a)} .gv-tab{flex:1;padding:12px 8px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;cursor:pointer;border:none;background:none;color:var(--text-muted,#666);transition:all .2s;border
AI 资讯
Build a vendor onboarding agent with its own email inbox
Vendor onboarding usually starts with one clean request and then turns into a messy thread. Procurement asks for a W-9, security asks for a SOC 2 report, finance asks for remittance details, legal asks for an executed agreement, and the vendor replies with four attachments across three messages because different people own different parts of the process. That is exactly the kind of workflow where a generic "AI email assistant" gets risky. You do not want a model improvising legal language, requesting bank details in the wrong channel, or forwarding a confidential report to the wrong internal alias. You want the agent to own the repetitive coordination while your application keeps the state machine, policy, audit log, and approvals. The pattern I reach for is a dedicated Nylas Agent Account: vendors@yourcompany.com . It is a real mailbox the onboarding agent owns. It receives the vendor's replies, detects what is attached, updates your vendor record, sends safe reminders, and escalates missing or sensitive items to a human. The agent is not borrowing an employee's inbox, and it is not scraping a shared procurement mailbox. It has a grant, an email address, webhooks, threads, folders, and the same Messages API you would use for any other mailbox. I work on the Nylas CLI, so the terminal examples below use the commands I would use while building and debugging this flow. I also include the raw API calls because the production version belongs in your service, not in a shell script. What the agent should own Start by drawing the boundary tightly. A vendor onboarding agent should own message handling and coordination, not business approval. Good responsibilities: Receive vendor replies at a stable address. Read message bodies and attachment metadata. Match a reply to an existing vendor record. Detect which onboarding items are complete, missing, expired, or unreadable. Draft reminders and status updates. Schedule handoff calls when the vendor asks for help. Escalate sensit
AI 资讯
Looking for 10 teams to test a managed knowledge API for free
I have been building AI products for a while and kept running into the same problem. Every project that involves querying documents with AI requires the same foundation before you can build anything interesting: a chunking strategy, an embedding pipeline, a vector database, re-ingestion logic when content changes, and a retrieval layer on top. It is not hard, it is just a lot, and it is not the part you actually want to be building. So I built Kognita to handle it as a managed API. You push content in via API, text or files, and get back hybrid search over a knowledge base. Kognita handles chunking, embedding, indexing, and automatically re-embeds when you update content. It is opinionated: we pick the embedding model and chunking strategy. The trade-off is less flexibility for a much faster path to a working knowledge layer. What we are looking for We want 10 teams who are building something that needs a knowledge layer and are willing to test it honestly. The ask is: what broke, what was confusing, what you needed that was missing. Not looking for compliments. Looking for people who will actually use it and tell us where it falls short. What you get Unlimited knowledge bases 10 GB storage 100 GB egress per month 50 GB file storage No credit card. No time limit. Higher than our standard paid plan. Who it is for Engineering teams building AI features over documents who do not want to manage the underlying infrastructure themselves. If you need full control over your embedding models or retrieval strategies, this is probably not the right fit. If you want to skip the pipeline and get to building, it might be. How to get started Sign up at kognita.io. Drop a comment here if you sign up and I will make sure you are on the early adopter tier.
AI 资讯
The Token Bucket Algorithm: Build Server-Side API Rate Limiting in ~40 Lines
The Token Bucket Algorithm: Server-Side API Rate Limiting in ~40 Lines Plenty of tutorials teach you how to survive someone else's rate limit with retries and backoff. Far fewer show you how to build one. If you run an API, you need rate limiting on your side too — to protect your database from a runaway client, keep one noisy tenant from starving everyone else, and give abusive traffic a polite 429 instead of a melted server. The cleanest algorithm for the job is the token bucket . Let's implement it from scratch, then make it production-ready. How token bucket works Picture a bucket that holds up to capacity tokens. Every request removes one token. The bucket refills at a steady refillRate (tokens per second), up to its cap. If a request arrives and the bucket is empty, it's rejected. This gives you two useful properties at once: A sustained rate — the long-run average, set by refillRate . A burst allowance — clients can spend the whole bucket at once, set by capacity . That burst tolerance is why token bucket feels fair. A user who's been quiet for a minute can fire off a batch of requests without being punished for it. A minimal implementation Here's a self-contained bucket in JavaScript. No dependencies, no timers — we compute refill lazily based on elapsed time, which is both simpler and more accurate than a background interval. class TokenBucket { constructor ( capacity , refillRatePerSec ) { this . capacity = capacity ; this . refillRate = refillRatePerSec ; this . tokens = capacity ; this . lastRefill = Date . now (); } _refill () { const now = Date . now (); const elapsedSec = ( now - this . lastRefill ) / 1000 ; this . tokens = Math . min ( this . capacity , this . tokens + elapsedSec * this . refillRate ); this . lastRefill = now ; } take ( cost = 1 ) { this . _refill (); if ( this . tokens >= cost ) { this . tokens -= cost ; return { ok : true , remaining : Math . floor ( this . tokens ) }; } const deficit = cost - this . tokens ; const retryAfter = Mat
AI 资讯
Web Scraping with Python in 2026: Best Libraries and Anti-Bot Strategies
Web Scraping with Python in 2026: Best Libraries and Anti-Bot Strategies Web scraping in 2026 looks very different from 2020. Sites are smarter, anti-bot systems are more aggressive, and the legal landscape has evolved. Here's what actually works now. The 2026 Scraping Landscape Challenge 2020 Solution 2026 Solution Bot detection Rotate User-Agent Fingerprint randomization + residential proxies CAPTCHAs Manual solving Turnstile/hCaptcha solvers JavaScript rendering Selenium Playwright (faster, more reliable) Rate limiting Sleep between requests Adaptive pacing + request signing IP blocking VPN rotation Residential proxy pools Best Libraries in 2026 1. Playwright (Best for JS-heavy sites) from playwright.sync_api import sync_playwright def scrape_with_playwright ( url ): with sync_playwright () as p : browser = p . chromium . launch ( headless = True ) page = browser . new_page () page . goto ( url , wait_until = " networkidle " ) data = page . query_selector_all ( " .job-item " ) results = [] for item in data : title = item . query_selector ( " h2 " ). text_content () results . append ( title ) browser . close () return results 2. httpx + Selectolax (Fast, no JS needed) import httpx from selectolax.parser import HTMLParser def scrape_static ( url ): resp = httpx . get ( url , headers = { " User-Agent " : " Mozilla/5.0 " }) tree = HTMLParser ( resp . text ) for node in tree . css ( " .listing " ): print ( node . text ()) 3. API-First Approach (Always check first!) Many sites have hidden or public APIs that make scraping unnecessary: url = " https://www.freelancer.com/api/projects/0.1/projects/active/?query=python " data = httpx . get ( url ). json () Anti-Bot Strategies That Work 1. Request Fingerprint Randomization import random def get_random_headers (): browsers = [ " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " , " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " , ] return { " User-Agent " : random . choice ( browsers ), " A
AI 资讯
mcpgen: Turn any OpenAPI spec into an MCP server in seconds
I got tired of manually writing MCP tools for every REST endpoint I wanted to expose to an LLM. So I automated it. mcpgen reads an OpenAPI JSON or YAML file and generates a complete, ready‑to‑run MCP server in Python. 🔧 What it does Parses OpenAPI 3.0 / 3.1 specs Creates one MCP tool per endpoint (with snake_case names) Handles auth automatically (API key, Bearer, etc.) Outputs a clean, human‑readable Python script Zero runtime surprises – just mcp and httpx 🚀 Quick start bash pip install mcpgen mcpgen my-api.json -o my-mcp-server python my-mcp-server/server.py The generated server runs over stdio – ready to plug into Claude Desktop or any MCP client. 🧪 Real‑world test Recently a contributor added an OpenAPI 3.1 fixture (Xquik API) with lookupTweet and getUser endpoints. The tool generated the correct tools, including path parameters and x-api-key auth, on the first try. All 18 tests pass. It works. 🤔 Why you might want it If you’re building LLM agents that need to interact with APIs, mcpgen eliminates the boilerplate. You don’t have to write a single @app.tool() decorator by hand. It also makes it dead simple to experiment – change your API spec, regenerate the server, and you’re done. 📦 Links GitHub: JnanaSrota/mcpgen PyPI: pip install mcpgen MIT licensed, open to contributions 🙏 Feedback If you try it with your own API spec and something breaks (or works beautifully), I’d love to hear about it. Drop a comment or open an issue. Thanks for reading!
AI 资讯
Shifting Left: How TDD Became the Foundation of SokoFlow's Core Engine
SokoFlow Build Log — Month 1 of 4 Last semester I set out on a new strategic plan to level up my software development skills through deliberate, project-based learning. That work produced one of the most ambitious things I've built so far: Sim-Pesa , a local-first transactional appliance that lets developers working in the M-Pesa ecosystem test and simulate STK Push workflows entirely on their own machines, without depending on the Daraja sandbox. I documented that build in 16 weekly posts, which you can find here . This semester, the focus shifts — from fintech foundations to cloud-native integration and real-world systems. The flagship project is SokoFlow , a conversational ERP for small Kenyan shopkeepers to track inventory and record sales entirely through WhatsApp chat. No app to download, no training session required — just natural language. Where Sim-Pesa lived in a controlled, predictable transactional world, SokoFlow steps into the mess of cloud-native reality: third-party API failures, webhook signature verification, the statelessness of HTTP, and container orchestration. The target audience shifts too — Kenyan SMEs operating on infrastructure that is often unreliable by design, not by exception. It's an ambitious project, but the goal was always to learn as much as possible from it. With the plan in place, I got to work. 1. The Vision of a Headless ERP The first real question I had to answer before writing a line of code: what does "headless" actually mean? Headless architecture decouples the frontend — the "head," or user interface — from the backend, the "body" that holds the data and business logic. A conventional ERP bundles both: backend plus a dashboard or UI on top. A headless ERP, by contrast, is just the engine. The brain. There's no built-in screen. So how do users interact with a system that has no interface of its own? SokoFlow doesn't actually care. It could be: WhatsApp SMS A web app A mobile app A voice assistant In this case, the "frontend
开发者
Nano Banana 2 Lite with MCP, and Antigravity CLI
This article covers the MCP setup and configuration for using Google Nano Banana 2 Lite and...
AI 资讯
Building a Denim Collection API: A Practical Guide to Handling Product Variants
If you've ever worked with e-commerce data, you know that "a pair of jeans" is never just one product. A single style might come in 5 washes, 8 sizes, and 3 inseam lengths. That's 120 potential SKUs. Handling this correctly in an API can be tricky, so let me share a pattern I've used for structuring product variants. The core problem is balancing flexibility with performance. You want customers to filter by size, color, and fit without making dozens of API calls. Here's a simple but effective approach using a normalized database schema with a flat query layer: -- Products table (the "parent") CREATE TABLE products ( id UUID PRIMARY KEY , name TEXT NOT NULL , description TEXT , base_price DECIMAL ( 10 , 2 ), category TEXT ); -- Variants table (the actual sellable items) CREATE TABLE variants ( id UUID PRIMARY KEY , product_id UUID REFERENCES products ( id ), sku TEXT UNIQUE NOT NULL , size TEXT , color TEXT , wash TEXT , inseam TEXT , price DECIMAL ( 10 , 2 ), -- can override base price stock_quantity INT , image_url TEXT ); The key insight? Keep the product metadata (description, care instructions, brand story) in the products table, but put all the sellable attributes in variants. This lets you run queries like: -- Find all size 28 jeans in "mid wash" under $80 SELECT p . name , v . color , v . wash , v . price , v . stock_quantity FROM products p JOIN variants v ON p . id = v . product_id WHERE p . category = &# 039 ; women - jeans &# 039 ; AND v . size = &# 039 ; 28 &# 039 ; AND v . wash LIKE &# 039 ; % mid %&# 039 ; AND v . price & lt ; 80 AND v . stock_quantity & gt ; 0 ORDER BY v . price ; For the frontend, I usually return a flattened structure: { "product": { "id": "abc -123 " , "name": "Classic Straight Leg Jean" , "description": "High-rise fit in stretch denim..." , "availableSizes": [ " 24 " , " 25 " , " 26 " , " 27 "
AI 资讯
How I Fixed OpenAI Assistants API Timeout Errors in Production
It was during a live client demo. The AI was mid-session. The user was answering questions. Everything was going perfectly. Then — this: "Sorry, there was an error processing your request. Please try again." The client looked at us. My manager looked at me. I looked at my laptop and wanted to disappear. The Investigation First thing I checked: OpenAI dashboard. No failed runs. Nothing. I checked our server logs. There it was: run_timeout — after exactly 60 seconds But here's the thing — the run wasn't failing. It was just slow. OpenAI was still processing. Our backend gave up at 60s. OpenAI finished at 87s. We quit too early. Why Does This Happen? The longer a session gets, the more history OpenAI has to process. Early in a session: 3–5 seconds. Mid-session (10+ messages): 30–50 seconds. Long sessions: 60–90+ seconds. Our hardcoded limit of 60 seconds wasn't matching reality. The Fix Step 1: Made the timeout configurable via environment variable. # .env OPENAI_RUN_TIMEOUT_MS=150000 Step 2: Updated the polling loop to use it. const TIMEOUT_MS = parseInt ( process . env . OPENAI_RUN_TIMEOUT_MS ) || 150000 ; const TERMINAL = [ ' completed ' , ' failed ' , ' cancelled ' , ' expired ' , ' requires_action ' ]; while ( ! TERMINAL . includes ( runStatus . status )) { if ( Date . now () - startTime >= TIMEOUT_MS ) throw new Error ( ' run_timeout ' ); await new Promise ( r => setTimeout ( r , 1000 )); runStatus = await openai . beta . threads . runs . retrieve ( threadId , run . id ); } Step 3: Deployed. No more errors. Lessons Learned Always handle ALL 5 terminal states — not just "completed" Never hardcode timeouts for AI workloads — they vary by session length Your error logs and OpenAI dashboard together tell the full story What's Next I'm exploring runs.stream() — streaming responses in real time, no polling, no timeouts. Will write a follow-up once it's in production. Have you hit this before? How did you handle it? Drop it in the comments.
AI 资讯
I checked my OpenAI and Anthropic dashboards every morning for a month. Then I stopped.
OpenAI usage page, check spend. Anthropic console, check spend. Add it up in my head. Close both...
开发者
🚀 Build Your First Space Shooter Game with Limn Engine
🚀 Build Your First Space Shooter Game with Limn Engine A Complete Step-by-Step Tutorial for JavaScript Beginners Welcome! In this tutorial, you'll build a complete space shooter game using Limn Engine — a zero‑configuration 2D game engine that runs in your browser. What you'll build: A spaceship that moves, shoots bullets, fights waves of enemies, and keeps score. All in about 100 lines of code . By the end, you'll understand: How to create a game loop How to handle keyboard input How to detect collisions How to use particles for visual effects How to manage game state (lives, score, game over) 🎮 Want to play the finished game? Click here to play Space Shooter Live! Before We Start What You Need A text editor (VS Code, Notepad, or any code editor) A web browser (Chrome, Firefox, Edge) Limn Engine — download epic.js from limn-engine-doc.vercel.app What You Should Know Basic JavaScript (variables, functions, arrays, if-statements) How to open an HTML file in a browser No game development experience required! Step 1: The HTML Structure Every Limn Engine game starts with a simple HTML file. <!doctype html> <html> <head> <script src= "asset/epic.js" ></script> </head> <body> <script> // All your game code goes here </script> </body> </html> What's happening: <script src="asset/epic.js"> — loads the Limn Engine library Everything inside the second <script> tag is your game code Save this as game.html and open it in your browser. You should see a blank canvas with a blue gradient background. Step 2: Setting Up the Game The first thing we need is a Display — this is the engine that creates the canvas, runs the game loop, and handles input. const display = new Display (); display . perform (); // Activates performance mode (dual-canvas rendering) display . start ( 800 , 600 ); // Creates an 800×600 canvas What's happening: new Display() — creates the engine display.perform() — turns on high-performance mode display.start(800, 600) — creates a canvas 800 pixels wide and 600 p
AI 资讯
Chamath Palihapitiya raises $135M Series A for his AI coding startup, takes CEO role
VCs remain thirsty to fund AI coding startups. This one, founded by investor Chamath Palihapitiya, is no exception.