PageSourceSearch

https://langextract.com/_nuxt/Dyj8hDUv.js

js langextract.com collected 2026-10-05 09:36:13 UTC 37,402 bytes, 110 lines download raw bytes

1import{_ as E}from"./CW2tSzjR.js";import{e as A,A as L,h as S,i as z,k as D,f as y,u as V,c as b,a as t,x as M,b as c,w as r,g as u,t as e,l as _,v as w,n as o,s as q,d as n,F as j,r as k,o as x}from"./Cwowk-0D.js";import{_ as T}from"./DlAUqK2U.js";const B={class:"min-h-screen bg-gray-50"},H={class:"bg-white border-b border-gray-200"},N={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},R={class:"flex justify-between items-center h-16"},F={class:"text-xl sm:text-2xl font-bold text-gray-900"},K={class:"hidden md:flex items-center space-x-4 lg:space-x-8"},G={href:"https://github.com/google/langextract",target:"_blank",class:"text-gray-700 hover:text-gray-900 px-2 lg:px-3 py-2 text-sm font-medium"},U={class:"relative inline-block text-left"},O={class:"md:hidden"},J={class:"h-6 w-6",stroke:"currentColor",fill:"none",viewBox:"0 0 24 24"},X={key:0,class:"md:hidden"},Y={class:"px-2 pt-2 pb-3 space-y-1 sm:px-3"},Z={href:"https://github.com/google/langextract",target:"_blank",class:"text-gray-700 hover:text-gray-900 block px-3 py-2 text-base font-medium"},Q={class:"bg-gradient-to-br from-blue-50 to-indigo-100 py-12 lg:py-20"},W={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},tt={class:"text-center"},st={class:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800 mb-4"},et={class:"text-3xl sm:text-4xl lg:text-5xl font-bold text-gray-900 mb-4"},at={class:"bg-amber-50 border border-amber-200 rounded-lg p-4 mb-8 max-w-3xl mx-auto"},nt={class:"text-amber-900 font-semibold mb-2"},ot={class:"text-amber-800"},lt={href:"https://github.com/google/langextract",target:"_blank",class:"text-amber-900 underline hover:text-amber-700"},ct={class:"py-12 lg:py-16 bg-white"},rt={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},dt={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-4"},pt={class:"text-gray-600 mb-6"},it={class:"space-y-4"},bt={class:"bg-gray-900 rounded-lg p-4 overflow-x-auto"},xt={class:"text-green-400"},gt={class:"py-12 lg:py-16 bg-gray-50"},ut={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},vt={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-4"},mt={class:"text-gray-600 mb-8"},ht={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},yt={class:"text-xl font-semibold text-gray-900 mb-4"},ft={class:"text-gray-600 mb-4"},_t={class:"py-12 lg:py-16 bg-white"},wt={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},qt={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-8"},jt={class:"grid md:grid-cols-2 gap-8"},kt={class:"text-xl font-semibold text-gray-900 mb-4"},$t={class:"text-gray-600 mb-4"},It={class:"bg-gray-900 rounded-lg p-4 overflow-x-auto"},Ct={class:"text-sm text-green-400"},Pt={class:"text-xl font-semibold text-gray-900 mb-4"},Et={class:"text-gray-600 mb-4"},At={class:"space-y-2"},Lt={class:"flex items-start"},St={class:"text-gray-700"},zt={class:"flex items-start"},Dt={class:"text-gray-700"},Vt={class:"flex items-start"},Mt={class:"text-gray-700"},Tt={class:"py-12 lg:py-16 bg-gray-50"},Bt={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},Ht={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-8"},Nt={class:"space-y-8"},Rt={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},Ft={class:"text-xl font-semibold text-gray-900 mb-2"},Kt={class:"text-gray-600 mb-4"},Gt={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},Ut={class:"text-xl font-semibold text-gray-900 mb-2"},Ot={class:"text-gray-600 mb-4"},Jt={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},Xt={class:"text-xl font-semibold text-gray-900 mb-2"},Yt={class:"text-gray-600 mb-4"},Zt={class:"py-12 lg:py-16 bg-white"},Qt={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},Wt={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-8"},ts={class:"grid md:grid-cols-2 gap-8"},ss={class:"bg-gray-50 rounded-lg p-6"},es={class:"text-xl font-semibold text-gray-900 mb-2"},as={class:"text-gray-600 mb-4"},ns={class:"bg-gray-50 rounded-lg p-6"},os={class:"text-xl font-semibold text-gray-900 mb-2"},ls={class:"text-gray-600 mb-4"},cs={class:"bg-gray-50 rounded-lg p-6"},rs={class:"text-xl font-semibold text-gray-900 mb-2"},ds={class:"text-gray-600 mb-4"},ps={class:"bg-gray-50 rounded-lg p-6"},is={class:"text-xl font-semibold text-gray-900 mb-2"},bs={class:"text-gray-600 mb-4"},xs={class:"py-12 lg:py-16 bg-gray-50"},gs={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},us={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-4"},vs={class:"text-gray-600 mb-6"},ms={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},hs={class:"space-y-3"},ys={class:"text-gray-700"},fs={class:"py-12 lg:py-16 bg-white"},_s={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},ws={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-4"},qs={class:"text-gray-600 mb-6"},js={class:"bg-gray-50 rounded-lg p-6"},ks={class:"text-xl font-semibold text-gray-900 mb-4"},$s={class:"text-gray-600 mb-4"},Is={class:"py-12 lg:py-16 bg-gray-50"},Cs={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},Ps={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-8"},Es={class:"bg-white rounded-lg shadow-sm border border-gray-200 p-6"},As={class:"space-y-4"},Ls={class:"inline-flex items-center justify-center w-8 h-8 rounded-full bg-blue-100 text-blue-600 font-semibold text-sm mr-3 flex-shrink-0"},Ss={class:"text-gray-700"},zs={class:"py-12 lg:py-16 bg-white"},Ds={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"},Vs={class:"text-2xl sm:text-3xl font-bold text-gray-900 mb-8"},Ms={class:"grid sm:grid-cols-2 lg:grid-cols-4 gap-6"},Ts={href:"https://www.npmjs.com/package/langextract",target:"_blank",class:"block p-6 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"},Bs={class:"flex items-center mb-3"},Hs={class:"font-semibold text-gray-900"},Ns={href:"https://github.com/google/langextract",target:"_blank",class:"block p-6 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"},Rs={class:"flex items-center mb-3"},Fs={class:"font-semibold text-gray-900"},Ks={href:"https://github.com/google/langextract/tree/main/docs",target:"_blank",class:"block p-6 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"},Gs={class:"flex items-center mb-3"},Us={class:"font-semibold text-gray-900"},Os={href:"https://github.com/google/langextract/tree/main/examples",target:"_blank",class:"block p-6 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"},Js={class:"flex items-center mb-3"},Xs={class:"font-semibold text-gray-900"},Ys={class:"py-16 lg:py-20 bg-gradient-to-r from-blue-600 to-indigo-700"},Zs={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center"},Qs={class:"text-3xl sm:text-4xl font-bold text-white mb-4"},Ws={class:"text-xl text-blue-100 mb-8 max-w-2xl mx-auto"},te={class:"bg-gray-900 rounded-lg px-6 py-4 inline-block mb-6"},se={class:"text-green-400 text-lg"},ee={class:"flex flex-col sm:flex-row justify-center gap-4"},ae={href:"https://github.com/google/langextract",target:"_blank",class:"inline-flex items-center px-6 py-3 bg-blue-800 text-white font-semibold rounded-lg hover:bg-blue-900 transition-colors"},ne={class:"bg-gray-900 text-gray-300"},oe={class:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12"},le={class:"grid grid-cols-1 md:grid-cols-3 gap-8"},ce={class:"text-sm"},re={href:"https://github.com/google/langextract",target:"_blank",class:"text-blue-400 hover:text-blue-300"},de={class:"text-white font-semibold mb-4"},pe={class:"text-sm"},ie={class:"space-y-2 text-sm"},be={class:"mt-8 pt-8 border-t border-gray-700 text-center text-sm"},xe={__name:"nodejs-sdk",setup(ge){const{locale:v,t:p}=A(),{$router:$}=L(),I=S(),g=z(),i=D(!1),m=y({get:()=>v.value,set:s=>{v.value=s}}),f=async s=>{const a=s.target.value;await $.push(I(a))},C=y(()=>{const s=v.value;return s==="zh-hans"?["所有 API 方法的完整类型定义","VS Code 和其他 IDE 中的 IntelliSense 支持","类型安全的提取结果","自定义提取类的泛型类型"]:s==="zh-hant"?["所有 API 方法的完整型別定義","VS Code 和其他 IDE 中的 IntelliSense 支持","型別安全的擷取結果","自訂擷取類別的泛型型別"]:s==="ja"?["すべてのAPIメソッドの完全な型定義","VS Codeや他のIDEでのIntelliSenseサポート","型安全な抽出結果","カスタム抽出クラスのジェネリック型"]:s==="ko"?["모든 API 메서드에 대한 완전한 타입 정의","VS Code 및 기타 IDE에서 IntelliSense 지원","타입 안전 추출 결과","사용자 정의 추출 클래스를 위한 제네릭 타입"]:["Complete type definitions for all API methods","IntelliSense support in VS Code and other IDEs","Type-safe extraction results","Generic types for custom extraction classes"]}
1),P=y(()=>{const s=v.value;return s==="zh-hans"?["提供高质量的示例以获得更好的提取准确性","为多个文档使用批处理","缓存提取结果以减少 API 调用","实现适当的错误处理和重试","使用环境变量存储 API 密钥"]:s==="zh-hant"?["提供高品質的範例以獲得更好的擷取準確性","為多個文件使用批次處理","快取擷取結果以減少 API 呼叫","實作適當的錯誤處理和重試","使用環境變數儲存 API 金鑰"]:s==="ja"?["より良い抽出精度のために高品質な例を提供する","複数のドキュメントにはバッチ処理を使用する","API呼び出しを減らすために抽出結果をキャッシュする","適切なエラーハンドリングとリトライを実装する","APIキーには環境変数を使用する"]:s==="ko"?["더 나은 추출 정확도를 위해 고품질 예제 제공","여러 문서에 대해 배치 처리 사용","API 호출을 줄이기 위해 추출 결과 캐시","적절한 오류 처리와 재시도 구현","API 키는 환경 변수 사용"]:["Provide high-quality examples for better extraction accuracy","Use batch processing for multiple documents","Cache extraction results to reduce API calls","Implement proper error handling and retries","Use environment variables for API keys"]});return V({title:()=>`${p("nodejs.meta.title")}`,meta:[{name:"description",content:()=>p("nodejs.meta.description")},{name:"keywords",content:()=>p("nodejs.meta.keywords")},{property:"og:title",content:()=>p("nodejs.meta.title")},{property:"og:description",content:()=>p("nodejs.meta.description")},{property:"og:type",content:"website"},{property:"og:url",content:"https://langextract.com/nodejs-sdk"},{name:"twitter:card",content:"summary_large_image"},{name:"twitter:title",content:()=>p("nodejs.meta.title")},{name:"twitter:description",content:()=>p("nodejs.meta.description")}],link:[{rel:"canonical",href:"https://langextract.com/nodejs-sdk"}]}),(s,a)=>{const l=E;return x(),b("div",B,[t("nav",H,[t("div",N,[t("div",R,[c(l,{to:u(g)("/"),class:"flex items-center space-x-3 hover:opacity-80 transition-opacity"},{default:r(()=>[a[3]||(a[3]=t("div",{class:"w-8 h-8 text-blue-600"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",class:"w-full h-full"},[t("rect",{x:"4",y:"6",width:"16",height:"2",rx:"1",opacity:"0.6"}),t("rect",{x:"4",y:"10",width:"20",height:"2",rx:"1",opacity:"0.6"}),t("rect",{x:"4",y:"14",width:"18",height:"2",rx:"1",opacity:"0.6"}),t("rect",{x:"4",y:"18",width:"14",height:"2",rx:"1",opacity:"0.6"}),t("rect",{x:"4",y:"22",width:"16",height:"2",rx:"1",opacity:"0.6"}),t("path",{d:"M22 12 L28 16 L22 20 L22 17 L18 17 L18 15 L22 15 Z",fill:"currentColor"}),t("rect",{x:"26",y:"8",width:"4",height:"3",rx:"0.5",fill:"currentColor"}),t("rect",{x:"26",y:"13",width:"4",height:"3",rx:"0.5",fill:"currentColor"}),t("rect",{x:"26",y:"18",width:"4",height:"3",rx:"0.5",fill:"currentColor"})])],-1)),t("div",F,e(s.$t("hero.title")),1)]),_:1,__:[3]},8,["to"]),t("div",K,[c(l,{to:u(g)("/"),class:"text-gray-700 hover:text-gray-900 px-2 lg:px-3 py-2 text-sm font-medium"},{default:r(()=>[n(e(s.$t("nav.home")),1)]),_:1},8,["to"]),c(l,{to:u(g)("/nodejs-sdk"),class:"text-blue-600 hover:text-blue-700 px-2 lg:px-3 py-2 text-sm font-medium"},{default:r(()=>[n(e(s.$t("nodejs.title")),1)]),_:1},8,["to"]),t("a",G,e(s.$t("nav.docs")),1),a[5]||(a[5]=t("a",{href:"https://github.com/google/langextract",target:"_blank",class:"text-gray-700 hover:text-gray-900 px-2 lg:px-3 py-2 text-sm font-medium"}," GitHub ",-1)),t("div",U,[_(t("select",{onChange:f,"onUpdate:modelValue":a[0]||(a[0]=d=>m.value=d),class:"block w-full px-2 py-1 text-xs sm:text-sm border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"},a[4]||(a[4]=[o('<option value="en" data-v-1cb3b404>EN</option><option value="zh-hans" data-v-1cb3b404>中文</option><option value="zh-hant" data-v-1cb3b404>繁中</option><option value="ja" data-v-1cb3b404>日本</option><option value="ko" data-v-1cb3b404>한국</option>',5)]),544),[[w,m.value]])])]),t("div",O,[t("button",{onClick:a[1]||(a[1]=d=>
1i.value=!i.value),class:"inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100"},[(x(),b("svg",J,[t("path",{class:q({hidden:i.value,"inline-flex":!i.value}),"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h16M4 18h16"},null,2),t("path",{class:q({hidden:!i.value,"inline-flex":i.value}),"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"},null,2)]))])])])]),i.value?(x(),b("div",X,[t("div",Y,[c(l,{to:u(g)("/"),class:"text-gray-700 hover:text-gray-900 block px-3 py-2 text-base font-medium"},{default:r(()=>[n(e(s.$t("nav.home")),1)]),_:1},8,["to"]),c(l,{to:u(g)("/nodejs-sdk"),class:"text-blue-600 hover:text-blue-700 block px-3 py-2 text-base font-medium"},{default:r(()=>[n(e(s.$t("nodejs.title")),1)]),_:1},8,["to"]),t("a",Z,e(s.$t("nav.docs")),1),a[7]||(a[7]=t("a",{href:"https://github.com/google/langextract",target:"_blank",class:"text-gray-700 hover:text-gray-900 block px-3 py-2 text-base font-medium"}," GitHub ",-1)),_(t("select",{onChange:f,"onUpdate:modelValue":a[2]||(a[2]=d=>m.value=d),class:"mt-2 w-full px-3 py-2 text-base border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white"},a[6]||(a[6]=[o('<option value="en" data-v-1cb3b404>English</option><option value="zh-hans" data-v-1cb3b404>简体中文</option><option value="zh-hant" data-v-1cb3b404>繁體中文</option><option value="ja" data-v-1cb3b404>日本語</option><option value="ko" data-v-1cb3b404>한국어</option>',5)]),544),[[w,m.value]])])])):M("",!0)]),t("section",Q,[t("div",W,[t("div",tt,[t("div",st,e(s.$t("nodejs.title")),1),t("h1",et,e(s.$t("nodejs.subtitle")),1),t("div",at,[t("h3",nt,e(s.$t("nodejs.disclaimer.title")),1),t("p",ot,[n(e(s.$t("nodejs.disclaimer.description"))+" ",1),t("a",lt,e(s.$t("nodejs.disclaimer.link")),1),a[8]||(a[8]=n(". ",-1))])])])])]),t("section",ct,[t("div",rt,[t("h2",dt,e(s.$t("nodejs.installation.title")),1),t("p",pt,e(s.$t("nodejs.installation.description")),1),t("div",it,[t("div",bt,[t("pre",xt,[t("code",null,`# npm
2`+e(s.$t("nodejs.installation.npm"))+`
3
4# yarn
5`+e(s.$t("nodejs.installation.yarn"))+`
6
7# pnpm
8`+e(s.$t("nodejs.installation.pnpm")),1)])])])])]),t("section",gt,[t("div",ut,[t("h2",vt,e(s.$t("nodejs.quickStart.title")),1),t("p",mt,e(s.$t("nodejs.quickStart.description")),1),t("div",ht,[t("h3",yt,e(s.$t("nodejs.quickStart.example.title")),1),t("p",ft,e(s.$t("nodejs.quickStart.example.description")),1),a[9]||(a[9]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>import</span> { <span class="text-blue-300" data-v-1cb3b404>extract</span>, <span class="text-blue-300" data-v-1cb3b404>ExampleData</span> } <span class="text-purple-400" data-v-1cb3b404>from</span> <span class="text-green-300" data-v-1cb3b404>&quot;langextract&quot;</span>;
9
10<span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>examples</span>: <span class="text-yellow-300" data-v-1cb3b404>ExampleData</span>[] = [
11  {
12    <span class="text-red-300" data-v-1cb3b404>text</span>: <span class="text-green-300" data-v-1cb3b404>&quot;John Smith is 30 years old and works at Google.&quot;</span>,
13    <span class="text-red-300" data-v-1cb3b404>extractions</span>: [
14      {
15        <span class="text-red-300" data-v-1cb3b404>extractionClass</span>: <span class="text-green-300" data-v-1cb3b404>&quot;person&quot;</span>,
16        <span class="text-red-300" data-v-1cb3b404>extractionText</span>: <span class="text-green-300" data-v-1cb3b404>&quot;John Smith&quot;</span>,
17        <span class="text-red-300" data-v-1cb3b404>attributes</span>: {
18          <span class="text-red-300" data-v-1cb3b404>age</span>: <span class="text-green-300" data-v-1cb3b404>&quot;30&quot;</span>,
19          <span class="text-red-300" data-v-1cb3b404>employer</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Google&quot;</span>
20        }
21      }
22    ]
23  }
24];
25
26<span class="text-purple-400" data-v-1cb3b404>async function</span> <span class="text-yellow-300" data-v-1cb3b404>extractPersonInfo</span>() {
27  <span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>result</span> = <span class="text-purple-400" data-v-1cb3b404>await</span> <span class="text-yellow-300" data-v-1cb3b404>extract</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Alice Johnson is 25 and works at Microsoft.&quot;</span>, {
28    <span class="text-red-300" data-v-1cb3b404>promptDescription</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Extract person information including name, age, and employer&quot;</span>,
29    <span class="text-red-300" data-v-1cb3b404>examples</span>: examples,
30    <span class="text-red-300" data-v-1cb3b404>modelType</span>: <span class="text-green-300" data-v-1cb3b404>&quot;gemini&quot;</span>,
31    <span class="text-red-300" data-v-1cb3b404>apiKey</span>: process.env.<span class="text-blue-300" data-v-1cb3b404>LANGEXTRACT_API_KEY</span>
32  });
33  
34  console.<span class="text-yellow-300" data-v-1cb3b404>log</span>(result.extractions);
35}</code></pre></div>`,1))])])]),t("section",_t,[t("div",wt,[t("h2",qt,e(s.$t("nodejs.configuration.title")),1),t("div",jt,[t("div",null,[t("h3",kt,e(s.$t("nodejs.configuration.apiKey.title")),1),t("p",$t,e(s.$t("nodejs.configuration.apiKey.description")),1),t("div",It,[t("pre",Ct,[t("code",null,e(s.$t("nodejs.configuration.apiKey.envExample")),1)])])]),t("div",null,[t("h3",Pt,e(s.$t("nodejs.configuration.models.title")),1),t("p",Et,e(s.$t("nodejs.configuration.models.description")),1),t("ul",At,[t("li",Lt,[a[10]||(a[10]=t("span",{class:"text-green-500 mr-2"},"✓",-1)),t("span",St,e(s.$t("nodejs.configuration.models.gemini")),1)]),t("li",zt,[a[11]||(a[11]=t("span",{class:"text-green-500 mr-2"},"✓",-1)),t("span",Dt,e(s.$t("nodejs.configuration.models.openai")),1)]),t("li",Vt,[a[12]||(a[12]=t("span",{class:"text-green-500 mr-2"},"✓",-1)),t("span",Mt,e(s.$t("nodejs.configuration.models.ollama")),1
35)])])])])])]),t("section",Tt,[t("div",Bt,[t("h2",Ht,e(s.$t("nodejs.api.title")),1),t("div",Nt,[t("div",Rt,[t("h3",Ft,e(s.$t("nodejs.api.extract.title")),1),t("p",Kt,e(s.$t("nodejs.api.extract.description")),1),a[13]||(a[13]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto mb-4" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>async function</span> <span class="text-yellow-300" data-v-1cb3b404>extract</span>(
36  <span class="text-blue-300" data-v-1cb3b404>text</span>: <span class="text-yellow-300" data-v-1cb3b404>string</span>,
37  <span class="text-blue-300" data-v-1cb3b404>options</span>: {
38    <span class="text-red-300" data-v-1cb3b404>promptDescription</span>: <span class="text-yellow-300" data-v-1cb3b404>string</span>;
39    <span class="text-red-300" data-v-1cb3b404>examples</span>: <span class="text-yellow-300" data-v-1cb3b404>ExampleData</span>[];
40    <span class="text-red-300" data-v-1cb3b404>modelType</span>: <span class="text-green-300" data-v-1cb3b404>&quot;gemini&quot;</span> | <span class="text-green-300" data-v-1cb3b404>&quot;openai&quot;</span> | <span class="text-green-300" data-v-1cb3b404>&quot;ollama&quot;</span>;
41    <span class="text-red-300" data-v-1cb3b404>apiKey</span>?: <span class="text-yellow-300" data-v-1cb3b404>string</span>;
42    <span class="text-red-300" data-v-1cb3b404>modelId</span>?: <span class="text-yellow-300" data-v-1cb3b404>string</span>;
43  }
44): <span class="text-yellow-300" data-v-1cb3b404>Promise</span>&lt;<span class="text-yellow-300" data-v-1cb3b404>ExtractionResult</span>&gt;</code></pre></div>`,1))]),t("div",Gt,[t("h3",Ut,e(s.$t("nodejs.api.visualize.title")),1),t("p",Ot,e(s.$t("nodejs.api.visualize.description")),1),a[14]||(a[14]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto mb-4" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>function</span> <span class="text-yellow-300" data-v-1cb3b404>visualize</span>(
45  <span class="text-blue-300" data-v-1cb3b404>results</span>: <span class="text-yellow-300" data-v-1cb3b404>ExtractionResult</span>[],
46  <span class="text-blue-300" data-v-1cb3b404>options</span>?: {
47    <span class="text-red-300" data-v-1cb3b404>theme</span>?: <span class="text-green-300" data-v-1cb3b404>&quot;light&quot;</span> | <span class="text-green-300" data-v-1cb3b404>&quot;dark&quot;</span>;
48    <span class="text-red-300" data-v-1cb3b404>highlightColors</span>?: <span class="text-yellow-300" data-v-1cb3b404>string</span>[];
49  }
50): <span class="text-yellow-300" data-v-1cb3b404>string</span></code></pre></div>`,1))]),t("div",Jt,[t("h3",Xt,e(s.$t("nodejs.api.batch.title")),1),t("p",Yt,e(s.$t("nodejs.api.batch.description")),1),a[15]||(a[15]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto mb-4" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>async function</span> <span class="text-yellow-300" data-v-1cb3b404>batchExtract</span>(
51  <span class="text-blue-300" data-v-1cb3b404>documents</span>: <span class="text-yellow-300" data-v-1cb3b404>string</span>[],
52  <span class="text-blue-300" data-v-1cb3b404>options</span>: <span class="text-yellow-300" data-v-1cb3b404>ExtractOptions</span> &amp; {
53    <span class="text-red-300" data-v-1cb3b404>concurrency</span>?: <span class="text-yellow-300" data-v-1cb3b404>number</span>;
54    <span class="text-red-300" data-v-1cb3b404>onProgress</span>?: (<span class="text-blue-300" data-v-1cb3b404>completed</span>: <span class="text-yellow-300" data-v-1cb3b404>number</span>, <span class="text-blue-300" data-v-1cb3b404>total</span>: <span class="text-yellow-300" data-v-1cb3b404>number</span>) =&gt; <span class="text-yellow-300" data-v-1cb3b404>void</span>;
55  }
56): <span class="text-yellow-300" data-v-1cb3b404>Promise</span>&lt;<span class="text-yellow-300" data-v-1cb3b404>ExtractionResult</span>[]&gt;</code></pre></div>`,1))])])])]),t("section",Zt,[t("div",Qt,[t("h2",Wt,e(s.$t("nodejs.examples.title")),1),t("div",ts,[t("div",ss,[t("h3",es,e(s.$t("nodejs.examples.basic.title")),1),t("p",as,e(s.$t("nodejs.examples.basic.description")),1),a[16]||(a[16]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>result</span> = <span class="text-purple-400" data-v-1cb3b404>await</span> <span class="text-yellow-300" data-v-1cb3b404>extract</span>(<span class="text-green-300" data-v-1cb3b404>&quot;The product costs $99.99&quot;</span>, {
57  <span class="text-red-300" data-v-1cb3b404>promptDescription</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Extract product price&quot;</span>,
58  <span class="text-red-300" data-v-1cb3b404>examples</span>: [{
59    <span class="text-red-300" data-v-1cb3b404>text</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Price: $50&quot;</span>,
60    <span class="text-red-300" data-v-1cb3b404>extractions</span>: [{
61      <span class="text-red-300" data-v-1cb3b404>extractionClass</span>: <span class="text-green-300" data-v-1cb3b404>&quot;price&quot;</span>,
62      <span class="text-red-300" data-v-1cb3b404>extractionText</span>: <span class="text-green-300" data-v-1cb3b404>&quot;$50&quot;</span>
63    }]
64  }],
65  <span class="text-red-300" data-v-1cb3b404>modelType</span>: <span class="text-green-300" data-v-1cb3b404>&quot;gemini&quot;</span>
66});</code></pre></div>`,1))]),t("div",ns,[t("h3",os,e(s.$t("nodejs.examples.advanced.title")),1),t("p",ls,e(s.$t("nodejs.examples.advanced.description")),1),a[17]||(a[17]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>examples</span> = [{
67  <span class="text-red-300" data-v-1cb3b404>text</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Dr. Smith prescribed 500mg aspirin&quot;</span>,
68  <span class="text-red-300" data-v-1cb3b404>extractions</span>: [{
69    <span class="text-red-300" data-v-1cb3b404>extractionClass</span>: <span class="text-green-300" data-v-1cb3b404>&quot;medication&quot;</span>,
70    <span class="text-red-300" data-v-1cb3b404>extractionText</span>: <span class="text-green-300" data-v-1cb3b404>&quot;aspirin&quot;</span>,
71    <span class="text-red-300" data-v-1cb3b404>attributes</span>: {
72      <span class="text-red-300" data-v-1cb3b404>dosage</span>: <span class="text-green-300" data-v-1cb3b404>&quot;500mg&quot;</span>,
73      <span class="text-red-300" data-v-1cb3b404>prescriber</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Dr. Smith&quot;</span>
74    }
75  }]
76}];</code></pre></div>`,1))]),t("div",cs,[t("h3",rs,e(s.$t("nodejs.examples.batch.title")),1),t("p",ds,e(s.$t("nodejs.examples.batch.description")),1),a[18]||(a[18]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>documents</span> = [
77  <span class="text-green-300" data-v-1cb3b404>&quot;Document 1 content...&quot;</span>,
78  <span class="text-green-300" data-v-1cb3b404>&quot;Document 2 content...&quot;</span>,
79  <span class="text-green-300" data-v-1cb3b404>&quot;Document 3 content...&quot;</span>
80];
81
82<span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>results</span> = <span class="text-purple-400" data-v-1cb3b404>await</span> <span class="text-yellow-300" data-v-1cb3b404>batchExtract</span>(documents, {
83  <span class="text-red-300" data-v-1cb3b404>promptDescription</span>: <span class="text-green-300" data-v-1cb3b404>&quot;Extract entities&quot;</span>,
84  <span class="text-red-300" data-v-1cb3b404>examples</span>: examples,
85  <span class="text-red-300" data-v-1cb3b404>modelType</span>: <span class="text-green-300" data-v-1cb3b404>&quot;gemini&quot;</span>,
86  <span class="text-red-300" data-v-1cb3b404>concurrency</span>: <span class="text-orange-300" data-v-1cb3b404>3</span>,
87  <span class="text-red-300" data-v-1cb3b404>onProgress</span>: (<span class="text-blue-300" data-v-1cb3b404>done</span>, <span class="text-blue-300" data-v-1cb3b404>total</span>) =&gt; {
88    console.<span class="text-yellow-300" data-v-1cb3b404>log</span>(<span class="text-green-300" data-v-1cb3b404>\`Progress: </span><span class="text-orange-300" data-v-1cb3b404>\${</span>done<span class="text-orange-300" data-v-1cb3b404>}</span><span class="text-green-300" data-v-1cb3b404>/</span><span class="text-orange-300" data-v-1cb3b404>\${</span>total<span class="text-orange-300" data-v-1cb3b404>}</span><span class="text-green-300" data-v-1cb3b404>\`</span>);
89  }
90});</code></pre></div>`,1))]),t("div",ps,[t("h3",is,e(s.$t("nodejs.examples.visualization.title")),1),t("p",bs,e(s.$t("nodejs.examples.visualization.description")),1),a[19]||(a[19]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>html</span> = <span class="text-yellow-300" data-v-1cb3b404>visualize</span>(results, {
91  <span class="text-red-300" data-v-1cb3b404>theme</span>: <span class="text-green-300" data-v-1cb3b404>&quot;light&quot;</span>,
92  <span class="text-red-300" data-v-1cb3b404>highlightColors</span>: [<span class="text-green-300" data-v-1cb3b404>&quot;#3B82F6&quot;</span>, <span class="text-green-300" data-v-1cb3b404>&quot;#10B981&quot;</span>, <span class="text-green-300" data-v-1cb3b404>&quot;#F59E0B&quot;</span>]
93});
94
95<span class="text-gray-500" data-v-1cb3b404>// Save to file</span>
96<span class="text-purple-400" data-v-1cb3b404>import</span> { <span class="text-blue-300" data-v-1cb3b404>writeFileSync</span> } <span class="text-purple-400" data-v-1cb3b404>from</span> <span class="text-green-300" data-v-1cb3b404>&quot;fs&quot;</span>;
97<span class="text-yellow-300" data-v-1cb3b404>writeFileSync</span>(<span class="text-green-300" data-v-1cb3b404>&quot;results.html&quot;</span>, html);</code></pre></div>`,1))])])])]),t("section",xs,[t("div",gs,[t("h2",us,e(s.$t("nodejs.typescript.title")),1),t("p",vs,e(s.$t("nodejs.typescript.description")),1),t("div",ms,[t("ul",hs,[(x(!0),b(j,null,k(C.value,(d,h)=>(x(),b("li",{key:h,class:"flex items-start"},[a[20]||(a[20]=t("span",{class:"text-blue-600 mr-2 mt-0.5"},[t("svg",{class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},[t("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z","clip-rule":"evenodd"})])],-1)),t("span",ys,e(d),1)]))),128))])])])]),t("section",fs,[t("div",_s,[t("h2",ws,e(s.$t("nodejs.errorHandling.title")),1),t("p",qs,e(s.$t("nodejs.errorHandling.description")),1),t("div",js,[t("h3",ks,e(s.$t("nodejs.errorHandling.example.title")),1),t("p",$s,e(s.$t("nodejs.errorHandling.example.description")),1),a[21]||(a[21]=o(`<div class="bg-gray-900 rounded-lg p-4 overflow-x-auto" data-v-1cb3b404><pre class="text-sm" data-v-1cb3b404><code class="text-gray-100" data-v-1cb3b404><span class="text-purple-400" data-v-1cb3b404>try</span> {
98  <span class="text-purple-400" data-v-1cb3b404>const</span> <span class="text-blue-300" data-v-1cb3b404>result</span> = <span class="text-purple-400" data-v-1cb3b404>await</span> <span class="text-yellow-300" data-v-1cb3b404>extract</span>(text, options);
99  console.<span class="text-yellow-300" data-v-1cb3b404>log</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Extraction successful:&quot;</span>, result);
100} <span class="text-purple-400" data-v-1cb3b404>catch</span> (<span class="text-blue-300" data-v-1cb3b404>error</span>) {
101  <span class="text-purple-400" data-v-1cb3b404>if</span> (error.code === <span class="text-green-300" data-v-1cb3b404>&quot;INVALID_API_KEY&quot;</span>) {
102    console.<span class="text-red-400" data-v-1cb3b404>error</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Invalid API key provided&quot;</span>);
103  } <span class="text-purple-400" data-v-1cb3b404>else if</span> (error.code === <span class="text-green-300" data-v-1cb3b404>&quot;RATE_LIMIT_EXCEEDED&quot;</span>) {
104    console.<span class="text-red-400" data-v-1cb3b404>error</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Rate limit exceeded, retry after:&quot;</span>, error.retryAfter);
105  } <span class="text-purple-400" data-v-1cb3b404>else if</span> (error.code === <span class="text-green-300" data-v-1cb3b404>&quot;VALIDATION_ERROR&quot;</span>) {
106    console.<span class="text-red-400" data-v-1cb3b404>error</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Validation error:&quot;</span>, error.details);
107  } <span class="text-purple-400" data-v-1cb3b404>else</span> {
108    console.<span class="text-red-400" data-v-1cb3b404>error</span>(<span class="text-green-300" data-v-1cb3b404>&quot;Unexpected error:&quot;</span>, error.message);
109  }
110}</code></pre></div>`,1))])])]),t("section",Is,[t("div",Cs,[t("h2",Ps,e(s.$t("nodejs.bestPractices.title")),1),t("div",Es,[t("ul",As,[(x(!0),b(j,null,k(P.value,(d,h)=>(x(),b("li",{key:h,class:"flex items-start"},[t("span",Ls,e(h+1),1),t("span",Ss,e(d),1)]))),128))])])])]),t("section",zs,[t("div",Ds,[t("h2",Vs,e(s.$t("nodejs.resources.title")),1),t("div",Ms,[t("a",Ts,[t("div",Bs,[a[22]||(a[22]=t("div",{class:"w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center mr-3"},[t("svg",{class:"w-6 h-6 text-red-600",fill:"currentColor",viewBox:"0 0 24 24"},[t("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})])],-1)),t("h3",Hs,e(s.$t("nodejs.resources.links.npm")),1)]),a[23]||(a[23]=t("p",{class:"text-gray-600 text-sm"},"View package on NPM registry",-1))]),t("a",Ns,[t("div",Rs,[a[24]||(a[24]=t("div",{class:"w-10 h-10 bg-gray-800 rounded-lg flex items-center justify-center mr-3"}
110,[t("svg",{class:"w-6 h-6 text-white",fill:"currentColor",viewBox:"0 0 24 24"},[t("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 4.42 2.865 8.17 6.839 9.49.5.092.682-.217.682-.482 0-.237-.008-.866-.013-1.7-2.782.603-3.369-1.342-3.369-1.342-.454-1.155-1.11-1.462-1.11-1.462-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836c.85.004 1.705.114 2.504.336 1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.743 0 .267.18.578.688.48C19.138 20.167 22 16.418 22 12c0-5.523-4.477-10-10-10z"})])],-1)),t("h3",Fs,e(s.$t("nodejs.resources.links.github")),1)]),a[25]||(a[25]=t("p",{class:"text-gray-600 text-sm"},"Source code and issues",-1))]),t("a",Ks,[t("div",Gs,[a[26]||(a[26]=t("div",{class:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3"},[t("svg",{class:"w-6 h-6 text-blue-600",fill:"currentColor",viewBox:"0 0 24 24"},[t("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"})])],-1)),t("h3",Us,e(s.$t("nodejs.resources.links.docs")),1)]),a[27]||(a[27]=t("p",{class:"text-gray-600 text-sm"},"Detailed API documentation",-1))]),t("a",Os,[t("div",Js,[a[28]||(a[28]=t("div",{class:"w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center mr-3"},[t("svg",{class:"w-6 h-6 text-green-600",fill:"currentColor",viewBox:"0 0 24 24"},[t("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})])],-1)),t("h3",Xs,e(s.$t("nodejs.resources.links.examples")),1)]),a[29]||(a[29]=t("p",{class:"text-gray-600 text-sm"},"Complete example projects",-1))])])])]),t("section",Ys,[t("div",Zs,[t("h2",Qs,e(s.$t("cta.title")),1),t("p",Ws,e(s.$t("cta.description")),1),t("div",te,[t("code",se,e(s.$t("nodejs.installation.npm")),1)]),t("div",ee,[a[31]||(a[31]=t("a",{href:"https://www.npmjs.com/package/langextract",target:"_blank",class:"inline-flex items-center px-6 py-3 bg-white text-blue-600 font-semibold rounded-lg hover:bg-gray-100 transition-colors"},[n(" View on NPM "),t("svg",{class:"ml-2 w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})])],-1)),t("a",ae,[n(e(s.$t("cta.documentation"))+" ",1),a[30]||(a[30]=t("svg",{class:"ml-2 w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1))])])])]),t("footer",ne,[t("div",oe,[t("div",le,[t("div",null,[a[33]||(a[33]=t("h3",{class:"text-white font-semibold mb-4"}
110,"LangExtract",-1)),t("p",ce,[n(e(s.$t("footer.disclaimer"))+" ",1),t("a",re,e(s.$t("footer.officialRepo")),1),a[32]||(a[32]=n(". ",-1))])]),t("div",null,[t("h3",de,e(s.$t("footer.support")),1),t("p",pe,e(s.$t("footer.supportEmail")),1)]),t("div",null,[a[34]||(a[34]=t("h3",{class:"text-white font-semibold mb-4"},"Links",-1)),t("ul",ie,[t("li",null,[c(l,{to:"/",class:"hover:text-white"},{default:r(()=>[n(e(s.$t("nav.home")),1)]),_:1})]),t("li",null,[c(l,{to:"/about",class:"hover:text-white"},{default:r(()=>[n(e(s.$t("footer.links.about")),1)]),_:1})]),t("li",null,[c(l,{to:"/privacy",class:"hover:text-white"},{default:r(()=>[n(e(s.$t("footer.links.privacy")),1)]),_:1})]),t("li",null,[c(l,{to:"/terms",class:"hover:text-white"},{default:r(()=>[n(e(s.$t("footer.links.terms")),1)]),_:1})])])])]),t("div",be,[t("p",null,e(s.$t("footer.copyright")),1)])])])])}}},he=T(xe,[["__scopeId","data-v-1cb3b404"]]);export{he as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.