@agentica/chat 0.15.4 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/{Divider-DaLcPLlq.js → Divider-U2p72sQ2.js} +1 -1
- package/dist/assets/_accessExpressionAsString-J5NhZ9FO.js +1 -0
- package/dist/assets/_isFormatUri-Czmim0us.js +3162 -0
- package/dist/assets/bbs/index-CdF6qCrg.js +115 -0
- package/dist/assets/{client-BVv4NBtY.js → client-nQAh1QKo.js} +1 -1
- package/dist/assets/{index-BjONR16U.js → index-DmJqXwCp.js} +1 -1
- package/dist/assets/index-af7ihIz8.js +1641 -0
- package/dist/assets/shopping/index.html-C5MFMT7t.js +1 -0
- package/dist/assets/uploader/index.html-CH6UMGAK.js +27 -0
- package/dist/bbs/index.html +31 -24
- package/dist/index.html +29 -22
- package/dist/shopping/index.html +32 -24
- package/dist/uploader/index.html +30 -22
- package/lib/AgenticaChatApplication.d.ts +3 -3
- package/lib/components/MarkdownViewer.d.ts +1 -1
- package/lib/examples/bbs/BbsArticleService.d.ts +2 -2
- package/lib/examples/bbs/BbsChatApplication.d.ts +1 -1
- package/lib/examples/bbs/IBbsArticle.d.ts +1 -1
- package/lib/examples/shopping/ShoppingChatApplication.d.ts +3 -3
- package/lib/examples/uploader/AgenticaChatPlaygroundApplication.d.ts +3 -2
- package/lib/examples/uploader/AgenticaChatUploaderMovie.d.ts +2 -2
- package/lib/index.mjs +155 -146
- package/lib/index.mjs.map +1 -1
- package/lib/movies/messages/AgenticaChatDescribeMessageMovie.d.ts +3 -3
- package/lib/movies/messages/AgenticaChatExecuteMessageMovie.d.ts +3 -3
- package/lib/movies/messages/AgenticaChatMessageMovie.d.ts +3 -3
- package/lib/movies/messages/AgenticaChatSelectMessageMovie.d.ts +3 -3
- package/lib/movies/messages/AgenticaChatTextMessageMovie.d.ts +2 -2
- package/lib/movies/sides/AgenticaChatFunctionStackSideMovie.d.ts +3 -3
- package/lib/movies/sides/AgenticaChatSideMovie.d.ts +3 -3
- package/lib/movies/sides/AgenticaChatTokenUsageSideMovie.d.ts +2 -2
- package/package.json +21 -22
- package/src/AgenticaChatApplication.tsx +4 -6
- package/src/README.md +5 -2
- package/src/components/MarkdownViewer.tsx +2 -2
- package/src/movies/AgenticaChatMovie.tsx +22 -22
- package/src/movies/messages/AgenticaChatDescribeMessageMovie.tsx +10 -8
- package/src/movies/messages/AgenticaChatExecuteMessageMovie.tsx +14 -10
- package/src/movies/messages/AgenticaChatMessageMovie.tsx +12 -9
- package/src/movies/messages/AgenticaChatSelectMessageMovie.tsx +18 -15
- package/src/movies/messages/AgenticaChatTextMessageMovie.tsx +5 -4
- package/src/movies/sides/AgenticaChatFunctionStackSideMovie.tsx +7 -8
- package/src/movies/sides/AgenticaChatSideMovie.tsx +36 -26
- package/src/movies/sides/AgenticaChatTokenUsageSideMovie.tsx +22 -14
- package/dist/assets/AgenticaChatApplication-lWIm50QF.js +0 -4821
- package/dist/assets/_isFormatUri-YqTfGpHo.js +0 -1
- package/dist/assets/bbs/index-DQHKfogj.js +0 -97
- package/dist/assets/shopping/index.html-FHl0O6gf.js +0 -1
- package/dist/assets/uploader/index.html-CIM-e8Kh.js +0 -27
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import{j as I,o as as,r as Ue,T as bt}from"../client-nQAh1QKo.js";import{_ as xt,F as is,T as xn,R as os,c as Sn,d as An,B as ls}from"../index-af7ihIz8.js";import{v as cs,A as us,b as We,_ as Je,c as ds}from"../_isFormatUri-Czmim0us.js";import{D as hs}from"../Divider-U2p72sQ2.js";const Tt="RFC3986",kt={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:r=>String(r)},fs="RFC1738",ms=Array.isArray,z=(()=>{const r=[];for(let e=0;e<256;++e)r.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return r})(),St=1024,ps=(r,e,t,n,s)=>{if(r.length===0)return r;let a=r;if(typeof r=="symbol"?a=Symbol.prototype.toString.call(r):typeof r!="string"&&(a=String(r)),t==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let i="";for(let l=0;l<a.length;l+=St){const u=a.length>=St?a.slice(l,l+St):a,d=[];for(let o=0;o<u.length;++o){let c=u.charCodeAt(o);if(c===45||c===46||c===95||c===126||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||s===fs&&(c===40||c===41)){d[d.length]=u.charAt(o);continue}if(c<128){d[d.length]=z[c];continue}if(c<2048){d[d.length]=z[192|c>>6]+z[128|c&63];continue}if(c<55296||c>=57344){d[d.length]=z[224|c>>12]+z[128|c>>6&63]+z[128|c&63];continue}o+=1,c=65536+((c&1023)<<10|u.charCodeAt(o)&1023),d[d.length]=z[240|c>>18]+z[128|c>>12&63]+z[128|c>>6&63]+z[128|c&63]}i+=d.join("")}return i};function gs(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function Cn(r,e){if(ms(r)){const t=[];for(let n=0;n<r.length;n+=1)t.push(e(r[n]));return t}return e(r)}const _s=Object.prototype.hasOwnProperty,Vn={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,e){return String(r)+"["+e+"]"},repeat(r){return String(r)}},Y=Array.isArray,ys=Array.prototype.push,Kn=function(r,e){ys.apply(r,Y(e)?e:[e])},ws=Date.prototype.toISOString,F={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ps,encodeValuesOnly:!1,format:Tt,formatter:kt[Tt],indices:!1,serializeDate(r){return ws.call(r)},skipNulls:!1,strictNullHandling:!1};function bs(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}const At={};function Gn(r,e,t,n,s,a,i,l,u,d,o,c,h,f,w,g,_,N){let m=r,C=N,b=0,O=!1;for(;(C=C.get(At))!==void 0&&!O;){const $=C.get(r);if(b+=1,typeof $<"u"){if($===b)throw new RangeError("Cyclic object value");O=!0}typeof C.get(At)>"u"&&(b=0)}if(typeof d=="function"?m=d(e,m):m instanceof Date?m=h==null?void 0:h(m):t==="comma"&&Y(m)&&(m=Cn(m,function($){return $ instanceof Date?h==null?void 0:h($):$})),m===null){if(a)return u&&!g?u(e,F.encoder,_,"key",f):e;m=""}if(bs(m)||gs(m)){if(u){const $=g?e:u(e,F.encoder,_,"key",f);return[(w==null?void 0:w($))+"="+(w==null?void 0:w(u(m,F.encoder,_,"value",f)))]}return[(w==null?void 0:w(e))+"="+(w==null?void 0:w(String(m)))]}const v=[];if(typeof m>"u")return v;let A;if(t==="comma"&&Y(m))g&&u&&(m=Cn(m,u)),A=[{value:m.length>0?m.join(",")||null:void 0}];else if(Y(d))A=d;else{const $=Object.keys(m);A=o?$.sort(o):$}const H=l?String(e).replace(/\./g,"%2E"):String(e),T=n&&Y(m)&&m.length===1?H+"[]":H;if(s&&Y(m)&&m.length===0)return T+"[]";for(let $=0;$<A.length;++$){const P=A[$],ue=typeof P=="object"&&typeof P.value<"u"?P.value:m[P];if(i&&ue===null)continue;const wt=c&&l?P.replace(/\./g,"%2E"):P,ss=Y(m)?typeof t=="function"?t(T,wt):T:T+(c?"."+wt:"["+wt+"]");N.set(r,b);const bn=new WeakMap;bn.set(At,N),Kn(v,Gn(ue,ss,t,n,s,a,i,l,t==="comma"&&g&&Y(m)?null:u,d,o,c,h,f,w,g,_,bn))}return v}function xs(r=F){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=r.charset||F.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=Tt;if(typeof r.format<"u"){if(!_s.call(kt,r.format))throw new TypeError("Unknown format option provided.");t=r.format}const n=kt[t];let s=F.filter;(typeof r.filter=="function"||Y(r.filter))&&(s=r.filter);let a;if(r.arrayFormat&&r.arrayFormat in Vn?a=r.arrayFormat:"indices"in r?a=r.indices?"indices":"repeat":a=F.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const i=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:F.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:F.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:F.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:F.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?F.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:F.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:F.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:F.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:F.encodeValuesOnly,filter:s,format:t,formatter:n,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:F.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:F.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:F.strictNullHandling}}function Ss(r,e={}){let t=r;const n=xs(e);let s,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):Y(n.filter)&&(a=n.filter,s=a);const i=[];if(typeof t!="object"||t===null)return"";const l=Vn[n.arrayFormat],u=l==="comma"&&n.commaRoundTrip;s||(s=Object.keys(t)),n.sort&&s.sort(n.sort);const d=new WeakMap;for(let h=0;h<s.length;++h){const f=s[h];n.skipNulls&&t[f]===null||Kn(i,Gn(t[f],f,l,u,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,d))}const o=i.join(n.delimiter);let c=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?c+="utf8=%26%2310003%3B&":c+="utf8=%E2%9C%93&"),o.length>0?c+o:""}const pe="4.89.0";let vn=!1,Te,Qn,zn,Ft,Yn,Zn,er,tr,nr;function As(r,e={auto:!1}){if(vn)throw new Error(`you must \`import 'openai/shims/${r.kind}'\` before importing anything else from openai`);if(Te)throw new Error(`can't \`import 'openai/shims/${r.kind}'\` after \`import 'openai/shims/${Te}'\``);vn=e.auto,Te=r.kind,Qn=r.fetch,zn=r.FormData,Ft=r.File,Yn=r.ReadableStream,Zn=r.getMultipartRequestOptions,er=r.getDefaultAgent,tr=r.fileFromPath,nr=r.isFsReadStream}class Cs{constructor(e){this.body=e}get[Symbol.toStringTag](){return"MultipartBody"}}function vs({manuallyImported:r}={}){const e=r?"You may need to use polyfills":"Add one of these imports before your first `import … from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n";let t,n,s,a;try{t=fetch,n=Request,s=Response,a=Headers}catch(i){throw new Error(`this environment is missing the following Web Fetch API type: ${i.message}. ${e}`)}return{kind:"web",fetch:t,Request:n,Response:s,Headers:a,FormData:typeof FormData<"u"?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${e}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${e}`)}},File:typeof File<"u"?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${e}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${e}`)}},getMultipartRequestOptions:async(i,l)=>({...l,body:new Cs(i)}),getDefaultAgent:i=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:i=>!1}}Te||As(vs(),{auto:!0});class y extends Error{}class j extends y{constructor(e,t,n,s){super(`${j.makeMessage(e,t,n)}`),this.status=e,this.headers=s,this.request_id=s==null?void 0:s["x-request-id"],this.error=t;const a=t;this.code=a==null?void 0:a.code,this.param=a==null?void 0:a.param,this.type=a==null?void 0:a.type}static makeMessage(e,t,n){const s=t!=null&&t.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,t,n,s){if(!e||!s)return new ct({message:n,cause:Bt(t)});const a=t==null?void 0:t.error;return e===400?new rr(e,a,n,s):e===401?new sr(e,a,n,s):e===403?new ar(e,a,n,s):e===404?new ir(e,a,n,s):e===409?new or(e,a,n,s):e===422?new lr(e,a,n,s):e===429?new cr(e,a,n,s):e>=500?new ur(e,a,n,s):new j(e,a,n,s)}}class V extends j{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class ct extends j{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Xt extends ct{constructor({message:e}={}){super({message:e??"Request timed out."})}}class rr extends j{}class sr extends j{}class ar extends j{}class ir extends j{}class or extends j{}class lr extends j{}class cr extends j{}class ur extends j{}class dr extends y{constructor(){super("Could not parse response content as the length limit was reached")}}class hr extends y{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var qe=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},oe=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},q;class ut{constructor(){q.set(this,void 0),this.buffer=new Uint8Array,qe(this,q,null,"f")}decode(e){if(e==null)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?new TextEncoder().encode(e):e;let n=new Uint8Array(this.buffer.length+t.length);n.set(this.buffer),n.set(t,this.buffer.length),this.buffer=n;const s=[];let a;for(;(a=Rs(this.buffer,oe(this,q,"f")))!=null;){if(a.carriage&&oe(this,q,"f")==null){qe(this,q,a.index,"f");continue}if(oe(this,q,"f")!=null&&(a.index!==oe(this,q,"f")+1||a.carriage)){s.push(this.decodeText(this.buffer.slice(0,oe(this,q,"f")-1))),this.buffer=this.buffer.slice(oe(this,q,"f")),qe(this,q,null,"f");continue}const i=oe(this,q,"f")!==null?a.preceding-1:a.preceding,l=this.decodeText(this.buffer.slice(0,i));s.push(l),this.buffer=this.buffer.slice(a.index),qe(this,q,null,"f")}return s}decodeText(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof Buffer<"u"){if(e instanceof Buffer)return e.toString();if(e instanceof Uint8Array)return Buffer.from(e).toString();throw new y(`Unexpected: received non-Uint8Array (${e.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(e);throw new y(`Unexpected: received non-Uint8Array/ArrayBuffer (${e.constructor.name}) in a web platform. Please report this error.`)}throw new y("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){return this.buffer.length?this.decode(`
|
|
2
|
+
`):[]}}q=new WeakMap;ut.NEWLINE_CHARS=new Set([`
|
|
3
|
+
`,"\r"]);ut.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Rs(r,e){for(let s=e??0;s<r.length;s++){if(r[s]===10)return{preceding:s,index:s+1,carriage:!1};if(r[s]===13)return{preceding:s,index:s+1,carriage:!0}}return null}function Ps(r){for(let n=0;n<r.length-1;n++){if(r[n]===10&&r[n+1]===10||r[n]===13&&r[n+1]===13)return n+2;if(r[n]===13&&r[n+1]===10&&n+3<r.length&&r[n+2]===13&&r[n+3]===10)return n+4}return-1}function fr(r){if(r[Symbol.asyncIterator])return r;const e=r.getReader();return{async next(){try{const t=await e.read();return t!=null&&t.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){const t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class ee{constructor(e,t){this.iterator=e,this.controller=t}static fromSSEResponse(e,t){let n=!1;async function*s(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let a=!1;try{for await(const i of Is(e,t))if(!a){if(i.data.startsWith("[DONE]")){a=!0;continue}if(i.event===null||i.event.startsWith("response.")){let l;try{l=JSON.parse(i.data)}catch(u){throw console.error("Could not parse message into JSON:",i.data),console.error("From chunk:",i.raw),u}if(l&&l.error)throw new j(void 0,l.error,void 0,void 0);yield l}else{let l;try{l=JSON.parse(i.data)}catch(u){throw console.error("Could not parse message into JSON:",i.data),console.error("From chunk:",i.raw),u}if(i.event=="error")throw new j(void 0,l.error,l.message,void 0);yield{event:i.event,data:l}}}a=!0}catch(i){if(i instanceof Error&&i.name==="AbortError")return;throw i}finally{a||t.abort()}}return new ee(s,t)}static fromReadableStream(e,t){let n=!1;async function*s(){const i=new ut,l=fr(e);for await(const u of l)for(const d of i.decode(u))yield d;for(const u of i.flush())yield u}async function*a(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let i=!1;try{for await(const l of s())i||l&&(yield JSON.parse(l));i=!0}catch(l){if(l instanceof Error&&l.name==="AbortError")return;throw l}finally{i||t.abort()}}return new ee(a,t)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),s=a=>({next:()=>{if(a.length===0){const i=n.next();e.push(i),t.push(i)}return a.shift()}});return[new ee(()=>s(e),this.controller),new ee(()=>s(t),this.controller)]}toReadableStream(){const e=this;let t;const n=new TextEncoder;return new Yn({async start(){t=e[Symbol.asyncIterator]()},async pull(s){try{const{value:a,done:i}=await t.next();if(i)return s.close();const l=n.encode(JSON.stringify(a)+`
|
|
4
|
+
`);s.enqueue(l)}catch(a){s.error(a)}},async cancel(){var s;await((s=t.return)==null?void 0:s.call(t))}})}}async function*Is(r,e){if(!r.body)throw e.abort(),new y("Attempted to iterate over a response with no body");const t=new $s,n=new ut,s=fr(r.body);for await(const a of Es(s))for(const i of n.decode(a)){const l=t.decode(i);l&&(yield l)}for(const a of n.flush()){const i=t.decode(a);i&&(yield i)}}async function*Es(r){let e=new Uint8Array;for await(const t of r){if(t==null)continue;const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?new TextEncoder().encode(t):t;let s=new Uint8Array(e.length+n.length);s.set(e),s.set(n,e.length),e=s;let a;for(;(a=Ps(e))!==-1;)yield e.slice(0,a),e=e.slice(a)}e.length>0&&(yield e)}class $s{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const a={event:this.event,data:this.data.join(`
|
|
5
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],a}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,n,s]=Os(e,":");return s.startsWith(" ")&&(s=s.substring(1)),t==="event"?this.event=s:t==="data"&&this.data.push(s),null}}function Os(r,e){const t=r.indexOf(e);return t!==-1?[r.substring(0,t),e,r.substring(t+e.length)]:[r,"",""]}const mr=r=>r!=null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.blob=="function",pr=r=>r!=null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.lastModified=="number"&&dt(r),dt=r=>r!=null&&typeof r=="object"&&typeof r.size=="number"&&typeof r.type=="string"&&typeof r.text=="function"&&typeof r.slice=="function"&&typeof r.arrayBuffer=="function",Ts=r=>pr(r)||mr(r)||nr(r);async function gr(r,e,t){var s;if(r=await r,pr(r))return r;if(mr(r)){const a=await r.blob();e||(e=new URL(r.url).pathname.split(/[\\/]/).pop()??"unknown_file");const i=dt(a)?[await a.arrayBuffer()]:[a];return new Ft(i,e,t)}const n=await ks(r);if(e||(e=Ms(r)??"unknown_file"),!(t!=null&&t.type)){const a=(s=n[0])==null?void 0:s.type;typeof a=="string"&&(t={...t,type:a})}return new Ft(n,e,t)}async function ks(r){var t;let e=[];if(typeof r=="string"||ArrayBuffer.isView(r)||r instanceof ArrayBuffer)e.push(r);else if(dt(r))e.push(await r.arrayBuffer());else if(Bs(r))for await(const n of r)e.push(n);else throw new Error(`Unexpected data type: ${typeof r}; constructor: ${(t=r==null?void 0:r.constructor)==null?void 0:t.name}; props: ${Fs(r)}`);return e}function Fs(r){return`[${Object.getOwnPropertyNames(r).map(t=>`"${t}"`).join(", ")}]`}function Ms(r){var e;return Ct(r.name)||Ct(r.filename)||((e=Ct(r.path))==null?void 0:e.split(/[\\/]/).pop())}const Ct=r=>{if(typeof r=="string")return r;if(typeof Buffer<"u"&&r instanceof Buffer)return String(r)},Bs=r=>r!=null&&typeof r=="object"&&typeof r[Symbol.asyncIterator]=="function",Rn=r=>r&&typeof r=="object"&&r.body&&r[Symbol.toStringTag]==="MultipartBody",Se=async r=>{const e=await Ns(r.body);return Zn(e,r)},Ns=async r=>{const e=new zn;return await Promise.all(Object.entries(r||{}).map(([t,n])=>Mt(e,t,n))),e},Mt=async(r,e,t)=>{if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")r.append(e,String(t));else if(Ts(t)){const n=await gr(t);r.append(e,n)}else if(Array.isArray(t))await Promise.all(t.map(n=>Mt(r,e+"[]",n)));else if(typeof t=="object")await Promise.all(Object.entries(t).map(([n,s])=>Mt(r,`${e}[${n}]`,s)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var ye={},Ds=function(r,e,t,n,s){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t},js=function(r,e,t,n){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Xe;async function _r(r){var i;const{response:e}=r;if(r.options.stream)return we("response",e.status,e.url,e.headers,e.body),r.options.__streamClass?r.options.__streamClass.fromSSEResponse(e,r.controller):ee.fromSSEResponse(e,r.controller);if(e.status===204)return null;if(r.options.__binaryResponse)return e;const t=e.headers.get("content-type"),n=(i=t==null?void 0:t.split(";")[0])==null?void 0:i.trim();if((n==null?void 0:n.includes("application/json"))||(n==null?void 0:n.endsWith("+json"))){const l=await e.json();return we("response",e.status,e.url,e.headers,l),yr(l,e)}const a=await e.text();return we("response",e.status,e.url,e.headers,a),a}function yr(r,e){return!r||typeof r!="object"||Array.isArray(r)?r:Object.defineProperty(r,"_request_id",{value:e.headers.get("x-request-id"),enumerable:!1})}class ht extends Promise{constructor(e,t=_r){super(n=>{n(null)}),this.responsePromise=e,this.parseResponse=t}_thenUnwrap(e){return new ht(this.responsePromise,async t=>yr(e(await this.parseResponse(t),t),t.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}class Ls{constructor({baseURL:e,maxRetries:t=2,timeout:n=6e5,httpAgent:s,fetch:a}){this.baseURL=e,this.maxRetries=vt("maxRetries",t),this.timeout=vt("timeout",n),this.httpAgent=s,this.fetch=a??Qn}authHeaders(e){return{}}defaultHeaders(e){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...Hs(),...this.authHeaders(e)}}validateHeaders(e,t){}defaultIdempotencyKey(){return`stainless-node-retry-${Qs()}`}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(async s=>{const a=s&&dt(s==null?void 0:s.body)?new DataView(await s.body.arrayBuffer()):(s==null?void 0:s.body)instanceof DataView?s.body:(s==null?void 0:s.body)instanceof ArrayBuffer?new DataView(s.body):s&&ArrayBuffer.isView(s==null?void 0:s.body)?new DataView(s.body.buffer):s==null?void 0:s.body;return{method:e,path:t,...s,body:a}}))}getAPIList(e,t,n){return this.requestAPIList(t,{method:"get",path:e,...n})}calculateContentLength(e){if(typeof e=="string"){if(typeof Buffer<"u")return Buffer.byteLength(e,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode(e).length.toString()}else if(ArrayBuffer.isView(e))return e.byteLength.toString();return null}buildRequest(e,{retryCount:t=0}={}){var w;e={...e};const{method:n,path:s,query:a,headers:i={}}=e,l=ArrayBuffer.isView(e.body)||e.__binaryRequest&&typeof e.body=="string"?e.body:Rn(e.body)?e.body.body:e.body?JSON.stringify(e.body,null,2):null,u=this.calculateContentLength(l),d=this.buildURL(s,a);"timeout"in e&&vt("timeout",e.timeout),e.timeout=e.timeout??this.timeout;const o=e.httpAgent??this.httpAgent??er(d),c=e.timeout+1e3;typeof((w=o==null?void 0:o.options)==null?void 0:w.timeout)=="number"&&c>(o.options.timeout??0)&&(o.options.timeout=c),this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);const h=this.buildHeaders({options:e,headers:i,contentLength:u,retryCount:t});return{req:{method:n,...l&&{body:l},headers:h,...o&&{agent:o},signal:e.signal??null},url:d,timeout:e.timeout}}buildHeaders({options:e,headers:t,contentLength:n,retryCount:s}){const a={};n&&(a["content-length"]=n);const i=this.defaultHeaders(e);return $n(a,i),$n(a,t),Rn(e.body)&&Te!=="node"&&delete a["content-type"],Ve(i,"x-stainless-retry-count")===void 0&&Ve(t,"x-stainless-retry-count")===void 0&&(a["x-stainless-retry-count"]=String(s)),Ve(i,"x-stainless-timeout")===void 0&&Ve(t,"x-stainless-timeout")===void 0&&e.timeout&&(a["x-stainless-timeout"]=String(e.timeout)),this.validateHeaders(a,t),a}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}parseHeaders(e){return e?Symbol.iterator in e?Object.fromEntries(Array.from(e).map(t=>[...t])):{...e}:{}}makeStatusError(e,t,n,s){return j.generate(e,t,n,s)}request(e,t=null){return new ht(this.makeRequest(e,t))}async makeRequest(e,t){var c,h;const n=await e,s=n.maxRetries??this.maxRetries;t==null&&(t=s),await this.prepareOptions(n);const{req:a,url:i,timeout:l}=this.buildRequest(n,{retryCount:s-t});if(await this.prepareRequest(a,{url:i,options:n}),we("request",i,n,a.headers),(c=n.signal)!=null&&c.aborted)throw new V;const u=new AbortController,d=await this.fetchWithTimeout(i,a,l,u).catch(Bt);if(d instanceof Error){if((h=n.signal)!=null&&h.aborted)throw new V;if(t)return this.retryRequest(n,t);throw d.name==="AbortError"?new Xt:new ct({cause:d})}const o=Ws(d.headers);if(!d.ok){if(t&&this.shouldRetry(d)){const m=`retrying, ${t} attempts remaining`;return we(`response (error; ${m})`,d.status,i,o),this.retryRequest(n,t,o)}const f=await d.text().catch(m=>Bt(m).message),w=Vs(f),g=w?void 0:f;throw we(`response (error; ${t?"(error; no more retries left)":"(error; not retryable)"})`,d.status,i,o,g),this.makeStatusError(d.status,w,g,o)}return{response:d,options:n,controller:u}}requestAPIList(e,t){const n=this.makeRequest(t,null);return new Us(this,n,e)}buildURL(e,t){const n=Gs(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery();return br(s)||(t={...s,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(n.search=this.stringifyQuery(t)),n.toString()}stringifyQuery(e){return Object.entries(e).filter(([t,n])=>typeof n<"u").map(([t,n])=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(n===null)return`${encodeURIComponent(t)}=`;throw new y(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout(e,t,n,s){const{signal:a,...i}=t||{};a&&a.addEventListener("abort",()=>s.abort());const l=setTimeout(()=>s.abort(),n),u={signal:s.signal,...i};return u.method&&(u.method=u.method.toUpperCase()),this.fetch.call(void 0,e,u).finally(()=>{clearTimeout(l)})}shouldRetry(e){const t=e.headers.get("x-should-retry");return t==="true"?!0:t==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n){let s;const a=n==null?void 0:n["retry-after-ms"];if(a){const l=parseFloat(a);Number.isNaN(l)||(s=l)}const i=n==null?void 0:n["retry-after"];if(i&&!s){const l=parseFloat(i);Number.isNaN(l)?s=Date.parse(i)-Date.now():s=l*1e3}if(!(s&&0<=s&&s<60*1e3)){const l=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(t,l)}return await Be(s),this.makeRequest(e,t-1)}calculateDefaultRetryTimeoutMillis(e,t){const a=t-e,i=Math.min(.5*Math.pow(2,a),8),l=1-Math.random()*.25;return i*l*1e3}getUserAgent(){return`${this.constructor.name}/JS ${pe}`}}class wr{constructor(e,t,n,s){Xe.set(this,void 0),Ds(this,Xe,e),this.options=s,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageInfo()!=null:!1}async getNextPage(){const e=this.nextPageInfo();if(!e)throw new y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");const t={...this.options};if("params"in e&&typeof t.query=="object")t.query={...t.query,...e.params};else if("url"in e){const n=[...Object.entries(t.query||{}),...e.url.searchParams.entries()];for(const[s,a]of n)e.url.searchParams.set(s,a);t.query=void 0,t.path=e.url.toString()}return await js(this,Xe,"f").requestAPIList(this.constructor,t)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Xe=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class Us extends ht{constructor(e,t,n){super(t,async s=>new n(e,s.response,await _r(s),s.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const t of e)yield t}}const Ws=r=>new Proxy(Object.fromEntries(r.entries()),{get(e,t){const n=t.toString();return e[n.toLowerCase()]||e[n]}}),Js={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__metadata:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},B=r=>typeof r=="object"&&r!==null&&!br(r)&&Object.keys(r).every(e=>xr(Js,e)),qs=()=>{var e;if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":pe,"X-Stainless-OS":In(Deno.build.os),"X-Stainless-Arch":Pn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:((e=Deno.version)==null?void 0:e.deno)??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":pe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":pe,"X-Stainless-OS":In(process.platform),"X-Stainless-Arch":Pn(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};const r=Xs();return r?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":pe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${r.browser}`,"X-Stainless-Runtime-Version":r.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":pe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Xs(){if(typeof navigator>"u"||!navigator)return null;const r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:t}of r){const n=t.exec(navigator.userAgent);if(n){const s=n[1]||0,a=n[2]||0,i=n[3]||0;return{browser:e,version:`${s}.${a}.${i}`}}}return null}const Pn=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",In=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown");let En;const Hs=()=>En??(En=qs()),Vs=r=>{try{return JSON.parse(r)}catch{return}},Ks=/^[a-z][a-z0-9+.-]*:/i,Gs=r=>Ks.test(r),Be=r=>new Promise(e=>setTimeout(e,r)),vt=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${r} must be an integer`);if(e<0)throw new y(`${r} must be a positive integer`);return e},Bt=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null)try{return new Error(JSON.stringify(r))}catch{}return new Error(r)},He=r=>{var e,t,n,s;if(typeof process<"u")return((e=ye==null?void 0:ye[r])==null?void 0:e.trim())??void 0;if(typeof Deno<"u")return(s=(n=(t=Deno.env)==null?void 0:t.get)==null?void 0:n.call(t,r))==null?void 0:s.trim()};function br(r){if(!r)return!0;for(const e in r)return!1;return!0}function xr(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function $n(r,e){for(const t in e){if(!xr(e,t))continue;const n=t.toLowerCase();if(!n)continue;const s=e[t];s===null?delete r[n]:s!==void 0&&(r[n]=s)}}const On=new Set(["authorization","api-key"]);function we(r,...e){if(typeof process<"u"&&(ye==null?void 0:ye.DEBUG)==="true"){const t=e.map(n=>{if(!n)return n;if(n.headers){const a={...n,headers:{...n.headers}};for(const i in n.headers)On.has(i.toLowerCase())&&(a.headers[i]="REDACTED");return a}let s=null;for(const a in n)On.has(a.toLowerCase())&&(s??(s={...n}),s[a]="REDACTED");return s??n});console.log(`OpenAI:DEBUG:${r}`,...t)}}const Qs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),zs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u",Ys=r=>typeof(r==null?void 0:r.get)=="function",Ve=(r,e)=>{var n;const t=e.toLowerCase();if(Ys(r)){const s=((n=e[0])==null?void 0:n.toUpperCase())+e.substring(1).replace(/([^\w])(\w)/g,(a,i,l)=>i+l.toUpperCase());for(const a of[e,t,e.toUpperCase(),s]){const i=r.get(a);if(i)return i}}for(const[s,a]of Object.entries(r))if(s.toLowerCase()===t)return Array.isArray(a)?(a.length<=1||console.warn(`Received ${a.length} entries for the ${e} header, using the first entry.`),a[0]):a};function Rt(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}class Ht extends wr{constructor(e,t,n,s){super(e,t,n,s),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}}class W extends wr{constructor(e,t,n,s){super(e,t,n,s),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageParams(){const e=this.nextPageInfo();if(!e)return null;if("params"in e)return e.params;const t=Object.fromEntries(e.url.searchParams);return Object.keys(t).length?t:null}nextPageInfo(){var n;const e=this.getPaginatedItems();if(!e.length)return null;const t=(n=e[e.length-1])==null?void 0:n.id;return t?{params:{after:t}}:null}}class S{constructor(e){this._client=e}}let Sr=class extends S{list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/chat/completions/${e}/messages`,Zs,{query:t,...n})}},ft=class extends S{constructor(){super(...arguments),this.messages=new Sr(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(`/chat/completions/${e}`,t)}update(e,t,n){return this._client.post(`/chat/completions/${e}`,{body:t,...n})}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/chat/completions",mt,{query:e,...t})}del(e,t){return this._client.delete(`/chat/completions/${e}`,t)}};class mt extends W{}class Zs extends W{}ft.ChatCompletionsPage=mt;ft.Messages=Sr;let pt=class extends S{constructor(){super(...arguments),this.completions=new ft(this._client)}};pt.Completions=ft;pt.ChatCompletionsPage=mt;class Ar extends S{create(e,t){return this._client.post("/audio/speech",{body:e,...t,headers:{Accept:"application/octet-stream",...t==null?void 0:t.headers},__binaryResponse:!0})}}class Cr extends S{create(e,t){return this._client.post("/audio/transcriptions",Se({body:e,...t,__metadata:{model:e.model}}))}}class vr extends S{create(e,t){return this._client.post("/audio/translations",Se({body:e,...t,__metadata:{model:e.model}}))}}class Ne extends S{constructor(){super(...arguments),this.transcriptions=new Cr(this._client),this.translations=new vr(this._client),this.speech=new Ar(this._client)}}Ne.Transcriptions=Cr;Ne.Translations=vr;Ne.Speech=Ar;class Vt extends S{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(`/batches/${e}`,t)}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/batches",Kt,{query:e,...t})}cancel(e,t){return this._client.post(`/batches/${e}/cancel`,t)}}class Kt extends W{}Vt.BatchesPage=Kt;class Gt extends S{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}retrieve(e,t){return this._client.get(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}update(e,t,n){return this._client.post(`/assistants/${e}`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/assistants",Qt,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}del(e,t){return this._client.delete(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}}class Qt extends W{}Gt.AssistantsPage=Qt;function Tn(r){return typeof r.parse=="function"}const be=r=>(r==null?void 0:r.role)==="assistant",Rr=r=>(r==null?void 0:r.role)==="function",Pr=r=>(r==null?void 0:r.role)==="tool";var K=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},E=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Nt,Ze,et,Re,Pe,tt,Ie,ne,Ee,at,it,ge,Ir;class zt{constructor(){Nt.add(this),this.controller=new AbortController,Ze.set(this,void 0),et.set(this,()=>{}),Re.set(this,()=>{}),Pe.set(this,void 0),tt.set(this,()=>{}),Ie.set(this,()=>{}),ne.set(this,{}),Ee.set(this,!1),at.set(this,!1),it.set(this,!1),ge.set(this,!1),K(this,Ze,new Promise((e,t)=>{K(this,et,e,"f"),K(this,Re,t,"f")}),"f"),K(this,Pe,new Promise((e,t)=>{K(this,tt,e,"f"),K(this,Ie,t,"f")}),"f"),E(this,Ze,"f").catch(()=>{}),E(this,Pe,"f").catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit("end")},E(this,Nt,"m",Ir).bind(this))},0)}_connected(){this.ended||(E(this,et,"f").call(this),this._emit("connect"))}get ended(){return E(this,Ee,"f")}get errored(){return E(this,at,"f")}get aborted(){return E(this,it,"f")}abort(){this.controller.abort()}on(e,t){return(E(this,ne,"f")[e]||(E(this,ne,"f")[e]=[])).push({listener:t}),this}off(e,t){const n=E(this,ne,"f")[e];if(!n)return this;const s=n.findIndex(a=>a.listener===t);return s>=0&&n.splice(s,1),this}once(e,t){return(E(this,ne,"f")[e]||(E(this,ne,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{K(this,ge,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,t)})}async done(){K(this,ge,!0,"f"),await E(this,Pe,"f")}_emit(e,...t){if(E(this,Ee,"f"))return;e==="end"&&(K(this,Ee,!0,"f"),E(this,tt,"f").call(this));const n=E(this,ne,"f")[e];if(n&&(E(this,ne,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...t))),e==="abort"){const s=t[0];!E(this,ge,"f")&&!(n!=null&&n.length)&&Promise.reject(s),E(this,Re,"f").call(this,s),E(this,Ie,"f").call(this,s),this._emit("end");return}if(e==="error"){const s=t[0];!E(this,ge,"f")&&!(n!=null&&n.length)&&Promise.reject(s),E(this,Re,"f").call(this,s),E(this,Ie,"f").call(this,s),this._emit("end")}}_emitFinal(){}}Ze=new WeakMap,et=new WeakMap,Re=new WeakMap,Pe=new WeakMap,tt=new WeakMap,Ie=new WeakMap,ne=new WeakMap,Ee=new WeakMap,at=new WeakMap,it=new WeakMap,ge=new WeakMap,Nt=new WeakSet,Ir=function(e){if(K(this,at,!0,"f"),e instanceof Error&&e.name==="AbortError"&&(e=new V),e instanceof V)return K(this,it,!0,"f"),this._emit("abort",e);if(e instanceof y)return this._emit("error",e);if(e instanceof Error){const t=new y(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new y(String(e)))};function Yt(r){return(r==null?void 0:r.$brand)==="auto-parseable-response-format"}function De(r){return(r==null?void 0:r.$brand)==="auto-parseable-tool"}function ea(r,e){return!e||!Er(e)?{...r,choices:r.choices.map(t=>({...t,message:{...t.message,parsed:null,...t.message.tool_calls?{tool_calls:t.message.tool_calls}:void 0}}))}:Zt(r,e)}function Zt(r,e){const t=r.choices.map(n=>{var s;if(n.finish_reason==="length")throw new dr;if(n.finish_reason==="content_filter")throw new hr;return{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:((s=n.message.tool_calls)==null?void 0:s.map(a=>na(e,a)))??void 0}:void 0,parsed:n.message.content&&!n.message.refusal?ta(e,n.message.content):null}}});return{...r,choices:t}}function ta(r,e){var t,n;return((t=r.response_format)==null?void 0:t.type)!=="json_schema"?null:((n=r.response_format)==null?void 0:n.type)==="json_schema"?"$parseRaw"in r.response_format?r.response_format.$parseRaw(e):JSON.parse(e):null}function na(r,e){var n;const t=(n=r.tools)==null?void 0:n.find(s=>{var a;return((a=s.function)==null?void 0:a.name)===e.function.name});return{...e,function:{...e.function,parsed_arguments:De(t)?t.$parseRaw(e.function.arguments):t!=null&&t.function.strict?JSON.parse(e.function.arguments):null}}}function ra(r,e){var n;if(!r)return!1;const t=(n=r.tools)==null?void 0:n.find(s=>{var a;return((a=s.function)==null?void 0:a.name)===e.function.name});return De(t)||(t==null?void 0:t.function.strict)||!1}function Er(r){var e;return Yt(r.response_format)?!0:((e=r.tools)==null?void 0:e.some(t=>De(t)||t.type==="function"&&t.function.strict===!0))??!1}function sa(r){for(const e of r??[]){if(e.type!=="function")throw new y(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new y(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var U=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},L,Dt,ot,jt,Lt,Ut,$r,Wt;const kn=10;class Or extends zt{constructor(){super(...arguments),L.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){var n;this._chatCompletions.push(e),this._emit("chatCompletion",e);const t=(n=e.choices[0])==null?void 0:n.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t){if(this._emit("message",e),(Rr(e)||Pr(e))&&e.content)this._emit("functionCallResult",e.content);else if(be(e)&&e.function_call)this._emit("functionCall",e.function_call);else if(be(e)&&e.tool_calls)for(const n of e.tool_calls)n.type==="function"&&this._emit("functionCall",n.function)}}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new y("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),U(this,L,"m",Dt).call(this)}async finalMessage(){return await this.done(),U(this,L,"m",ot).call(this)}async finalFunctionCall(){return await this.done(),U(this,L,"m",jt).call(this)}async finalFunctionCallResult(){return await this.done(),U(this,L,"m",Lt).call(this)}async totalUsage(){return await this.done(),U(this,L,"m",Ut).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const t=U(this,L,"m",ot).call(this);t&&this._emit("finalMessage",t);const n=U(this,L,"m",Dt).call(this);n&&this._emit("finalContent",n);const s=U(this,L,"m",jt).call(this);s&&this._emit("finalFunctionCall",s);const a=U(this,L,"m",Lt).call(this);a!=null&&this._emit("finalFunctionCallResult",a),this._chatCompletions.some(i=>i.usage)&&this._emit("totalUsage",U(this,L,"m",Ut).call(this))}async _createChatCompletion(e,t,n){const s=n==null?void 0:n.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),U(this,L,"m",$r).call(this,t);const a=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Zt(a,t))}async _runChatCompletion(e,t,n){for(const s of t.messages)this._addMessage(s,!1);return await this._createChatCompletion(e,t,n)}async _runFunctions(e,t,n){var h;const s="function",{function_call:a="auto",stream:i,...l}=t,u=typeof a!="string"&&(a==null?void 0:a.name),{maxChatCompletions:d=kn}=n||{},o={};for(const f of t.functions)o[f.name||f.function.name]=f;const c=t.functions.map(f=>({name:f.name||f.function.name,parameters:f.parameters,description:f.description}));for(const f of t.messages)this._addMessage(f,!1);for(let f=0;f<d;++f){const g=(h=(await this._createChatCompletion(e,{...l,function_call:a,functions:c,messages:[...this.messages]},n)).choices[0])==null?void 0:h.message;if(!g)throw new y("missing message in ChatCompletion response");if(!g.function_call)return;const{name:_,arguments:N}=g.function_call,m=o[_];if(m){if(u&&u!==_){const v=`Invalid function_call: ${JSON.stringify(_)}. ${JSON.stringify(u)} requested. Please try again`;this._addMessage({role:s,name:_,content:v});continue}}else{const v=`Invalid function_call: ${JSON.stringify(_)}. Available options are: ${c.map(A=>JSON.stringify(A.name)).join(", ")}. Please try again`;this._addMessage({role:s,name:_,content:v});continue}let C;try{C=Tn(m)?await m.parse(N):N}catch(v){this._addMessage({role:s,name:_,content:v instanceof Error?v.message:String(v)});continue}const b=await m.function(C,this),O=U(this,L,"m",Wt).call(this,b);if(this._addMessage({role:s,name:_,content:O}),u)return}}async _runTools(e,t,n){var f,w,g;const s="tool",{tool_choice:a="auto",stream:i,...l}=t,u=typeof a!="string"&&((f=a==null?void 0:a.function)==null?void 0:f.name),{maxChatCompletions:d=kn}=n||{},o=t.tools.map(_=>{if(De(_)){if(!_.$callback)throw new y("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:_.$callback,name:_.function.name,description:_.function.description||"",parameters:_.function.parameters,parse:_.$parseRaw,strict:!0}}}return _}),c={};for(const _ of o)_.type==="function"&&(c[_.function.name||_.function.function.name]=_.function);const h="tools"in t?o.map(_=>_.type==="function"?{type:"function",function:{name:_.function.name||_.function.function.name,parameters:_.function.parameters,description:_.function.description,strict:_.function.strict}}:_):void 0;for(const _ of t.messages)this._addMessage(_,!1);for(let _=0;_<d;++_){const m=(w=(await this._createChatCompletion(e,{...l,tool_choice:a,tools:h,messages:[...this.messages]},n)).choices[0])==null?void 0:w.message;if(!m)throw new y("missing message in ChatCompletion response");if(!((g=m.tool_calls)!=null&&g.length))return;for(const C of m.tool_calls){if(C.type!=="function")continue;const b=C.id,{name:O,arguments:v}=C.function,A=c[O];if(A){if(u&&u!==O){const P=`Invalid tool_call: ${JSON.stringify(O)}. ${JSON.stringify(u)} requested. Please try again`;this._addMessage({role:s,tool_call_id:b,content:P});continue}}else{const P=`Invalid tool_call: ${JSON.stringify(O)}. Available options are: ${Object.keys(c).map(ue=>JSON.stringify(ue)).join(", ")}. Please try again`;this._addMessage({role:s,tool_call_id:b,content:P});continue}let H;try{H=Tn(A)?await A.parse(v):v}catch(P){const ue=P instanceof Error?P.message:String(P);this._addMessage({role:s,tool_call_id:b,content:ue});continue}const T=await A.function(H,this),$=U(this,L,"m",Wt).call(this,T);if(this._addMessage({role:s,tool_call_id:b,content:$}),u)return}}}}L=new WeakSet,Dt=function(){return U(this,L,"m",ot).call(this).content??null},ot=function(){let e=this.messages.length;for(;e-- >0;){const t=this.messages[e];if(be(t)){const{function_call:n,...s}=t,a={...s,content:t.content??null,refusal:t.refusal??null};return n&&(a.function_call=n),a}}throw new y("stream ended without producing a ChatCompletionMessage with role=assistant")},jt=function(){var e,t;for(let n=this.messages.length-1;n>=0;n--){const s=this.messages[n];if(be(s)&&(s!=null&&s.function_call))return s.function_call;if(be(s)&&((e=s==null?void 0:s.tool_calls)!=null&&e.length))return(t=s.tool_calls.at(-1))==null?void 0:t.function}},Lt=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(Rr(t)&&t.content!=null||Pr(t)&&t.content!=null&&typeof t.content=="string"&&this.messages.some(n=>{var s;return n.role==="assistant"&&((s=n.tool_calls)==null?void 0:s.some(a=>a.type==="function"&&a.id===t.tool_call_id))}))return t.content}},Ut=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},$r=function(e){if(e.n!=null&&e.n>1)throw new y("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},Wt=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};class Fe extends Or{static runFunctions(e,t,n){const s=new Fe,a={...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"runFunctions"}};return s._run(()=>s._runFunctions(e,t,a)),s}static runTools(e,t,n){const s=new Fe,a={...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"runTools"}};return s._run(()=>s._runTools(e,t,a)),s}_addMessage(e,t=!0){super._addMessage(e,t),be(e)&&e.content&&this._emit("content",e.content)}}const Tr=1,kr=2,Fr=4,Mr=8,Br=16,Nr=32,Dr=64,jr=128,Lr=256,Ur=jr|Lr,Wr=Br|Nr|Ur|Dr,Jr=Tr|kr|Wr,qr=Fr|Mr,aa=Jr|qr,M={STR:Tr,NUM:kr,ARR:Fr,OBJ:Mr,NULL:Br,BOOL:Nr,NAN:Dr,INFINITY:jr,MINUS_INFINITY:Lr,INF:Ur,SPECIAL:Wr,ATOM:Jr,COLLECTION:qr,ALL:aa};class ia extends Error{}class oa extends Error{}function la(r,e=M.ALL){if(typeof r!="string")throw new TypeError(`expecting str, got ${typeof r}`);if(!r.trim())throw new Error(`${r} is empty`);return ca(r.trim(),e)}const ca=(r,e)=>{const t=r.length;let n=0;const s=h=>{throw new ia(`${h} at position ${n}`)},a=h=>{throw new oa(`${h} at position ${n}`)},i=()=>(c(),n>=t&&s("Unexpected end of input"),r[n]==='"'?l():r[n]==="{"?u():r[n]==="["?d():r.substring(n,n+4)==="null"||M.NULL&e&&t-n<4&&"null".startsWith(r.substring(n))?(n+=4,null):r.substring(n,n+4)==="true"||M.BOOL&e&&t-n<4&&"true".startsWith(r.substring(n))?(n+=4,!0):r.substring(n,n+5)==="false"||M.BOOL&e&&t-n<5&&"false".startsWith(r.substring(n))?(n+=5,!1):r.substring(n,n+8)==="Infinity"||M.INFINITY&e&&t-n<8&&"Infinity".startsWith(r.substring(n))?(n+=8,1/0):r.substring(n,n+9)==="-Infinity"||M.MINUS_INFINITY&e&&1<t-n&&t-n<9&&"-Infinity".startsWith(r.substring(n))?(n+=9,-1/0):r.substring(n,n+3)==="NaN"||M.NAN&e&&t-n<3&&"NaN".startsWith(r.substring(n))?(n+=3,NaN):o()),l=()=>{const h=n;let f=!1;for(n++;n<t&&(r[n]!=='"'||f&&r[n-1]==="\\");)f=r[n]==="\\"?!f:!1,n++;if(r.charAt(n)=='"')try{return JSON.parse(r.substring(h,++n-Number(f)))}catch(w){a(String(w))}else if(M.STR&e)try{return JSON.parse(r.substring(h,n-Number(f))+'"')}catch{return JSON.parse(r.substring(h,r.lastIndexOf("\\"))+'"')}s("Unterminated string literal")},u=()=>{n++,c();const h={};try{for(;r[n]!=="}";){if(c(),n>=t&&M.OBJ&e)return h;const f=l();c(),n++;try{const w=i();Object.defineProperty(h,f,{value:w,writable:!0,enumerable:!0,configurable:!0})}catch(w){if(M.OBJ&e)return h;throw w}c(),r[n]===","&&n++}}catch{if(M.OBJ&e)return h;s("Expected '}' at end of object")}return n++,h},d=()=>{n++;const h=[];try{for(;r[n]!=="]";)h.push(i()),c(),r[n]===","&&n++}catch{if(M.ARR&e)return h;s("Expected ']' at end of array")}return n++,h},o=()=>{if(n===0){r==="-"&&M.NUM&e&&s("Not sure what '-' is");try{return JSON.parse(r)}catch(f){if(M.NUM&e)try{return r[r.length-1]==="."?JSON.parse(r.substring(0,r.lastIndexOf("."))):JSON.parse(r.substring(0,r.lastIndexOf("e")))}catch{}a(String(f))}}const h=n;for(r[n]==="-"&&n++;r[n]&&!",]}".includes(r[n]);)n++;n==t&&!(M.NUM&e)&&s("Unterminated number literal");try{return JSON.parse(r.substring(h,n))}catch{r.substring(h,n)==="-"&&M.NUM&e&&s("Not sure what '-' is");try{return JSON.parse(r.substring(h,r.lastIndexOf("e")))}catch(w){a(String(w))}}},c=()=>{for(;n<t&&`
|
|
6
|
+
\r `.includes(r[n]);)n++};return i()},Fn=r=>la(r,M.ALL^M.NUM);var de=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},R=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},k,te,he,re,Pt,Ke,It,Et,$t,Ge,Ot,Mn;class Me extends Or{constructor(e){super(),k.add(this),te.set(this,void 0),he.set(this,void 0),re.set(this,void 0),de(this,te,e,"f"),de(this,he,[],"f")}get currentChatCompletionSnapshot(){return R(this,re,"f")}static fromReadableStream(e){const t=new Me(null);return t._run(()=>t._fromReadableStream(e)),t}static createChatCompletion(e,t,n){const s=new Me(t);return s._run(()=>s._runChatCompletion(e,{...t,stream:!0},{...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"stream"}})),s}async _createChatCompletion(e,t,n){var i;super._createChatCompletion;const s=n==null?void 0:n.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),R(this,k,"m",Pt).call(this);const a=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(const l of a)R(this,k,"m",It).call(this,l);if((i=a.controller.signal)!=null&&i.aborted)throw new V;return this._addChatCompletion(R(this,k,"m",Ge).call(this))}async _fromReadableStream(e,t){var i;const n=t==null?void 0:t.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),R(this,k,"m",Pt).call(this),this._connected();const s=ee.fromReadableStream(e,this.controller);let a;for await(const l of s)a&&a!==l.id&&this._addChatCompletion(R(this,k,"m",Ge).call(this)),R(this,k,"m",It).call(this,l),a=l.id;if((i=s.controller.signal)!=null&&i.aborted)throw new V;return this._addChatCompletion(R(this,k,"m",Ge).call(this))}[(te=new WeakMap,he=new WeakMap,re=new WeakMap,k=new WeakSet,Pt=function(){this.ended||de(this,re,void 0,"f")},Ke=function(t){let n=R(this,he,"f")[t.index];return n||(n={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},R(this,he,"f")[t.index]=n,n)},It=function(t){var s,a,i,l,u,d,o,c,h,f,w,g,_,N,m;if(this.ended)return;const n=R(this,k,"m",Mn).call(this,t);this._emit("chunk",t,n);for(const C of t.choices){const b=n.choices[C.index];C.delta.content!=null&&((s=b.message)==null?void 0:s.role)==="assistant"&&((a=b.message)!=null&&a.content)&&(this._emit("content",C.delta.content,b.message.content),this._emit("content.delta",{delta:C.delta.content,snapshot:b.message.content,parsed:b.message.parsed})),C.delta.refusal!=null&&((i=b.message)==null?void 0:i.role)==="assistant"&&((l=b.message)!=null&&l.refusal)&&this._emit("refusal.delta",{delta:C.delta.refusal,snapshot:b.message.refusal}),((u=C.logprobs)==null?void 0:u.content)!=null&&((d=b.message)==null?void 0:d.role)==="assistant"&&this._emit("logprobs.content.delta",{content:(o=C.logprobs)==null?void 0:o.content,snapshot:((c=b.logprobs)==null?void 0:c.content)??[]}),((h=C.logprobs)==null?void 0:h.refusal)!=null&&((f=b.message)==null?void 0:f.role)==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:(w=C.logprobs)==null?void 0:w.refusal,snapshot:((g=b.logprobs)==null?void 0:g.refusal)??[]});const O=R(this,k,"m",Ke).call(this,b);b.finish_reason&&(R(this,k,"m",$t).call(this,b),O.current_tool_call_index!=null&&R(this,k,"m",Et).call(this,b,O.current_tool_call_index));for(const v of C.delta.tool_calls??[])O.current_tool_call_index!==v.index&&(R(this,k,"m",$t).call(this,b),O.current_tool_call_index!=null&&R(this,k,"m",Et).call(this,b,O.current_tool_call_index)),O.current_tool_call_index=v.index;for(const v of C.delta.tool_calls??[]){const A=(_=b.message.tool_calls)==null?void 0:_[v.index];A!=null&&A.type&&((A==null?void 0:A.type)==="function"?this._emit("tool_calls.function.arguments.delta",{name:(N=A.function)==null?void 0:N.name,index:v.index,arguments:A.function.arguments,parsed_arguments:A.function.parsed_arguments,arguments_delta:((m=v.function)==null?void 0:m.arguments)??""}):(A==null||A.type,void 0))}}},Et=function(t,n){var i,l,u;if(R(this,k,"m",Ke).call(this,t).done_tool_calls.has(n))return;const a=(i=t.message.tool_calls)==null?void 0:i[n];if(!a)throw new Error("no tool call snapshot");if(!a.type)throw new Error("tool call snapshot missing `type`");if(a.type==="function"){const d=(u=(l=R(this,te,"f"))==null?void 0:l.tools)==null?void 0:u.find(o=>o.type==="function"&&o.function.name===a.function.name);this._emit("tool_calls.function.arguments.done",{name:a.function.name,index:n,arguments:a.function.arguments,parsed_arguments:De(d)?d.$parseRaw(a.function.arguments):d!=null&&d.function.strict?JSON.parse(a.function.arguments):null})}else a.type},$t=function(t){var s,a;const n=R(this,k,"m",Ke).call(this,t);if(t.message.content&&!n.content_done){n.content_done=!0;const i=R(this,k,"m",Ot).call(this);this._emit("content.done",{content:t.message.content,parsed:i?i.$parseRaw(t.message.content):null})}t.message.refusal&&!n.refusal_done&&(n.refusal_done=!0,this._emit("refusal.done",{refusal:t.message.refusal})),(s=t.logprobs)!=null&&s.content&&!n.logprobs_content_done&&(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:t.logprobs.content})),(a=t.logprobs)!=null&&a.refusal&&!n.logprobs_refusal_done&&(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:t.logprobs.refusal}))},Ge=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");const t=R(this,re,"f");if(!t)throw new y("request ended without sending any chunks");return de(this,re,void 0,"f"),de(this,he,[],"f"),ua(t,R(this,te,"f"))},Ot=function(){var n;const t=(n=R(this,te,"f"))==null?void 0:n.response_format;return Yt(t)?t:null},Mn=function(t){var n,s,a,i;let l=R(this,re,"f");const{choices:u,...d}=t;l?Object.assign(l,d):l=de(this,re,{...d,choices:[]},"f");for(const{delta:o,finish_reason:c,index:h,logprobs:f=null,...w}of t.choices){let g=l.choices[h];if(g||(g=l.choices[h]={finish_reason:c,index:h,message:{},logprobs:f,...w}),f)if(!g.logprobs)g.logprobs=Object.assign({},f);else{const{content:v,refusal:A,...H}=f;Object.assign(g.logprobs,H),v&&((n=g.logprobs).content??(n.content=[]),g.logprobs.content.push(...v)),A&&((s=g.logprobs).refusal??(s.refusal=[]),g.logprobs.refusal.push(...A))}if(c&&(g.finish_reason=c,R(this,te,"f")&&Er(R(this,te,"f")))){if(c==="length")throw new dr;if(c==="content_filter")throw new hr}if(Object.assign(g,w),!o)continue;const{content:_,refusal:N,function_call:m,role:C,tool_calls:b,...O}=o;if(Object.assign(g.message,O),N&&(g.message.refusal=(g.message.refusal||"")+N),C&&(g.message.role=C),m&&(g.message.function_call?(m.name&&(g.message.function_call.name=m.name),m.arguments&&((a=g.message.function_call).arguments??(a.arguments=""),g.message.function_call.arguments+=m.arguments)):g.message.function_call=m),_&&(g.message.content=(g.message.content||"")+_,!g.message.refusal&&R(this,k,"m",Ot).call(this)&&(g.message.parsed=Fn(g.message.content))),b){g.message.tool_calls||(g.message.tool_calls=[]);for(const{index:v,id:A,type:H,function:T,...$}of b){const P=(i=g.message.tool_calls)[v]??(i[v]={});Object.assign(P,$),A&&(P.id=A),H&&(P.type=H),T&&(P.function??(P.function={name:T.name??"",arguments:""})),T!=null&&T.name&&(P.function.name=T.name),T!=null&&T.arguments&&(P.function.arguments+=T.arguments,ra(R(this,te,"f"),P)&&(P.function.parsed_arguments=Fn(P.function.arguments)))}}}return l},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("chunk",s=>{const a=t.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(const s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),this.on("error",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((a,i)=>t.push({resolve:a,reject:i})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new ee(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function ua(r,e){const{id:t,choices:n,created:s,model:a,system_fingerprint:i,...l}=r,u={...l,id:t,choices:n.map(({message:d,finish_reason:o,index:c,logprobs:h,...f})=>{if(!o)throw new y(`missing finish_reason for choice ${c}`);const{content:w=null,function_call:g,tool_calls:_,...N}=d,m=d.role;if(!m)throw new y(`missing role for choice ${c}`);if(g){const{arguments:C,name:b}=g;if(C==null)throw new y(`missing function_call.arguments for choice ${c}`);if(!b)throw new y(`missing function_call.name for choice ${c}`);return{...f,message:{content:w,function_call:{arguments:C,name:b},role:m,refusal:d.refusal??null},finish_reason:o,index:c,logprobs:h}}return _?{...f,index:c,finish_reason:o,logprobs:h,message:{...N,role:m,content:w,refusal:d.refusal??null,tool_calls:_.map((C,b)=>{const{function:O,type:v,id:A,...H}=C,{arguments:T,name:$,...P}=O||{};if(A==null)throw new y(`missing choices[${c}].tool_calls[${b}].id
|
|
7
|
+
${Qe(r)}`);if(v==null)throw new y(`missing choices[${c}].tool_calls[${b}].type
|
|
8
|
+
${Qe(r)}`);if($==null)throw new y(`missing choices[${c}].tool_calls[${b}].function.name
|
|
9
|
+
${Qe(r)}`);if(T==null)throw new y(`missing choices[${c}].tool_calls[${b}].function.arguments
|
|
10
|
+
${Qe(r)}`);return{...H,id:A,type:v,function:{...P,name:$,arguments:T}}})}}:{...f,message:{...N,content:w,role:m,refusal:d.refusal??null},finish_reason:o,index:c,logprobs:h}}),created:s,model:a,object:"chat.completion",...i?{system_fingerprint:i}:{}};return ea(u,e)}function Qe(r){return JSON.stringify(r)}class xe extends Me{static fromReadableStream(e){const t=new xe(null);return t._run(()=>t._fromReadableStream(e)),t}static runFunctions(e,t,n){const s=new xe(null),a={...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"runFunctions"}};return s._run(()=>s._runFunctions(e,t,a)),s}static runTools(e,t,n){const s=new xe(t),a={...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"runTools"}};return s._run(()=>s._runTools(e,t,a)),s}}let Xr=class extends S{parse(e,t){return sa(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t==null?void 0:t.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap(n=>Zt(n,e))}runFunctions(e,t){return e.stream?xe.runFunctions(this._client,e,t):Fe.runFunctions(this._client,e,t)}runTools(e,t){return e.stream?xe.runTools(this._client,e,t):Fe.runTools(this._client,e,t)}stream(e,t){return Me.createChatCompletion(this._client,e,t)}};class Jt extends S{constructor(){super(...arguments),this.completions=new Xr(this._client)}}(function(r){r.Completions=Xr})(Jt||(Jt={}));class Hr extends S{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}}class Vr extends S{create(e,t){return this._client.post("/realtime/transcription_sessions",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}}class gt extends S{constructor(){super(...arguments),this.sessions=new Hr(this._client),this.transcriptionSessions=new Vr(this._client)}}gt.Sessions=Hr;gt.TranscriptionSessions=Vr;var p=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},J=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},D,qt,Z,nt,G,ce,_e,le,lt,X,rt,st,ke,$e,Oe,Bn,Nn,Dn,jn,Ln,Un,Wn;class Q extends zt{constructor(){super(...arguments),D.add(this),qt.set(this,[]),Z.set(this,{}),nt.set(this,{}),G.set(this,void 0),ce.set(this,void 0),_e.set(this,void 0),le.set(this,void 0),lt.set(this,void 0),X.set(this,void 0),rt.set(this,void 0),st.set(this,void 0),ke.set(this,void 0)}[(qt=new WeakMap,Z=new WeakMap,nt=new WeakMap,G=new WeakMap,ce=new WeakMap,_e=new WeakMap,le=new WeakMap,lt=new WeakMap,X=new WeakMap,rt=new WeakMap,st=new WeakMap,ke=new WeakMap,D=new WeakSet,Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",s=>{const a=t.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(const s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),this.on("error",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((a,i)=>t.push({resolve:a,reject:i})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const t=new Q;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){var a;const n=t==null?void 0:t.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();const s=ee.fromReadableStream(e,this.controller);for await(const i of s)p(this,D,"m",$e).call(this,i);if((a=s.controller.signal)!=null&&a.aborted)throw new V;return this._addRun(p(this,D,"m",Oe).call(this))}toReadableStream(){return new ee(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,s,a){const i=new Q;return i._run(()=>i._runToolAssistantStream(e,t,n,s,{...a,headers:{...a==null?void 0:a.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createToolAssistantStream(e,t,n,s,a){var d;const i=a==null?void 0:a.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const l={...s,stream:!0},u=await e.submitToolOutputs(t,n,l,{...a,signal:this.controller.signal});this._connected();for await(const o of u)p(this,D,"m",$e).call(this,o);if((d=u.controller.signal)!=null&&d.aborted)throw new V;return this._addRun(p(this,D,"m",Oe).call(this))}static createThreadAssistantStream(e,t,n){const s=new Q;return s._run(()=>s._threadAssistantStream(e,t,{...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"stream"}})),s}static createAssistantStream(e,t,n,s){const a=new Q;return a._run(()=>a._runAssistantStream(e,t,n,{...s,headers:{...s==null?void 0:s.headers,"X-Stainless-Helper-Method":"stream"}})),a}currentEvent(){return p(this,rt,"f")}currentRun(){return p(this,st,"f")}currentMessageSnapshot(){return p(this,G,"f")}currentRunStepSnapshot(){return p(this,ke,"f")}async finalRunSteps(){return await this.done(),Object.values(p(this,Z,"f"))}async finalMessages(){return await this.done(),Object.values(p(this,nt,"f"))}async finalRun(){if(await this.done(),!p(this,ce,"f"))throw Error("Final run was not received.");return p(this,ce,"f")}async _createThreadAssistantStream(e,t,n){var l;const s=n==null?void 0:n.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort()));const a={...t,stream:!0},i=await e.createAndRun(a,{...n,signal:this.controller.signal});this._connected();for await(const u of i)p(this,D,"m",$e).call(this,u);if((l=i.controller.signal)!=null&&l.aborted)throw new V;return this._addRun(p(this,D,"m",Oe).call(this))}async _createAssistantStream(e,t,n,s){var u;const a=s==null?void 0:s.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},l=await e.create(t,i,{...s,signal:this.controller.signal});this._connected();for await(const d of l)p(this,D,"m",$e).call(this,d);if((u=l.controller.signal)!=null&&u.aborted)throw new V;return this._addRun(p(this,D,"m",Oe).call(this))}static accumulateDelta(e,t){for(const[n,s]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=s;continue}let a=e[n];if(a==null){e[n]=s;continue}if(n==="index"||n==="type"){e[n]=s;continue}if(typeof a=="string"&&typeof s=="string")a+=s;else if(typeof a=="number"&&typeof s=="number")a+=s;else if(Rt(a)&&Rt(s))a=this.accumulateDelta(a,s);else if(Array.isArray(a)&&Array.isArray(s)){if(a.every(i=>typeof i=="string"||typeof i=="number")){a.push(...s);continue}for(const i of s){if(!Rt(i))throw new Error(`Expected array delta entry to be an object but got: ${i}`);const l=i.index;if(l==null)throw console.error(i),new Error("Expected array delta entry to have an `index` property");if(typeof l!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${l}`);const u=a[l];u==null?a.push(i):a[l]=this.accumulateDelta(u,i)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${s}, accValue: ${a}`);e[n]=a}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,s){return await this._createAssistantStream(t,e,n,s)}async _runToolAssistantStream(e,t,n,s,a){return await this._createToolAssistantStream(n,e,t,s,a)}}$e=function(e){if(!this.ended)switch(J(this,rt,e,"f"),p(this,D,"m",Dn).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":p(this,D,"m",Wn).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":p(this,D,"m",Nn).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":p(this,D,"m",Bn).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},Oe=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");if(!p(this,ce,"f"))throw Error("Final run has not been received");return p(this,ce,"f")},Bn=function(e){const[t,n]=p(this,D,"m",Ln).call(this,e,p(this,G,"f"));J(this,G,t,"f"),p(this,nt,"f")[t.id]=t;for(const s of n){const a=t.content[s.index];(a==null?void 0:a.type)=="text"&&this._emit("textCreated",a.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(const s of e.data.delta.content){if(s.type=="text"&&s.text){let a=s.text,i=t.content[s.index];if(i&&i.type=="text")this._emit("textDelta",a,i.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(s.index!=p(this,_e,"f")){if(p(this,le,"f"))switch(p(this,le,"f").type){case"text":this._emit("textDone",p(this,le,"f").text,p(this,G,"f"));break;case"image_file":this._emit("imageFileDone",p(this,le,"f").image_file,p(this,G,"f"));break}J(this,_e,s.index,"f")}J(this,le,t.content[s.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(p(this,_e,"f")!==void 0){const s=e.data.content[p(this,_e,"f")];if(s)switch(s.type){case"image_file":this._emit("imageFileDone",s.image_file,p(this,G,"f"));break;case"text":this._emit("textDone",s.text,p(this,G,"f"));break}}p(this,G,"f")&&this._emit("messageDone",e.data),J(this,G,void 0,"f")}},Nn=function(e){const t=p(this,D,"m",jn).call(this,e);switch(J(this,ke,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const n=e.data.delta;if(n.step_details&&n.step_details.type=="tool_calls"&&n.step_details.tool_calls&&t.step_details.type=="tool_calls")for(const a of n.step_details.tool_calls)a.index==p(this,lt,"f")?this._emit("toolCallDelta",a,t.step_details.tool_calls[a.index]):(p(this,X,"f")&&this._emit("toolCallDone",p(this,X,"f")),J(this,lt,a.index,"f"),J(this,X,t.step_details.tool_calls[a.index],"f"),p(this,X,"f")&&this._emit("toolCallCreated",p(this,X,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":J(this,ke,void 0,"f"),e.data.step_details.type=="tool_calls"&&p(this,X,"f")&&(this._emit("toolCallDone",p(this,X,"f")),J(this,X,void 0,"f")),this._emit("runStepDone",e.data,t);break}},Dn=function(e){p(this,qt,"f").push(e),this._emit("event",e)},jn=function(e){switch(e.event){case"thread.run.step.created":return p(this,Z,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=p(this,Z,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){const s=Q.accumulateDelta(t,n.delta);p(this,Z,"f")[e.data.id]=s}return p(this,Z,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":p(this,Z,"f")[e.data.id]=e.data;break}if(p(this,Z,"f")[e.data.id])return p(this,Z,"f")[e.data.id];throw new Error("No snapshot available")},Ln=function(e,t){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let s=e.data;if(s.delta.content)for(const a of s.delta.content)if(a.index in t.content){let i=t.content[a.index];t.content[a.index]=p(this,D,"m",Un).call(this,a,i)}else t.content[a.index]=a,n.push(a);return[t,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},Un=function(e,t){return Q.accumulateDelta(t,e)},Wn=function(e){switch(J(this,st,e.data,"f"),e.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":J(this,ce,e.data,"f"),p(this,X,"f")&&(this._emit("toolCallDone",p(this,X,"f")),J(this,X,void 0,"f"));break}};class en extends S{create(e,t,n){return this._client.post(`/threads/${e}/messages`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}retrieve(e,t,n){return this._client.get(`/threads/${e}/messages/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}update(e,t,n,s){return this._client.post(`/threads/${e}/messages/${t}`,{body:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers}})}list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/messages`,tn,{query:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}del(e,t,n){return this._client.delete(`/threads/${e}/messages/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}}class tn extends W{}en.MessagesPage=tn;class nn extends S{retrieve(e,t,n,s={},a){return B(s)?this.retrieve(e,t,n,{},s):this._client.get(`/threads/${e}/runs/${t}/steps/${n}`,{query:s,...a,headers:{"OpenAI-Beta":"assistants=v2",...a==null?void 0:a.headers}})}list(e,t,n={},s){return B(n)?this.list(e,t,{},n):this._client.getAPIList(`/threads/${e}/runs/${t}/steps`,rn,{query:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers}})}}class rn extends W{}nn.RunStepsPage=rn;class je extends S{constructor(){super(...arguments),this.steps=new nn(this._client)}create(e,t,n){const{include:s,...a}=t;return this._client.post(`/threads/${e}/runs`,{query:{include:s},body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers},stream:t.stream??!1})}retrieve(e,t,n){return this._client.get(`/threads/${e}/runs/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}update(e,t,n,s){return this._client.post(`/threads/${e}/runs/${t}`,{body:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers}})}list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/runs`,sn,{query:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}cancel(e,t,n){return this._client.post(`/threads/${e}/runs/${t}/cancel`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}async createAndPoll(e,t,n){const s=await this.create(e,t,n);return await this.poll(e,s.id,n)}createAndStream(e,t,n){return Q.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){const s={...n==null?void 0:n.headers,"X-Stainless-Poll-Helper":"true"};for(n!=null&&n.pollIntervalMs&&(s["X-Stainless-Custom-Poll-Interval"]=n.pollIntervalMs.toString());;){const{data:a,response:i}=await this.retrieve(e,t,{...n,headers:{...n==null?void 0:n.headers,...s}}).withResponse();switch(a.status){case"queued":case"in_progress":case"cancelling":let l=5e3;if(n!=null&&n.pollIntervalMs)l=n.pollIntervalMs;else{const u=i.headers.get("openai-poll-after-ms");if(u){const d=parseInt(u);isNaN(d)||(l=d)}}await Be(l);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return a}}}stream(e,t,n){return Q.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n,s){return this._client.post(`/threads/${e}/runs/${t}/submit_tool_outputs`,{body:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers},stream:n.stream??!1})}async submitToolOutputsAndPoll(e,t,n,s){const a=await this.submitToolOutputs(e,t,n,s);return await this.poll(e,a.id,s)}submitToolOutputsStream(e,t,n,s){return Q.createToolAssistantStream(e,t,this._client.beta.threads.runs,n,s)}}class sn extends W{}je.RunsPage=sn;je.Steps=nn;je.RunStepsPage=rn;class Ae extends S{constructor(){super(...arguments),this.runs=new je(this._client),this.messages=new en(this._client)}create(e={},t){return B(e)?this.create({},e):this._client.post("/threads",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}retrieve(e,t){return this._client.get(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}update(e,t,n){return this._client.post(`/threads/${e}`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}del(e,t){return this._client.delete(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers},stream:e.stream??!1})}async createAndRunPoll(e,t){const n=await this.createAndRun(e,t);return await this.runs.poll(n.thread_id,n.id,t)}createAndRunStream(e,t){return Q.createThreadAssistantStream(e,this._client.beta.threads,t)}}Ae.Runs=je;Ae.RunsPage=sn;Ae.Messages=en;Ae.MessagesPage=tn;class Ce extends S{constructor(){super(...arguments),this.realtime=new gt(this._client),this.chat=new Jt(this._client),this.assistants=new Gt(this._client),this.threads=new Ae(this._client)}}Ce.Realtime=gt;Ce.Assistants=Gt;Ce.AssistantsPage=Qt;Ce.Threads=Ae;class Kr extends S{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}class Gr extends S{create(e,t){return this._client.post("/embeddings",{body:e,...t})}}let an=class extends S{create(e,t){return this._client.post("/files",Se({body:e,...t}))}retrieve(e,t){return this._client.get(`/files/${e}`,t)}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/files",on,{query:e,...t})}del(e,t){return this._client.delete(`/files/${e}`,t)}content(e,t){return this._client.get(`/files/${e}/content`,{...t,headers:{Accept:"application/binary",...t==null?void 0:t.headers},__binaryResponse:!0})}retrieveContent(e,t){return this._client.get(`/files/${e}/content`,t)}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=30*60*1e3}={}){const s=new Set(["processed","error","deleted"]),a=Date.now();let i=await this.retrieve(e);for(;!i.status||!s.has(i.status);)if(await Be(t),i=await this.retrieve(e),Date.now()-a>n)throw new Xt({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return i}};class on extends W{}an.FileObjectsPage=on;class ln extends S{list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/checkpoints`,cn,{query:t,...n})}}class cn extends W{}ln.FineTuningJobCheckpointsPage=cn;class ve extends S{constructor(){super(...arguments),this.checkpoints=new ln(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(`/fine_tuning/jobs/${e}`,t)}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/fine_tuning/jobs",un,{query:e,...t})}cancel(e,t){return this._client.post(`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},n){return B(t)?this.listEvents(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/events`,dn,{query:t,...n})}}class un extends W{}class dn extends W{}ve.FineTuningJobsPage=un;ve.FineTuningJobEventsPage=dn;ve.Checkpoints=ln;ve.FineTuningJobCheckpointsPage=cn;class Le extends S{constructor(){super(...arguments),this.jobs=new ve(this._client)}}Le.Jobs=ve;Le.FineTuningJobsPage=un;Le.FineTuningJobEventsPage=dn;class Qr extends S{createVariation(e,t){return this._client.post("/images/variations",Se({body:e,...t}))}edit(e,t){return this._client.post("/images/edits",Se({body:e,...t}))}generate(e,t){return this._client.post("/images/generations",{body:e,...t})}}class hn extends S{retrieve(e,t){return this._client.get(`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",fn,e)}del(e,t){return this._client.delete(`/models/${e}`,t)}}class fn extends Ht{}hn.ModelsPage=fn;class zr extends S{create(e,t){return this._client.post("/moderations",{body:e,...t})}}function da(r,e){return!e||!fa(e)?{...r,output_parsed:null,output:r.output.map(t=>t.type==="function_call"?{...t,parsed_arguments:null}:t.type==="message"?{...t,content:t.content.map(n=>({...n,parsed:null}))}:t)}:Yr(r,e)}function Yr(r,e){const t=r.output.map(s=>{if(s.type==="function_call")return{...s,parsed_arguments:ga(e,s)};if(s.type==="message"){const a=s.content.map(i=>i.type==="output_text"?{...i,parsed:ha(e,i.text)}:i);return{...s,content:a}}return s}),n=Object.assign({},r,{output:t});return Object.getOwnPropertyDescriptor(r,"output_text")||Zr(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(const s of n.output)if(s.type==="message"){for(const a of s.content)if(a.type==="output_text"&&a.parsed!==null)return a.parsed}return null}}),n}function ha(r,e){var t,n,s,a;return((n=(t=r.text)==null?void 0:t.format)==null?void 0:n.type)!=="json_schema"?null:"$parseRaw"in((s=r.text)==null?void 0:s.format)?((a=r.text)==null?void 0:a.format).$parseRaw(e):JSON.parse(e)}function fa(r){var e;return!!Yt((e=r.text)==null?void 0:e.format)}function ma(r){return(r==null?void 0:r.$brand)==="auto-parseable-tool"}function pa(r,e){return r.find(t=>t.type==="function"&&t.name===e)}function ga(r,e){const t=pa(r.tools??[],e.name);return{...e,...e,parsed_arguments:ma(t)?t.$parseRaw(e.arguments):t!=null&&t.strict?JSON.parse(e.arguments):null}}function Zr(r){const e=[];for(const t of r.output)if(t.type==="message")for(const n of t.content)n.type==="output_text"&&e.push(n.text);r.output_text=e.join("")}class es extends S{list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/responses/${e}/input_items`,ya,{query:t,...n})}}var fe=function(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t},se=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},me,ze,ae,Ye,Jn,qn,Xn,Hn;class mn extends zt{constructor(e){super(),me.add(this),ze.set(this,void 0),ae.set(this,void 0),Ye.set(this,void 0),fe(this,ze,e,"f")}static createResponse(e,t,n){const s=new mn(t);return s._run(()=>s._createResponse(e,t,{...n,headers:{...n==null?void 0:n.headers,"X-Stainless-Helper-Method":"stream"}})),s}async _createResponse(e,t,n){var i;const s=n==null?void 0:n.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),se(this,me,"m",Jn).call(this);const a=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(const l of a)se(this,me,"m",qn).call(this,l);if((i=a.controller.signal)!=null&&i.aborted)throw new V;return se(this,me,"m",Xn).call(this)}[(ze=new WeakMap,ae=new WeakMap,Ye=new WeakMap,me=new WeakSet,Jn=function(){this.ended||fe(this,ae,void 0,"f")},qn=function(t){if(this.ended)return;const n=se(this,me,"m",Hn).call(this,t);switch(this._emit("event",t),t.type){case"response.output_text.delta":{const s=n.output[t.output_index];if(!s)throw new y(`missing output at index ${t.output_index}`);if(s.type==="message"){const a=s.content[t.content_index];if(!a)throw new y(`missing content at index ${t.content_index}`);if(a.type!=="output_text")throw new y(`expected content to be 'output_text', got ${a.type}`);this._emit("response.output_text.delta",{...t,snapshot:a.text})}break}case"response.function_call_arguments.delta":{const s=n.output[t.output_index];if(!s)throw new y(`missing output at index ${t.output_index}`);s.type==="function_call"&&this._emit("response.function_call_arguments.delta",{...t,snapshot:s.arguments});break}default:this._emit(t.type,t);break}},Xn=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");const t=se(this,ae,"f");if(!t)throw new y("request ended without sending any events");fe(this,ae,void 0,"f");const n=_a(t,se(this,ze,"f"));return fe(this,Ye,n,"f"),n},Hn=function(t){let n=se(this,ae,"f");if(!n){if(t.type!=="response.created")throw new y(`When snapshot hasn't been set yet, expected 'response.created' event, got ${t.type}`);return n=fe(this,ae,t.response,"f"),n}switch(t.type){case"response.output_item.added":{n.output.push(t.item);break}case"response.content_part.added":{const s=n.output[t.output_index];if(!s)throw new y(`missing output at index ${t.output_index}`);s.type==="message"&&s.content.push(t.part);break}case"response.output_text.delta":{const s=n.output[t.output_index];if(!s)throw new y(`missing output at index ${t.output_index}`);if(s.type==="message"){const a=s.content[t.content_index];if(!a)throw new y(`missing content at index ${t.content_index}`);if(a.type!=="output_text")throw new y(`expected content to be 'output_text', got ${a.type}`);a.text+=t.delta}break}case"response.function_call_arguments.delta":{const s=n.output[t.output_index];if(!s)throw new y(`missing output at index ${t.output_index}`);s.type==="function_call"&&(s.arguments+=t.delta);break}case"response.completed":{fe(this,ae,t.response,"f");break}}return n},Symbol.asyncIterator)](){const e=[],t=[];let n=!1;return this.on("event",s=>{const a=t.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(const s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),this.on("error",s=>{n=!0;for(const a of t)a.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((a,i)=>t.push({resolve:a,reject:i})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();const e=se(this,Ye,"f");if(!e)throw new y("stream ended without producing a ChatCompletion");return e}}function _a(r,e){return da(r,e)}class pn extends S{constructor(){super(...arguments),this.inputItems=new es(this._client)}create(e,t){return this._client.post("/responses",{body:e,...t,stream:e.stream??!1})._thenUnwrap(n=>("object"in n&&n.object==="response"&&Zr(n),n))}retrieve(e,t={},n){return B(t)?this.retrieve(e,{},t):this._client.get(`/responses/${e}`,{query:t,...n})}del(e,t){return this._client.delete(`/responses/${e}`,{...t,headers:{Accept:"*/*",...t==null?void 0:t.headers}})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(n=>Yr(n,e))}stream(e,t){return mn.createResponse(this._client,e,t)}}class ya extends W{}pn.InputItems=es;class ts extends S{create(e,t,n){return this._client.post(`/uploads/${e}/parts`,Se({body:t,...n}))}}class gn extends S{constructor(){super(...arguments),this.parts=new ts(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(`/uploads/${e}/cancel`,t)}complete(e,t,n){return this._client.post(`/uploads/${e}/complete`,{body:t,...n})}}gn.Parts=ts;const wa=async r=>{const e=await Promise.allSettled(r),t=e.filter(s=>s.status==="rejected");if(t.length){for(const s of t)console.error(s.reason);throw new Error(`${t.length} promise(s) failed - see the above errors`)}const n=[];for(const s of e)s.status==="fulfilled"&&n.push(s.value);return n};class _t extends S{create(e,t,n){return this._client.post(`/vector_stores/${e}/files`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}retrieve(e,t,n){return this._client.get(`/vector_stores/${e}/files/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}update(e,t,n,s){return this._client.post(`/vector_stores/${e}/files/${t}`,{body:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers}})}list(e,t={},n){return B(t)?this.list(e,{},t):this._client.getAPIList(`/vector_stores/${e}/files`,yt,{query:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}del(e,t,n){return this._client.delete(`/vector_stores/${e}/files/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}async createAndPoll(e,t,n){const s=await this.create(e,t,n);return await this.poll(e,s.id,n)}async poll(e,t,n){const s={...n==null?void 0:n.headers,"X-Stainless-Poll-Helper":"true"};for(n!=null&&n.pollIntervalMs&&(s["X-Stainless-Custom-Poll-Interval"]=n.pollIntervalMs.toString());;){const a=await this.retrieve(e,t,{...n,headers:s}).withResponse(),i=a.data;switch(i.status){case"in_progress":let l=5e3;if(n!=null&&n.pollIntervalMs)l=n.pollIntervalMs;else{const u=a.response.headers.get("openai-poll-after-ms");if(u){const d=parseInt(u);isNaN(d)||(l=d)}}await Be(l);break;case"failed":case"completed":return i}}}async upload(e,t,n){const s=await this._client.files.create({file:t,purpose:"assistants"},n);return this.create(e,{file_id:s.id},n)}async uploadAndPoll(e,t,n){const s=await this.upload(e,t,n);return await this.poll(e,s.id,n)}content(e,t,n){return this._client.getAPIList(`/vector_stores/${e}/files/${t}/content`,_n,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}}class yt extends W{}class _n extends Ht{}_t.VectorStoreFilesPage=yt;_t.FileContentResponsesPage=_n;class ns extends S{create(e,t,n){return this._client.post(`/vector_stores/${e}/file_batches`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}retrieve(e,t,n){return this._client.get(`/vector_stores/${e}/file_batches/${t}`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}cancel(e,t,n){return this._client.post(`/vector_stores/${e}/file_batches/${t}/cancel`,{...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}async createAndPoll(e,t,n){const s=await this.create(e,t);return await this.poll(e,s.id,n)}listFiles(e,t,n={},s){return B(n)?this.listFiles(e,t,{},n):this._client.getAPIList(`/vector_stores/${e}/file_batches/${t}/files`,yt,{query:n,...s,headers:{"OpenAI-Beta":"assistants=v2",...s==null?void 0:s.headers}})}async poll(e,t,n){const s={...n==null?void 0:n.headers,"X-Stainless-Poll-Helper":"true"};for(n!=null&&n.pollIntervalMs&&(s["X-Stainless-Custom-Poll-Interval"]=n.pollIntervalMs.toString());;){const{data:a,response:i}=await this.retrieve(e,t,{...n,headers:s}).withResponse();switch(a.status){case"in_progress":let l=5e3;if(n!=null&&n.pollIntervalMs)l=n.pollIntervalMs;else{const u=i.headers.get("openai-poll-after-ms");if(u){const d=parseInt(u);isNaN(d)||(l=d)}}await Be(l);break;case"failed":case"cancelled":case"completed":return a}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},s){if(t==null||t.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const a=(s==null?void 0:s.maxConcurrency)??5,i=Math.min(a,t.length),l=this._client,u=t.values(),d=[...n];async function o(h){for(let f of h){const w=await l.files.create({file:f,purpose:"assistants"},s);d.push(w.id)}}const c=Array(i).fill(u).map(o);return await wa(c),await this.createAndPoll(e,{file_ids:d})}}class ie extends S{constructor(){super(...arguments),this.files=new _t(this._client),this.fileBatches=new ns(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}retrieve(e,t){return this._client.get(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}update(e,t,n){return this._client.post(`/vector_stores/${e}`,{body:t,...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}list(e={},t){return B(e)?this.list({},e):this._client.getAPIList("/vector_stores",yn,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}del(e,t){return this._client.delete(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t==null?void 0:t.headers}})}search(e,t,n){return this._client.getAPIList(`/vector_stores/${e}/search`,wn,{body:t,method:"post",...n,headers:{"OpenAI-Beta":"assistants=v2",...n==null?void 0:n.headers}})}}class yn extends W{}class wn extends Ht{}ie.VectorStoresPage=yn;ie.VectorStoreSearchResponsesPage=wn;ie.Files=_t;ie.VectorStoreFilesPage=yt;ie.FileContentResponsesPage=_n;ie.FileBatches=ns;var rs;class x extends Ls{constructor({baseURL:e=He("OPENAI_BASE_URL"),apiKey:t=He("OPENAI_API_KEY"),organization:n=He("OPENAI_ORG_ID")??null,project:s=He("OPENAI_PROJECT_ID")??null,...a}={}){if(t===void 0)throw new y("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");const i={apiKey:t,organization:n,project:s,...a,baseURL:e||"https://api.openai.com/v1"};if(!i.dangerouslyAllowBrowser&&zs())throw new y(`It looks like you're running in a browser-like environment.
|
|
11
|
+
|
|
12
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
13
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
14
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
15
|
+
|
|
16
|
+
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
17
|
+
|
|
18
|
+
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
19
|
+
`);super({baseURL:i.baseURL,timeout:i.timeout??6e5,httpAgent:i.httpAgent,maxRetries:i.maxRetries,fetch:i.fetch}),this.completions=new Kr(this),this.chat=new pt(this),this.embeddings=new Gr(this),this.files=new an(this),this.images=new Qr(this),this.audio=new Ne(this),this.moderations=new zr(this),this.models=new hn(this),this.fineTuning=new Le(this),this.vectorStores=new ie(this),this.beta=new Ce(this),this.batches=new Vt(this),this.uploads=new gn(this),this.responses=new pn(this),this._options=i,this.apiKey=t,this.organization=n,this.project=s}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return Ss(e,{arrayFormat:"brackets"})}}rs=x;x.OpenAI=rs;x.DEFAULT_TIMEOUT=6e5;x.OpenAIError=y;x.APIError=j;x.APIConnectionError=ct;x.APIConnectionTimeoutError=Xt;x.APIUserAbortError=V;x.NotFoundError=ir;x.ConflictError=or;x.RateLimitError=cr;x.BadRequestError=rr;x.AuthenticationError=sr;x.InternalServerError=ur;x.PermissionDeniedError=ar;x.UnprocessableEntityError=lr;x.toFile=gr;x.fileFromPath=tr;x.Completions=Kr;x.Chat=pt;x.ChatCompletionsPage=mt;x.Embeddings=Gr;x.Files=an;x.FileObjectsPage=on;x.Images=Qr;x.Audio=Ne;x.Moderations=zr;x.Models=hn;x.ModelsPage=fn;x.FineTuning=Le;x.VectorStores=ie;x.VectorStoresPage=yn;x.VectorStoreSearchResponsesPage=wn;x.Beta=Ce;x.Batches=Vt;x.BatchesPage=Kt;x.Uploads=gn;x.Responses=pn;class ba{constructor(){this.articles=[]}index(){return this.articles}create(e){const t={id:cs(),title:e.input.title,body:e.input.body,thumbnail:e.input.thumbnail,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return this.articles.push(t),t}update(e){const t=this.articles.find(n=>n.id===e.id);if(t===void 0)throw new Error("Unable to find the matched article.");e.input.title!==void 0&&(t.title=e.input.title),e.input.body!==void 0&&(t.body=e.input.body),e.input.thumbnail!==void 0&&(t.thumbnail=e.input.thumbnail),t.updated_at=new Date().toISOString()}erase(e){const t=this.articles.findIndex(n=>n.id===e.id);if(t===-1)throw new Error("Unable to find the matched article.");this.articles.splice(t,1)}}function xa(r){const e=new ba,t=new us({model:"chatgpt",vendor:{api:new x({apiKey:r.apiKey,dangerouslyAllowBrowser:!0}),model:r.model??"gpt-4o-mini"},controllers:[{protocol:"class",name:"bbs",application:{model:"chatgpt",options:{reference:!1,strict:!1,separate:null},functions:[{name:"index",parameters:{description:"",type:"object",properties:{},additionalProperties:!1,required:[],$defs:{}},output:{description:"List of every articles",type:"array",items:{description:`Description of the current {@link IBbsArticle} type:
|
|
20
|
+
|
|
21
|
+
> Article entity.
|
|
22
|
+
>
|
|
23
|
+
> \`IBbsArticle\` is an entity representing an article in the BBS (Bulletin Board System).`,type:"object",properties:{id:{title:"Primary Key",description:`Primary Key.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@format uuid`,type:"string"},created_at:{title:"Creation time of the article",description:`Creation time of the article.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@format date-time`,type:"string"},updated_at:{title:"Last updated time of the article",description:`Last updated time of the article.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@format date-time`,type:"string"},title:{title:"Title of the article",description:`Title of the article.
|
|
33
|
+
|
|
34
|
+
Representative title of the article.`,type:"string"},body:{title:"Content body",description:`Content body.
|
|
35
|
+
|
|
36
|
+
Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{title:"Thumbnail image URI",description:`Thumbnail image URI.
|
|
37
|
+
|
|
38
|
+
Thumbnail image URI which can represent the article.
|
|
39
|
+
|
|
40
|
+
If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",description:`@format uri
|
|
41
|
+
@contentMediaType image/*`}]}},required:["id","created_at","updated_at","title","body","thumbnail"]}},description:`Get all articles.
|
|
42
|
+
|
|
43
|
+
List up every articles archived in the BBS DB.`,validate:n=>({success:!0,data:n})},{name:"create",parameters:{description:" Properties of create function",type:"object",properties:{input:{description:`Information of the article to create
|
|
44
|
+
|
|
45
|
+
------------------------------
|
|
46
|
+
|
|
47
|
+
Description of the current {@link IBbsArticle.ICreate} type:
|
|
48
|
+
|
|
49
|
+
> Information of the article to create.
|
|
50
|
+
|
|
51
|
+
------------------------------
|
|
52
|
+
|
|
53
|
+
Description of the parent {@link IBbsArticle} type:
|
|
54
|
+
|
|
55
|
+
> Article entity.
|
|
56
|
+
>
|
|
57
|
+
> \`IBbsArticle\` is an entity representing an article in the BBS (Bulletin Board System).`,type:"object",properties:{title:{title:"Title of the article",description:`Title of the article.
|
|
58
|
+
|
|
59
|
+
Representative title of the article.`,type:"string"},body:{title:"Content body",description:`Content body.
|
|
60
|
+
|
|
61
|
+
Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{title:"Thumbnail image URI",description:`Thumbnail image URI.
|
|
62
|
+
|
|
63
|
+
Thumbnail image URI which can represent the article.
|
|
64
|
+
|
|
65
|
+
If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",description:`@format uri
|
|
66
|
+
@contentMediaType image/*`}]}},required:["title","body","thumbnail"]}},required:["input"],additionalProperties:!1,$defs:{}},output:{description:`Description of the current {@link IBbsArticle} type:
|
|
67
|
+
|
|
68
|
+
> Article entity.
|
|
69
|
+
>
|
|
70
|
+
> \`IBbsArticle\` is an entity representing an article in the BBS (Bulletin Board System).`,type:"object",properties:{id:{title:"Primary Key",description:`Primary Key.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@format uuid`,type:"string"},created_at:{title:"Creation time of the article",description:`Creation time of the article.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@format date-time`,type:"string"},updated_at:{title:"Last updated time of the article",description:`Last updated time of the article.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@format date-time`,type:"string"},title:{title:"Title of the article",description:`Title of the article.
|
|
80
|
+
|
|
81
|
+
Representative title of the article.`,type:"string"},body:{title:"Content body",description:`Content body.
|
|
82
|
+
|
|
83
|
+
Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{title:"Thumbnail image URI",description:`Thumbnail image URI.
|
|
84
|
+
|
|
85
|
+
Thumbnail image URI which can represent the article.
|
|
86
|
+
|
|
87
|
+
If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",description:`@format uri
|
|
88
|
+
@contentMediaType image/*`}]}},required:["id","created_at","updated_at","title","body","thumbnail"]},description:`Create a new article.
|
|
89
|
+
|
|
90
|
+
Writes a new article and archives it into the DB.`,validate:(()=>{const n=o=>typeof o.input=="object"&&o.input!==null&&s(o.input),s=o=>typeof o.title=="string"&&typeof o.body=="string"&&(o.thumbnail===null||typeof o.thumbnail=="string"&&We(o.thumbnail)),a=(o,c,h=!0)=>[(typeof o.input=="object"&&o.input!==null||d(h,{path:c+".input",expected:"IBbsArticle.ICreate",value:o.input}))&&i(o.input,c+".input",h)||d(h,{path:c+".input",expected:"IBbsArticle.ICreate",value:o.input})].every(f=>f),i=(o,c,h=!0)=>[typeof o.title=="string"||d(h,{path:c+".title",expected:"string",value:o.title}),typeof o.body=="string"||d(h,{path:c+".body",expected:"string",value:o.body}),o.thumbnail===null||typeof o.thumbnail=="string"&&(We(o.thumbnail)||d(h,{path:c+".thumbnail",expected:'string & Format<"uri">',value:o.thumbnail}))||d(h,{path:c+".thumbnail",expected:'((string & Format<"uri"> & ContentMediaType<"image/*">) | null)',value:o.thumbnail})].every(f=>f),l=o=>typeof o=="object"&&o!==null&&n(o);let u,d;return o=>{if(l(o)===!1){u=[],d=xt(u),((h,f,w=!0)=>(typeof h=="object"&&h!==null||d(!0,{path:f+"",expected:"__type",value:h}))&&a(h,f+"",!0)||d(!0,{path:f+"",expected:"__type",value:h}))(o,"$input",!0);const c=u.length===0;return c?{success:c,data:o}:{success:c,errors:u,data:o}}return{success:!0,data:o}}})()},{name:"update",parameters:{description:" Properties of update function",type:"object",properties:{id:{title:"Target article's {@link IBbsArticle.id}",description:`Target article's {@link IBbsArticle.id}.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@format uuid`,type:"string"},input:{description:`New content to update.
|
|
94
|
+
|
|
95
|
+
------------------------------
|
|
96
|
+
|
|
97
|
+
Description of the current {@link PartialIBbsArticle.ICreate} type:
|
|
98
|
+
|
|
99
|
+
> Make all properties in T optional`,type:"object",properties:{title:{title:"Title of the article",description:`Title of the article.
|
|
100
|
+
|
|
101
|
+
Representative title of the article.`,type:"string"},body:{title:"Content body",description:`Content body.
|
|
102
|
+
|
|
103
|
+
Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{title:"Thumbnail image URI",description:`Thumbnail image URI.
|
|
104
|
+
|
|
105
|
+
Thumbnail image URI which can represent the article.
|
|
106
|
+
|
|
107
|
+
If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",description:`@format uri
|
|
108
|
+
@contentMediaType image/*`}]}},required:[]}},required:["id","input"],additionalProperties:!1,$defs:{}},description:`Update an article.
|
|
109
|
+
|
|
110
|
+
Updates an article with new content.`,validate:(()=>{const n=o=>typeof o.id=="string"&&Je(o.id)&&typeof o.input=="object"&&o.input!==null&&Array.isArray(o.input)===!1&&s(o.input),s=o=>(o.title===void 0||typeof o.title=="string")&&(o.body===void 0||typeof o.body=="string")&&(o.thumbnail===null||o.thumbnail===void 0||typeof o.thumbnail=="string"&&We(o.thumbnail)),a=(o,c,h=!0)=>[typeof o.id=="string"&&(Je(o.id)||d(h,{path:c+".id",expected:'string & Format<"uuid">',value:o.id}))||d(h,{path:c+".id",expected:'(string & Format<"uuid">)',value:o.id}),(typeof o.input=="object"&&o.input!==null&&Array.isArray(o.input)===!1||d(h,{path:c+".input",expected:"Partial<IBbsArticle.ICreate>",value:o.input}))&&i(o.input,c+".input",h)||d(h,{path:c+".input",expected:"Partial<IBbsArticle.ICreate>",value:o.input})].every(f=>f),i=(o,c,h=!0)=>[o.title===void 0||typeof o.title=="string"||d(h,{path:c+".title",expected:"(string | undefined)",value:o.title}),o.body===void 0||typeof o.body=="string"||d(h,{path:c+".body",expected:"(string | undefined)",value:o.body}),o.thumbnail===null||o.thumbnail===void 0||typeof o.thumbnail=="string"&&(We(o.thumbnail)||d(h,{path:c+".thumbnail",expected:'string & Format<"uri">',value:o.thumbnail}))||d(h,{path:c+".thumbnail",expected:'((string & Format<"uri"> & ContentMediaType<"image/*">) | null | undefined)',value:o.thumbnail})].every(f=>f),l=o=>typeof o=="object"&&o!==null&&n(o);let u,d;return o=>{if(l(o)===!1){u=[],d=xt(u),((h,f,w=!0)=>(typeof h=="object"&&h!==null||d(!0,{path:f+"",expected:"__type",value:h}))&&a(h,f+"",!0)||d(!0,{path:f+"",expected:"__type",value:h}))(o,"$input",!0);const c=u.length===0;return c?{success:c,data:o}:{success:c,errors:u,data:o}}return{success:!0,data:o}}})()},{name:"erase",parameters:{description:" Properties of erase function",type:"object",properties:{id:{title:"Target article's {@link IBbsArticle.id}",description:`Target article's {@link IBbsArticle.id}.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@format uuid`,type:"string"}},required:["id"],additionalProperties:!1,$defs:{}},description:`Erase an article.
|
|
114
|
+
|
|
115
|
+
Erases an article from the DB.`,validate:(()=>{const n=u=>typeof u.id=="string"&&Je(u.id),s=(u,d,o=!0)=>[typeof u.id=="string"&&(Je(u.id)||l(o,{path:d+".id",expected:'string & Format<"uuid">',value:u.id}))||l(o,{path:d+".id",expected:'(string & Format<"uuid">)',value:u.id})].every(c=>c),a=u=>typeof u=="object"&&u!==null&&n(u);let i,l;return u=>{if(a(u)===!1){i=[],l=xt(i),((o,c,h=!0)=>(typeof o=="object"&&o!==null||l(!0,{path:c+"",expected:"__type",value:o}))&&s(o,c+"",!0)||l(!0,{path:c+"",expected:"__type",value:o}))(u,"$input",!0);const d=i.length===0;return d?{success:d,data:u}:{success:d,errors:i,data:u}}return{success:!0,data:u}}})()}]},execute:e}],config:{locale:r.locale,timezone:r.timezone,executor:{initialize:null}}});return I.jsx(ds,{agent:t})}function Sa(){const[r,e]=Ue.useState(""),[t,n]=Ue.useState("gpt-4o-mini"),[s,a]=Ue.useState(window.navigator.language),[i,l]=Ue.useState(!1);return I.jsx("div",{style:{width:"100%",height:"100%"},children:i===!0?I.jsx(xa,{apiKey:r,model:t,locale:s}):I.jsxs(is,{style:{width:"calc(100% - 60px)",padding:15,margin:15},children:[I.jsx(bt,{variant:"h6",children:"BBS AI Chatbot"}),I.jsx("br",{}),I.jsx(hs,{}),I.jsx("br",{}),"Demonstration of Agentica with TypeScript Controller Class.",I.jsx("br",{}),I.jsx("br",{}),I.jsx(bt,{variant:"h6",children:" OpenAI Configuration "}),I.jsx(xn,{onChange:u=>e(u.target.value),defaultValue:r,label:"OpenAI API Key",variant:"outlined",placeholder:"Your OpenAI API Key",error:r.length===0}),I.jsx("br",{}),I.jsxs(os,{defaultValue:t,onChange:(u,d)=>n(d),style:{paddingLeft:15},children:[I.jsx(Sn,{control:I.jsx(An,{}),label:"GPT-4o Mini",value:"gpt-4o-mini"}),I.jsx(Sn,{control:I.jsx(An,{}),label:"GPT-4o",value:"gpt-4o"})]}),I.jsx("br",{}),I.jsx(bt,{variant:"h6",children:" Membership Information "}),I.jsx("br",{}),I.jsx(xn,{onChange:u=>a(u.target.value),defaultValue:s,label:"Locale",variant:"outlined",error:s.length===0}),I.jsx("br",{}),I.jsx("br",{}),I.jsx(ls,{component:"a",fullWidth:!0,variant:"contained",color:"info",size:"large",disabled:r.length===0||s.length===0,onClick:()=>l(!0),children:"Start AI Chatbot"})]})})}as(window.document.getElementById("root")).render(I.jsx(Sa,{}));
|
|
@@ -138,4 +138,4 @@ Error generating stack: `+i.message+`
|
|
|
138
138
|
animation-iteration-count: infinite;
|
|
139
139
|
animation-delay: 200ms;
|
|
140
140
|
}
|
|
141
|
-
`,b1=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiTouchRipple"}),{center:o=!1,classes:i={},className:l,...s}=r,[u,a]=$.useState([]),g=$.useRef(0),d=$.useRef(null);$.useEffect(()=>{d.current&&(d.current(),d.current=null)},[u]);const m=$.useRef(!1),w=Ym(),S=$.useRef(null),v=$.useRef(null),P=$.useCallback(y=>{const{pulsate:C,rippleX:E,rippleY:x,rippleSize:R,cb:M}=y;a(c=>[...c,we.jsx(H1,{classes:{ripple:$e(i.ripple,Xe.ripple),rippleVisible:$e(i.rippleVisible,Xe.rippleVisible),ripplePulsate:$e(i.ripplePulsate,Xe.ripplePulsate),child:$e(i.child,Xe.child),childLeaving:$e(i.childLeaving,Xe.childLeaving),childPulsate:$e(i.childPulsate,Xe.childPulsate)},timeout:uu,pulsate:C,rippleX:E,rippleY:x,rippleSize:R},g.current)]),g.current+=1,d.current=M},[i]),p=$.useCallback((y={},C={},E=()=>{})=>{const{pulsate:x=!1,center:R=o||C.pulsate,fakeElement:M=!1}=C;if((y==null?void 0:y.type)==="mousedown"&&m.current){m.current=!1;return}(y==null?void 0:y.type)==="touchstart"&&(m.current=!0);const c=M?null:v.current,_=c?c.getBoundingClientRect():{width:0,height:0,left:0,top:0};let z,L,b;if(R||y===void 0||y.clientX===0&&y.clientY===0||!y.clientX&&!y.touches)z=Math.round(_.width/2),L=Math.round(_.height/2);else{const{clientX:pe,clientY:ye}=y.touches&&y.touches.length>0?y.touches[0]:y;z=Math.round(pe-_.left),L=Math.round(ye-_.top)}if(R)b=Math.sqrt((2*_.width**2+_.height**2)/3),b%2===0&&(b+=1);else{const pe=Math.max(Math.abs((c?c.clientWidth:0)-z),z)*2+2,ye=Math.max(Math.abs((c?c.clientHeight:0)-L),L)*2+2;b=Math.sqrt(pe**2+ye**2)}y!=null&&y.touches?S.current===null&&(S.current=()=>{P({pulsate:x,rippleX:z,rippleY:L,rippleSize:b,cb:E})},w.start(B1,()=>{S.current&&(S.current(),S.current=null)})):P({pulsate:x,rippleX:z,rippleY:L,rippleSize:b,cb:E})},[o,P,w]),f=$.useCallback(()=>{p({},{pulsate:!0})},[p]),h=$.useCallback((y,C)=>{if(w.clear(),(y==null?void 0:y.type)==="touchend"&&S.current){S.current(),S.current=null,w.start(0,()=>{h(y,C)});return}S.current=null,a(E=>E.length>0?E.slice(1):E),d.current=C},[w]);return $.useImperativeHandle(n,()=>({pulsate:f,start:p,stop:h}),[f,p,h]),we.jsx(W1,{className:$e(Xe.root,i.root,l),ref:v,...s,children:we.jsx(_a,{component:null,exit:!0,children:u})})});function K1(e){return ao("MuiButtonBase",e)}const Q1=co("MuiButtonBase",["root","disabled","focusVisible"]),G1=e=>{const{disabled:t,focusVisible:n,focusVisibleClassName:r,classes:o}=e,l=bi({root:["root",t&&"disabled",n&&"focusVisible"]},K1,o);return n&&r&&(l.root+=` ${r}`),l},Y1=ar("button",{name:"MuiButtonBase",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",boxSizing:"border-box",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none",textDecoration:"none",color:"inherit","&::-moz-focus-inner":{borderStyle:"none"},[`&.${Q1.disabled}`]:{pointerEvents:"none",cursor:"default"},"@media print":{colorAdjust:"exact"}}),vS=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiButtonBase"}),{action:o,centerRipple:i=!1,children:l,className:s,component:u="button",disabled:a=!1,disableRipple:g=!1,disableTouchRipple:d=!1,focusRipple:m=!1,focusVisibleClassName:w,LinkComponent:S="a",onBlur:v,onClick:P,onContextMenu:p,onDragLeave:f,onFocus:h,onFocusVisible:y,onKeyDown:C,onKeyUp:E,onMouseDown:x,onMouseLeave:R,onMouseUp:M,onTouchEnd:c,onTouchMove:_,onTouchStart:z,tabIndex:L=0,TouchRippleProps:b,touchRippleRef:pe,type:ye,...Ye}=r,O=$.useRef(null),A=I1(),I=ls(A.ref,pe),[V,ee]=$.useState(!1);a&&V&&ee(!1),$.useImperativeHandle(o,()=>({focusVisible:()=>{ee(!0),O.current.focus()}}),[]);const xn=A.shouldMount&&!g&&!a;$.useEffect(()=>{V&&m&&!g&&A.pulsate()},[g,m,V,A]);const xt=Pt(A,"start",x,d),dr=Pt(A,"stop",p,d),Et=Pt(A,"stop",f,d),En=Pt(A,"stop",M,d),am=Pt(A,"stop",F=>{V&&F.preventDefault(),R&&R(F)},d),cm=Pt(A,"start",z,d),fm=Pt(A,"stop",c,d),dm=Pt(A,"stop",_,d),pm=Pt(A,"stop",F=>{Ma(F.target)||ee(!1),v&&v(F)},!1),mm=bo(F=>{O.current||(O.current=F.currentTarget),Ma(F.target)&&(ee(!0),y&&y(F)),h&&h(F)}),$l=()=>{const F=O.current;return u&&u!=="button"&&!(F.tagName==="A"&&F.href)},hm=bo(F=>{m&&!F.repeat&&V&&F.key===" "&&A.stop(F,()=>{A.start(F)}),F.target===F.currentTarget&&$l()&&F.key===" "&&F.preventDefault(),C&&C(F),F.target===F.currentTarget&&$l()&&F.key==="Enter"&&!a&&(F.preventDefault(),P&&P(F))}),gm=bo(F=>{m&&F.key===" "&&V&&!F.defaultPrevented&&A.stop(F,()=>{A.pulsate(F)}),E&&E(F),P&&F.target===F.currentTarget&&$l()&&F.key===" "&&!F.defaultPrevented&&P(F)});let Co=u;Co==="button"&&(Ye.href||Ye.to)&&(Co=S);const pr={};Co==="button"?(pr.type=ye===void 0?"button":ye,pr.disabled=a):(!Ye.href&&!Ye.to&&(pr.role="button"),a&&(pr["aria-disabled"]=a));const ym=ls(n,O),Ra={...r,centerRipple:i,component:u,disabled:a,disableRipple:g,disableTouchRipple:d,focusRipple:m,tabIndex:L,focusVisible:V},vm=G1(Ra);return we.jsxs(Y1,{as:Co,className:$e(vm.root,s),ownerState:Ra,onBlur:pm,onClick:P,onContextMenu:dr,onFocus:mm,onKeyDown:hm,onKeyUp:gm,onMouseDown:xt,onMouseLeave:am,onMouseUp:En,onDragLeave:Et,onTouchEnd:fm,onTouchMove:dm,onTouchStart:cm,ref:ym,tabIndex:a?-1:L,type:ye,...pr,...Ye,children:[l,xn?we.jsx(b1,{ref:I,center:i,...b}):null]})});function Pt(e,t,n,r=!1){return bo(o=>(n&&n(o),r||e[t](o),!0))}function X1(e){return typeof e.main=="string"}function Z1(e,t=[]){if(!X1(e))return!1;for(const n of t)if(!e.hasOwnProperty(n)||typeof e[n]!="string")return!1;return!0}function J1(e=[]){return([,t])=>t&&Z1(t,e)}function q1(e){return ao("MuiTypography",e)}const SS=co("MuiTypography",["root","h1","h2","h3","h4","h5","h6","subtitle1","subtitle2","body1","body2","inherit","button","caption","overline","alignLeft","alignRight","alignCenter","alignJustify","noWrap","gutterBottom","paragraph"]),eS={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},tS=w0(),nS=e=>{const{align:t,gutterBottom:n,noWrap:r,paragraph:o,variant:i,classes:l}=e,s={root:["root",i,e.align!=="inherit"&&`align${At(t)}`,n&&"gutterBottom",r&&"noWrap",o&&"paragraph"]};return bi(s,q1,l)},rS=ar("span",{name:"MuiTypography",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!=="inherit"&&t[`align${At(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom,n.paragraph&&t.paragraph]}})(ld(({theme:e})=>{var t;return{margin:0,variants:[{props:{variant:"inherit"},style:{font:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}},...Object.entries(e.typography).filter(([n,r])=>n!=="inherit"&&r&&typeof r=="object").map(([n,r])=>({props:{variant:n},style:r})),...Object.entries(e.palette).filter(J1()).map(([n])=>({props:{color:n},style:{color:(e.vars||e).palette[n].main}})),...Object.entries(((t=e.palette)==null?void 0:t.text)||{}).filter(([,n])=>typeof n=="string").map(([n])=>({props:{color:`text${At(n)}`},style:{color:(e.vars||e).palette.text[n]}})),{props:({ownerState:n})=>n.align!=="inherit",style:{textAlign:"var(--Typography-textAlign)"}},{props:({ownerState:n})=>n.noWrap,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{props:({ownerState:n})=>n.gutterBottom,style:{marginBottom:"0.35em"}},{props:({ownerState:n})=>n.paragraph,style:{marginBottom:16}}]}})),df={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",subtitle1:"h6",subtitle2:"h6",body1:"p",body2:"p",inherit:"p"},wS=$.forwardRef(function(t,n){const{color:r,...o}=yo({props:t,name:"MuiTypography"}),i=!eS[r],l=tS({...o,...i&&{color:r}}),{align:s="inherit",className:u,component:a,gutterBottom:g=!1,noWrap:d=!1,paragraph:m=!1,variant:w="body1",variantMapping:S=df,...v}=l,P={...l,align:s,color:r,className:u,component:a,gutterBottom:g,noWrap:d,paragraph:m,variant:w,variantMapping:S},p=a||(m?"p":S[w]||df[w])||"span",f=nS(P);return we.jsx(rS,{as:p,ref:n,className:$e(f.root,u),...v,ownerState:P,style:{...s!=="inherit"&&{"--Typography-textAlign":s},...v.style}})});function kS(e){return typeof e=="string"}const oS=$.createContext({});function iS(e){return ao("MuiList",e)}co("MuiList",["root","padding","dense","subheader"]);const lS=e=>{const{classes:t,disablePadding:n,dense:r,subheader:o}=e;return bi({root:["root",!n&&"padding",r&&"dense",o&&"subheader"]},iS,t)},sS=ar("ul",{name:"MuiList",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:"none",margin:0,padding:0,position:"relative",variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0}}]}),CS=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiList"}),{children:o,className:i,component:l="ul",dense:s=!1,disablePadding:u=!1,subheader:a,...g}=r,d=$.useMemo(()=>({dense:s}),[s]),m={...r,component:l,dense:s,disablePadding:u},w=lS(m);return we.jsx(oS.Provider,{value:d,children:we.jsxs(sS,{as:l,className:$e(w.root,i),ref:n,ownerState:m,...g,children:[a,o]})})});var uS,pf=um;uS=pf.createRoot,pf.hydrateRoot;export{
|
|
141
|
+
`,b1=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiTouchRipple"}),{center:o=!1,classes:i={},className:l,...s}=r,[u,a]=$.useState([]),g=$.useRef(0),d=$.useRef(null);$.useEffect(()=>{d.current&&(d.current(),d.current=null)},[u]);const m=$.useRef(!1),w=Ym(),S=$.useRef(null),v=$.useRef(null),P=$.useCallback(y=>{const{pulsate:C,rippleX:E,rippleY:x,rippleSize:R,cb:M}=y;a(c=>[...c,we.jsx(H1,{classes:{ripple:$e(i.ripple,Xe.ripple),rippleVisible:$e(i.rippleVisible,Xe.rippleVisible),ripplePulsate:$e(i.ripplePulsate,Xe.ripplePulsate),child:$e(i.child,Xe.child),childLeaving:$e(i.childLeaving,Xe.childLeaving),childPulsate:$e(i.childPulsate,Xe.childPulsate)},timeout:uu,pulsate:C,rippleX:E,rippleY:x,rippleSize:R},g.current)]),g.current+=1,d.current=M},[i]),p=$.useCallback((y={},C={},E=()=>{})=>{const{pulsate:x=!1,center:R=o||C.pulsate,fakeElement:M=!1}=C;if((y==null?void 0:y.type)==="mousedown"&&m.current){m.current=!1;return}(y==null?void 0:y.type)==="touchstart"&&(m.current=!0);const c=M?null:v.current,_=c?c.getBoundingClientRect():{width:0,height:0,left:0,top:0};let z,L,b;if(R||y===void 0||y.clientX===0&&y.clientY===0||!y.clientX&&!y.touches)z=Math.round(_.width/2),L=Math.round(_.height/2);else{const{clientX:pe,clientY:ye}=y.touches&&y.touches.length>0?y.touches[0]:y;z=Math.round(pe-_.left),L=Math.round(ye-_.top)}if(R)b=Math.sqrt((2*_.width**2+_.height**2)/3),b%2===0&&(b+=1);else{const pe=Math.max(Math.abs((c?c.clientWidth:0)-z),z)*2+2,ye=Math.max(Math.abs((c?c.clientHeight:0)-L),L)*2+2;b=Math.sqrt(pe**2+ye**2)}y!=null&&y.touches?S.current===null&&(S.current=()=>{P({pulsate:x,rippleX:z,rippleY:L,rippleSize:b,cb:E})},w.start(B1,()=>{S.current&&(S.current(),S.current=null)})):P({pulsate:x,rippleX:z,rippleY:L,rippleSize:b,cb:E})},[o,P,w]),f=$.useCallback(()=>{p({},{pulsate:!0})},[p]),h=$.useCallback((y,C)=>{if(w.clear(),(y==null?void 0:y.type)==="touchend"&&S.current){S.current(),S.current=null,w.start(0,()=>{h(y,C)});return}S.current=null,a(E=>E.length>0?E.slice(1):E),d.current=C},[w]);return $.useImperativeHandle(n,()=>({pulsate:f,start:p,stop:h}),[f,p,h]),we.jsx(W1,{className:$e(Xe.root,i.root,l),ref:v,...s,children:we.jsx(_a,{component:null,exit:!0,children:u})})});function K1(e){return ao("MuiButtonBase",e)}const Q1=co("MuiButtonBase",["root","disabled","focusVisible"]),G1=e=>{const{disabled:t,focusVisible:n,focusVisibleClassName:r,classes:o}=e,l=bi({root:["root",t&&"disabled",n&&"focusVisible"]},K1,o);return n&&r&&(l.root+=` ${r}`),l},Y1=ar("button",{name:"MuiButtonBase",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",boxSizing:"border-box",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none",textDecoration:"none",color:"inherit","&::-moz-focus-inner":{borderStyle:"none"},[`&.${Q1.disabled}`]:{pointerEvents:"none",cursor:"default"},"@media print":{colorAdjust:"exact"}}),vS=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiButtonBase"}),{action:o,centerRipple:i=!1,children:l,className:s,component:u="button",disabled:a=!1,disableRipple:g=!1,disableTouchRipple:d=!1,focusRipple:m=!1,focusVisibleClassName:w,LinkComponent:S="a",onBlur:v,onClick:P,onContextMenu:p,onDragLeave:f,onFocus:h,onFocusVisible:y,onKeyDown:C,onKeyUp:E,onMouseDown:x,onMouseLeave:R,onMouseUp:M,onTouchEnd:c,onTouchMove:_,onTouchStart:z,tabIndex:L=0,TouchRippleProps:b,touchRippleRef:pe,type:ye,...Ye}=r,O=$.useRef(null),A=I1(),I=ls(A.ref,pe),[V,ee]=$.useState(!1);a&&V&&ee(!1),$.useImperativeHandle(o,()=>({focusVisible:()=>{ee(!0),O.current.focus()}}),[]);const xn=A.shouldMount&&!g&&!a;$.useEffect(()=>{V&&m&&!g&&A.pulsate()},[g,m,V,A]);const xt=Pt(A,"start",x,d),dr=Pt(A,"stop",p,d),Et=Pt(A,"stop",f,d),En=Pt(A,"stop",M,d),am=Pt(A,"stop",F=>{V&&F.preventDefault(),R&&R(F)},d),cm=Pt(A,"start",z,d),fm=Pt(A,"stop",c,d),dm=Pt(A,"stop",_,d),pm=Pt(A,"stop",F=>{Ma(F.target)||ee(!1),v&&v(F)},!1),mm=bo(F=>{O.current||(O.current=F.currentTarget),Ma(F.target)&&(ee(!0),y&&y(F)),h&&h(F)}),$l=()=>{const F=O.current;return u&&u!=="button"&&!(F.tagName==="A"&&F.href)},hm=bo(F=>{m&&!F.repeat&&V&&F.key===" "&&A.stop(F,()=>{A.start(F)}),F.target===F.currentTarget&&$l()&&F.key===" "&&F.preventDefault(),C&&C(F),F.target===F.currentTarget&&$l()&&F.key==="Enter"&&!a&&(F.preventDefault(),P&&P(F))}),gm=bo(F=>{m&&F.key===" "&&V&&!F.defaultPrevented&&A.stop(F,()=>{A.pulsate(F)}),E&&E(F),P&&F.target===F.currentTarget&&$l()&&F.key===" "&&!F.defaultPrevented&&P(F)});let Co=u;Co==="button"&&(Ye.href||Ye.to)&&(Co=S);const pr={};Co==="button"?(pr.type=ye===void 0?"button":ye,pr.disabled=a):(!Ye.href&&!Ye.to&&(pr.role="button"),a&&(pr["aria-disabled"]=a));const ym=ls(n,O),Ra={...r,centerRipple:i,component:u,disabled:a,disableRipple:g,disableTouchRipple:d,focusRipple:m,tabIndex:L,focusVisible:V},vm=G1(Ra);return we.jsxs(Y1,{as:Co,className:$e(vm.root,s),ownerState:Ra,onBlur:pm,onClick:P,onContextMenu:dr,onFocus:mm,onKeyDown:hm,onKeyUp:gm,onMouseDown:xt,onMouseLeave:am,onMouseUp:En,onDragLeave:Et,onTouchEnd:fm,onTouchMove:dm,onTouchStart:cm,ref:ym,tabIndex:a?-1:L,type:ye,...pr,...Ye,children:[l,xn?we.jsx(b1,{ref:I,center:i,...b}):null]})});function Pt(e,t,n,r=!1){return bo(o=>(n&&n(o),r||e[t](o),!0))}function X1(e){return typeof e.main=="string"}function Z1(e,t=[]){if(!X1(e))return!1;for(const n of t)if(!e.hasOwnProperty(n)||typeof e[n]!="string")return!1;return!0}function J1(e=[]){return([,t])=>t&&Z1(t,e)}function q1(e){return ao("MuiTypography",e)}const SS=co("MuiTypography",["root","h1","h2","h3","h4","h5","h6","subtitle1","subtitle2","body1","body2","inherit","button","caption","overline","alignLeft","alignRight","alignCenter","alignJustify","noWrap","gutterBottom","paragraph"]),eS={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},tS=w0(),nS=e=>{const{align:t,gutterBottom:n,noWrap:r,paragraph:o,variant:i,classes:l}=e,s={root:["root",i,e.align!=="inherit"&&`align${At(t)}`,n&&"gutterBottom",r&&"noWrap",o&&"paragraph"]};return bi(s,q1,l)},rS=ar("span",{name:"MuiTypography",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!=="inherit"&&t[`align${At(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom,n.paragraph&&t.paragraph]}})(ld(({theme:e})=>{var t;return{margin:0,variants:[{props:{variant:"inherit"},style:{font:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}},...Object.entries(e.typography).filter(([n,r])=>n!=="inherit"&&r&&typeof r=="object").map(([n,r])=>({props:{variant:n},style:r})),...Object.entries(e.palette).filter(J1()).map(([n])=>({props:{color:n},style:{color:(e.vars||e).palette[n].main}})),...Object.entries(((t=e.palette)==null?void 0:t.text)||{}).filter(([,n])=>typeof n=="string").map(([n])=>({props:{color:`text${At(n)}`},style:{color:(e.vars||e).palette.text[n]}})),{props:({ownerState:n})=>n.align!=="inherit",style:{textAlign:"var(--Typography-textAlign)"}},{props:({ownerState:n})=>n.noWrap,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{props:({ownerState:n})=>n.gutterBottom,style:{marginBottom:"0.35em"}},{props:({ownerState:n})=>n.paragraph,style:{marginBottom:16}}]}})),df={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",subtitle1:"h6",subtitle2:"h6",body1:"p",body2:"p",inherit:"p"},wS=$.forwardRef(function(t,n){const{color:r,...o}=yo({props:t,name:"MuiTypography"}),i=!eS[r],l=tS({...o,...i&&{color:r}}),{align:s="inherit",className:u,component:a,gutterBottom:g=!1,noWrap:d=!1,paragraph:m=!1,variant:w="body1",variantMapping:S=df,...v}=l,P={...l,align:s,color:r,className:u,component:a,gutterBottom:g,noWrap:d,paragraph:m,variant:w,variantMapping:S},p=a||(m?"p":S[w]||df[w])||"span",f=nS(P);return we.jsx(rS,{as:p,ref:n,className:$e(f.root,u),...v,ownerState:P,style:{...s!=="inherit"&&{"--Typography-textAlign":s},...v.style}})});function kS(e){return typeof e=="string"}const oS=$.createContext({});function iS(e){return ao("MuiList",e)}co("MuiList",["root","padding","dense","subheader"]);const lS=e=>{const{classes:t,disablePadding:n,dense:r,subheader:o}=e;return bi({root:["root",!n&&"padding",r&&"dense",o&&"subheader"]},iS,t)},sS=ar("ul",{name:"MuiList",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:"none",margin:0,padding:0,position:"relative",variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0}}]}),CS=$.forwardRef(function(t,n){const r=yo({props:t,name:"MuiList"}),{children:o,className:i,component:l="ul",dense:s=!1,disablePadding:u=!1,subheader:a,...g}=r,d=$.useMemo(()=>({dense:s}),[s]),m={...r,component:l,dense:s,disablePadding:u},w=lS(m);return we.jsx(oS.Provider,{value:d,children:we.jsxs(sS,{as:l,className:$e(w.root,i),ref:n,ownerState:m,...g,children:[a,o]})})});var uS,pf=um;uS=pf.createRoot,pf.hydrateRoot;export{T0 as $,zu as A,vS as B,Mu as C,J1 as D,Zm as E,id as F,g0 as G,pS as H,zt as I,Qi as J,Ma as K,oS as L,fS as M,cS as N,Sy as O,Nu as P,t0 as Q,Nn as R,Ym as S,wS as T,Aa as U,oh as V,rh as W,th as X,ss as Y,dy as Z,od as _,co as a,gS as a0,E0 as a1,ff as a2,l0 as a3,Yg as a4,Ou as a5,bm as a6,um as a7,bo as a8,mS as a9,hn as aa,nh as ab,Ve as ac,v0 as ad,Km as b,hS as c,ls as d,$e as e,bi as f,ao as g,S0 as h,_y as i,we as j,dS as k,kS as l,ld as m,yS as n,uS as o,CS as p,mf as q,$ as r,ar as s,SS as t,yo as u,iy as v,Jn as w,my as x,qh as y,At as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as J,j as s,g as B,a as F,r as l,u as N,L as x,b as st,d as _,s as R,e as I,f as G,B as ot,h as nt,m as tt,i as H,k as at,l as Q,n as q,T as w,t as X,o as rt,R as z,p as it}from"./client-BVv4NBtY.js";import{D as Z}from"./Divider-DaLcPLlq.js";const ct=J(s.jsx("path",{d:"M11 9h2V6h3V4h-3V1h-2v3H8v2h3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2m10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2m-9.83-3.25.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25"}),"AddShoppingCart"),lt=J(s.jsx("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 16H8v-2h8zm0-4H8v-2h8zm-3-5V3.5L18.5 9z"}),"Description"),dt=J(s.jsx("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-9 8H3V9h9zm0-4H3V5h9z"}),"FeaturedPlayList");function pt(t){return B("MuiListItem",t)}F("MuiListItem",["root","container","dense","alignItemsFlexStart","divider","gutters","padding","secondaryAction"]);function ut(t){return B("MuiListItemButton",t)}const A=F("MuiListItemButton",["root","focusVisible","dense","alignItemsFlexStart","disabled","divider","gutters","selected"]),mt=(t,e)=>{const{ownerState:o}=t;return[e.root,o.dense&&e.dense,o.alignItems==="flex-start"&&e.alignItemsFlexStart,o.divider&&e.divider,!o.disableGutters&&e.gutters]},yt=t=>{const{alignItems:e,classes:o,dense:n,disabled:a,disableGutters:i,divider:r,selected:c}=t,g=G({root:["root",n&&"dense",!i&&"gutters",r&&"divider",a&&"disabled",e==="flex-start"&&"alignItemsFlexStart",c&&"selected"]},ut,o);return{...o,...g}},gt=R(ot,{shouldForwardProp:t=>nt(t)||t==="classes",name:"MuiListItemButton",slot:"Root",overridesResolver:mt})(tt(({theme:t})=>({display:"flex",flexGrow:1,justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minWidth:0,boxSizing:"border-box",textAlign:"left",paddingTop:8,paddingBottom:8,transition:t.transitions.create("background-color",{duration:t.transitions.duration.shortest}),"&:hover":{textDecoration:"none",backgroundColor:(t.vars||t).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${A.selected}`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / ${t.vars.palette.action.selectedOpacity})`:H(t.palette.primary.main,t.palette.action.selectedOpacity),[`&.${A.focusVisible}`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / calc(${t.vars.palette.action.selectedOpacity} + ${t.vars.palette.action.focusOpacity}))`:H(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.focusOpacity)}},[`&.${A.selected}:hover`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / calc(${t.vars.palette.action.selectedOpacity} + ${t.vars.palette.action.hoverOpacity}))`:H(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / ${t.vars.palette.action.selectedOpacity})`:H(t.palette.primary.main,t.palette.action.selectedOpacity)}},[`&.${A.focusVisible}`]:{backgroundColor:(t.vars||t).palette.action.focus},[`&.${A.disabled}`]:{opacity:(t.vars||t).palette.action.disabledOpacity},variants:[{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(t.vars||t).palette.divider}`,backgroundClip:"padding-box"}},{props:{alignItems:"flex-start"},style:{alignItems:"flex-start"}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.dense,style:{paddingTop:4,paddingBottom:4}}]}))),vt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemButton"}),{alignItems:a="center",autoFocus:i=!1,component:r="div",children:c,dense:d=!1,disableGutters:g=!1,divider:S=!1,focusVisibleClassName:P,selected:T=!1,className:C,...u}=n,f=l.useContext(x),m=l.useMemo(()=>({dense:d||f.dense||!1,alignItems:a,disableGutters:g}),[a,f.dense,d,g]),p=l.useRef(null);st(()=>{i&&p.current&&p.current.focus()},[i]);const v={...n,alignItems:a,dense:m.dense,disableGutters:g,divider:S,selected:T},h=yt(v),b=_(p,o);return s.jsx(x.Provider,{value:m,children:s.jsx(gt,{ref:b,href:u.href||u.to,component:(u.href||u.to)&&r==="div"?"button":r,focusVisibleClassName:I(h.focusVisible,P),ownerState:v,className:I(h.root,C),...u,classes:h,children:c})})});function ht(t){return B("MuiListItemSecondaryAction",t)}F("MuiListItemSecondaryAction",["root","disableGutters"]);const xt=t=>{const{disableGutters:e,classes:o}=t;return G({root:["root",e&&"disableGutters"]},ht,o)},ft=R("div",{name:"MuiListItemSecondaryAction",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[e.root,o.disableGutters&&e.disableGutters]}})({position:"absolute",right:16,top:"50%",transform:"translateY(-50%)",variants:[{props:({ownerState:t})=>t.disableGutters,style:{right:0}}]}),et=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemSecondaryAction"}),{className:a,...i}=n,r=l.useContext(x),c={...n,disableGutters:r.disableGutters},d=xt(c);return s.jsx(ft,{className:I(d.root,a),ownerState:c,ref:o,...i})});et.muiName="ListItemSecondaryAction";const bt=(t,e)=>{const{ownerState:o}=t;return[e.root,o.dense&&e.dense,o.alignItems==="flex-start"&&e.alignItemsFlexStart,o.divider&&e.divider,!o.disableGutters&&e.gutters,!o.disablePadding&&e.padding,o.hasSecondaryAction&&e.secondaryAction]},It=t=>{const{alignItems:e,classes:o,dense:n,disableGutters:a,disablePadding:i,divider:r,hasSecondaryAction:c}=t;return G({root:["root",n&&"dense",!a&&"gutters",!i&&"padding",r&&"divider",e==="flex-start"&&"alignItemsFlexStart",c&&"secondaryAction"],container:["container"]},pt,o)},St=R("div",{name:"MuiListItem",slot:"Root",overridesResolver:bt})(tt(({theme:t})=>({display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",width:"100%",boxSizing:"border-box",textAlign:"left",variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>!e.disablePadding&&e.dense,style:{paddingTop:4,paddingBottom:4}},{props:({ownerState:e})=>!e.disablePadding&&!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>!e.disablePadding&&!!e.secondaryAction,style:{paddingRight:48}},{props:({ownerState:e})=>!!e.secondaryAction,style:{[`& > .${A.root}`]:{paddingRight:48}}},{props:{alignItems:"flex-start"},style:{alignItems:"flex-start"}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(t.vars||t).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:e})=>e.button,style:{transition:t.transitions.create("background-color",{duration:t.transitions.duration.shortest}),"&:hover":{textDecoration:"none",backgroundColor:(t.vars||t).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}}}},{props:({ownerState:e})=>e.hasSecondaryAction,style:{paddingRight:48}}]}))),Ct=R("li",{name:"MuiListItem",slot:"Container",overridesResolver:(t,e)=>e.container})({position:"relative"}),Lt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItem"}),{alignItems:a="center",children:i,className:r,component:c,components:d={},componentsProps:g={},ContainerComponent:S="li",ContainerProps:{className:P,...T}={},dense:C=!1,disableGutters:u=!1,disablePadding:f=!1,divider:m=!1,secondaryAction:p,slotProps:v={},slots:h={},...b}=n,U=l.useContext(x),k=l.useMemo(()=>({dense:C||U.dense||!1,alignItems:a,disableGutters:u}),[a,U.dense,C,u]),E=l.useRef(null),y=l.Children.toArray(i),O=y.length&&at(y[y.length-1],["ListItemSecondaryAction"]),L={...n,alignItems:a,dense:k.dense,disableGutters:u,disablePadding:f,divider:m,hasSecondaryAction:O},Y=It(L),K=_(E,o),V=h.root||d.Root||St,M=v.root||g.root||{},$={className:I(Y.root,M.className,r),...b};let j=c||"li";return O?(j=!$.component&&!c?"div":j,S==="li"&&(j==="li"?j="div":$.component==="li"&&($.component="div")),s.jsx(x.Provider,{value:k,children:s.jsxs(Ct,{as:S,className:I(Y.container,P),ref:K,ownerState:L,...T,children:[s.jsx(V,{...M,...!Q(V)&&{as:j,ownerState:{...L,...M.ownerState}},...$,children:y}),y.pop()]})})):s.jsx(x.Provider,{value:k,children:s.jsxs(V,{...M,as:j,ref:K,...!Q(V)&&{ownerState:{...L,...M.ownerState}},...$,children:[y,p&&s.jsx(et,{children:p})]})})});function jt(t){return B("MuiListItemAvatar",t)}F("MuiListItemAvatar",["root","alignItemsFlexStart"]);const At=t=>{const{alignItems:e,classes:o}=t;return G({root:["root",e==="flex-start"&&"alignItemsFlexStart"]},jt,o)},wt=R("div",{name:"MuiListItemAvatar",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[e.root,o.alignItems==="flex-start"&&e.alignItemsFlexStart]}})({minWidth:56,flexShrink:0,variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}),Rt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemAvatar"}),{className:a,...i}=n,r=l.useContext(x),c={...n,alignItems:r.alignItems},d=At(c);return s.jsx(wt,{className:I(d.root,a),ownerState:c,ref:o,...i})});function Pt(t){return B("MuiListItemText",t)}const D=F("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),Tt=t=>{const{classes:e,inset:o,primary:n,secondary:a,dense:i}=t;return G({root:["root",o&&"inset",i&&"dense",n&&a&&"multiline"],primary:["primary"],secondary:["secondary"]},Pt,e)},kt=R("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[{[`& .${D.primary}`]:e.primary},{[`& .${D.secondary}`]:e.secondary},e.root,o.inset&&e.inset,o.primary&&o.secondary&&e.multiline,o.dense&&e.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${X.root}:where(& .${D.primary})`]:{display:"block"},[`.${X.root}:where(& .${D.secondary})`]:{display:"block"},variants:[{props:({ownerState:t})=>t.primary&&t.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:t})=>t.inset,style:{paddingLeft:56}}]}),Mt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemText"}),{children:a,className:i,disableTypography:r=!1,inset:c=!1,primary:d,primaryTypographyProps:g,secondary:S,secondaryTypographyProps:P,slots:T={},slotProps:C={},...u}=n,{dense:f}=l.useContext(x);let m=d??a,p=S;const v={...n,disableTypography:r,inset:c,primary:!!m,secondary:!!p,dense:f},h=Tt(v),b={slots:T,slotProps:{primary:g,secondary:P,...C}},[U,k]=q("root",{className:I(h.root,i),elementType:kt,externalForwardedProps:{...b,...u},ownerState:v,ref:o}),[E,y]=q("primary",{className:h.primary,elementType:w,externalForwardedProps:b,ownerState:v}),[O,L]=q("secondary",{className:h.secondary,elementType:w,externalForwardedProps:b,ownerState:v});return m!=null&&m.type!==w&&!r&&(m=s.jsx(E,{variant:f?"body2":"body1",component:y!=null&&y.variant?void 0:"span",...y,children:m})),p!=null&&p.type!==w&&!r&&(p=s.jsx(O,{variant:"body2",color:"textSecondary",...L,children:p})),s.jsxs(U,{...k,children:[m,p]})}),W=t=>s.jsx(Lt,{alignItems:"flex-start",children:s.jsxs(vt,{href:t.href,children:[s.jsx(Rt,{children:t.icon}),s.jsx(Mt,{primary:t.title,secondary:s.jsxs(z.Fragment,{children:[s.jsx(w,{component:"span",variant:"body2",sx:{color:"text.primary",display:"inline"},children:t.summary}),t.description]})})]})}),$t=()=>s.jsxs(z.Fragment,{children:[s.jsx(w,{variant:"h4",children:"Agentica Playground"}),s.jsx("hr",{}),s.jsxs(it,{sx:{width:"100%",maxWidth:720,bgcolor:"background.paper"},children:[s.jsx(W,{href:"./uploader/",title:"Swagger Uploader",summary:"Test your backend server's AI chatbot",icon:s.jsx(dt,{}),description:s.jsx("p",{children:"Upload your Swagger document file to the playground website, and start conversation with your backend server. Validate your backend server's Swagger documentation quality before developing your AI chatbot application."})}),s.jsx(Z,{variant:"inset",component:"li"}),s.jsx(W,{href:"./shopping/",title:"Shopping AI Chatbot",summary:"AI chatbot by Swagger document",icon:s.jsx(ct,{}),description:s.jsxs(z.Fragment,{children:[s.jsx("p",{children:"Shopping AI chatbot which can search products, and take orders just by conversation texts."}),s.jsxs("p",{children:["This example project has been developed to prove a key concept of ",s.jsx("code",{children:"nestia/agent"})," that every backend servers providing Swagger documents can be conversed with the AI chatbot. You can search products, and take orders just by conversation texts."]}),s.jsx("p",{children:"If you've developed a backend server, then you can chat with the backend server just by delivering the Swagger document. If your documentation quality is enough, you can experience the new AI era. No more GUI development required. Just develop only backend server and chat with it."})]})}),s.jsx(Z,{variant:"inset",component:"li"}),s.jsx(W,{href:"./bbs/",title:"BBS AI Chatbot",summary:"AI chatbot by TypeScript Class",icon:s.jsx(lt,{}),description:s.jsxs(z.Fragment,{children:[s.jsx("p",{children:"BBS (Bullet-in Board System) AI chatbot posting articles just by conversation texts."}),s.jsxs("p",{children:["This example project has been developed to demonstrate"," ",s.jsx("code",{children:"typia.llm.application<App, Model>()"})," function which can generate LLM (Large Language Model) function calling application schema from a TypeScript class type."]}),s.jsx("p",{children:"If you've developed a TypeScript facade class, then you can chat with the class just by taking the class type. If you've done enough documentations on the class methods and DTO (Data Transfer Object) types, you can experience the new AI era. No more GUI development required. Just develop only TypeScript class containing the business logics and chat with it."})]})})]})]});rt(window.document.getElementById("root")).render(s.jsx($t,{}));
|
|
1
|
+
import{c as J,j as s,g as B,a as F,r as l,u as N,L as x,b as st,d as _,s as R,e as I,f as G,B as ot,h as nt,m as tt,i as H,k as at,l as Q,n as q,T as w,t as X,o as rt,R as z,p as it}from"./client-nQAh1QKo.js";import{D as Z}from"./Divider-U2p72sQ2.js";const ct=J(s.jsx("path",{d:"M11 9h2V6h3V4h-3V1h-2v3H8v2h3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2m10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2m-9.83-3.25.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25"}),"AddShoppingCart"),lt=J(s.jsx("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 16H8v-2h8zm0-4H8v-2h8zm-3-5V3.5L18.5 9z"}),"Description"),dt=J(s.jsx("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-9 8H3V9h9zm0-4H3V5h9z"}),"FeaturedPlayList");function pt(t){return B("MuiListItem",t)}F("MuiListItem",["root","container","dense","alignItemsFlexStart","divider","gutters","padding","secondaryAction"]);function ut(t){return B("MuiListItemButton",t)}const A=F("MuiListItemButton",["root","focusVisible","dense","alignItemsFlexStart","disabled","divider","gutters","selected"]),mt=(t,e)=>{const{ownerState:o}=t;return[e.root,o.dense&&e.dense,o.alignItems==="flex-start"&&e.alignItemsFlexStart,o.divider&&e.divider,!o.disableGutters&&e.gutters]},yt=t=>{const{alignItems:e,classes:o,dense:n,disabled:a,disableGutters:i,divider:r,selected:c}=t,g=G({root:["root",n&&"dense",!i&&"gutters",r&&"divider",a&&"disabled",e==="flex-start"&&"alignItemsFlexStart",c&&"selected"]},ut,o);return{...o,...g}},gt=R(ot,{shouldForwardProp:t=>nt(t)||t==="classes",name:"MuiListItemButton",slot:"Root",overridesResolver:mt})(tt(({theme:t})=>({display:"flex",flexGrow:1,justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minWidth:0,boxSizing:"border-box",textAlign:"left",paddingTop:8,paddingBottom:8,transition:t.transitions.create("background-color",{duration:t.transitions.duration.shortest}),"&:hover":{textDecoration:"none",backgroundColor:(t.vars||t).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${A.selected}`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / ${t.vars.palette.action.selectedOpacity})`:H(t.palette.primary.main,t.palette.action.selectedOpacity),[`&.${A.focusVisible}`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / calc(${t.vars.palette.action.selectedOpacity} + ${t.vars.palette.action.focusOpacity}))`:H(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.focusOpacity)}},[`&.${A.selected}:hover`]:{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / calc(${t.vars.palette.action.selectedOpacity} + ${t.vars.palette.action.hoverOpacity}))`:H(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:t.vars?`rgba(${t.vars.palette.primary.mainChannel} / ${t.vars.palette.action.selectedOpacity})`:H(t.palette.primary.main,t.palette.action.selectedOpacity)}},[`&.${A.focusVisible}`]:{backgroundColor:(t.vars||t).palette.action.focus},[`&.${A.disabled}`]:{opacity:(t.vars||t).palette.action.disabledOpacity},variants:[{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(t.vars||t).palette.divider}`,backgroundClip:"padding-box"}},{props:{alignItems:"flex-start"},style:{alignItems:"flex-start"}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.dense,style:{paddingTop:4,paddingBottom:4}}]}))),vt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemButton"}),{alignItems:a="center",autoFocus:i=!1,component:r="div",children:c,dense:d=!1,disableGutters:g=!1,divider:S=!1,focusVisibleClassName:P,selected:T=!1,className:C,...u}=n,f=l.useContext(x),m=l.useMemo(()=>({dense:d||f.dense||!1,alignItems:a,disableGutters:g}),[a,f.dense,d,g]),p=l.useRef(null);st(()=>{i&&p.current&&p.current.focus()},[i]);const v={...n,alignItems:a,dense:m.dense,disableGutters:g,divider:S,selected:T},h=yt(v),b=_(p,o);return s.jsx(x.Provider,{value:m,children:s.jsx(gt,{ref:b,href:u.href||u.to,component:(u.href||u.to)&&r==="div"?"button":r,focusVisibleClassName:I(h.focusVisible,P),ownerState:v,className:I(h.root,C),...u,classes:h,children:c})})});function ht(t){return B("MuiListItemSecondaryAction",t)}F("MuiListItemSecondaryAction",["root","disableGutters"]);const xt=t=>{const{disableGutters:e,classes:o}=t;return G({root:["root",e&&"disableGutters"]},ht,o)},ft=R("div",{name:"MuiListItemSecondaryAction",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[e.root,o.disableGutters&&e.disableGutters]}})({position:"absolute",right:16,top:"50%",transform:"translateY(-50%)",variants:[{props:({ownerState:t})=>t.disableGutters,style:{right:0}}]}),et=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemSecondaryAction"}),{className:a,...i}=n,r=l.useContext(x),c={...n,disableGutters:r.disableGutters},d=xt(c);return s.jsx(ft,{className:I(d.root,a),ownerState:c,ref:o,...i})});et.muiName="ListItemSecondaryAction";const bt=(t,e)=>{const{ownerState:o}=t;return[e.root,o.dense&&e.dense,o.alignItems==="flex-start"&&e.alignItemsFlexStart,o.divider&&e.divider,!o.disableGutters&&e.gutters,!o.disablePadding&&e.padding,o.hasSecondaryAction&&e.secondaryAction]},It=t=>{const{alignItems:e,classes:o,dense:n,disableGutters:a,disablePadding:i,divider:r,hasSecondaryAction:c}=t;return G({root:["root",n&&"dense",!a&&"gutters",!i&&"padding",r&&"divider",e==="flex-start"&&"alignItemsFlexStart",c&&"secondaryAction"],container:["container"]},pt,o)},St=R("div",{name:"MuiListItem",slot:"Root",overridesResolver:bt})(tt(({theme:t})=>({display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",width:"100%",boxSizing:"border-box",textAlign:"left",variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>!e.disablePadding&&e.dense,style:{paddingTop:4,paddingBottom:4}},{props:({ownerState:e})=>!e.disablePadding&&!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>!e.disablePadding&&!!e.secondaryAction,style:{paddingRight:48}},{props:({ownerState:e})=>!!e.secondaryAction,style:{[`& > .${A.root}`]:{paddingRight:48}}},{props:{alignItems:"flex-start"},style:{alignItems:"flex-start"}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(t.vars||t).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:e})=>e.button,style:{transition:t.transitions.create("background-color",{duration:t.transitions.duration.shortest}),"&:hover":{textDecoration:"none",backgroundColor:(t.vars||t).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}}}},{props:({ownerState:e})=>e.hasSecondaryAction,style:{paddingRight:48}}]}))),Ct=R("li",{name:"MuiListItem",slot:"Container",overridesResolver:(t,e)=>e.container})({position:"relative"}),Lt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItem"}),{alignItems:a="center",children:i,className:r,component:c,components:d={},componentsProps:g={},ContainerComponent:S="li",ContainerProps:{className:P,...T}={},dense:C=!1,disableGutters:u=!1,disablePadding:f=!1,divider:m=!1,secondaryAction:p,slotProps:v={},slots:h={},...b}=n,U=l.useContext(x),k=l.useMemo(()=>({dense:C||U.dense||!1,alignItems:a,disableGutters:u}),[a,U.dense,C,u]),E=l.useRef(null),y=l.Children.toArray(i),O=y.length&&at(y[y.length-1],["ListItemSecondaryAction"]),L={...n,alignItems:a,dense:k.dense,disableGutters:u,disablePadding:f,divider:m,hasSecondaryAction:O},Y=It(L),K=_(E,o),V=h.root||d.Root||St,M=v.root||g.root||{},$={className:I(Y.root,M.className,r),...b};let j=c||"li";return O?(j=!$.component&&!c?"div":j,S==="li"&&(j==="li"?j="div":$.component==="li"&&($.component="div")),s.jsx(x.Provider,{value:k,children:s.jsxs(Ct,{as:S,className:I(Y.container,P),ref:K,ownerState:L,...T,children:[s.jsx(V,{...M,...!Q(V)&&{as:j,ownerState:{...L,...M.ownerState}},...$,children:y}),y.pop()]})})):s.jsx(x.Provider,{value:k,children:s.jsxs(V,{...M,as:j,ref:K,...!Q(V)&&{ownerState:{...L,...M.ownerState}},...$,children:[y,p&&s.jsx(et,{children:p})]})})});function jt(t){return B("MuiListItemAvatar",t)}F("MuiListItemAvatar",["root","alignItemsFlexStart"]);const At=t=>{const{alignItems:e,classes:o}=t;return G({root:["root",e==="flex-start"&&"alignItemsFlexStart"]},jt,o)},wt=R("div",{name:"MuiListItemAvatar",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[e.root,o.alignItems==="flex-start"&&e.alignItemsFlexStart]}})({minWidth:56,flexShrink:0,variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}),Rt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemAvatar"}),{className:a,...i}=n,r=l.useContext(x),c={...n,alignItems:r.alignItems},d=At(c);return s.jsx(wt,{className:I(d.root,a),ownerState:c,ref:o,...i})});function Pt(t){return B("MuiListItemText",t)}const D=F("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),Tt=t=>{const{classes:e,inset:o,primary:n,secondary:a,dense:i}=t;return G({root:["root",o&&"inset",i&&"dense",n&&a&&"multiline"],primary:["primary"],secondary:["secondary"]},Pt,e)},kt=R("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:o}=t;return[{[`& .${D.primary}`]:e.primary},{[`& .${D.secondary}`]:e.secondary},e.root,o.inset&&e.inset,o.primary&&o.secondary&&e.multiline,o.dense&&e.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${X.root}:where(& .${D.primary})`]:{display:"block"},[`.${X.root}:where(& .${D.secondary})`]:{display:"block"},variants:[{props:({ownerState:t})=>t.primary&&t.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:t})=>t.inset,style:{paddingLeft:56}}]}),Mt=l.forwardRef(function(e,o){const n=N({props:e,name:"MuiListItemText"}),{children:a,className:i,disableTypography:r=!1,inset:c=!1,primary:d,primaryTypographyProps:g,secondary:S,secondaryTypographyProps:P,slots:T={},slotProps:C={},...u}=n,{dense:f}=l.useContext(x);let m=d??a,p=S;const v={...n,disableTypography:r,inset:c,primary:!!m,secondary:!!p,dense:f},h=Tt(v),b={slots:T,slotProps:{primary:g,secondary:P,...C}},[U,k]=q("root",{className:I(h.root,i),elementType:kt,externalForwardedProps:{...b,...u},ownerState:v,ref:o}),[E,y]=q("primary",{className:h.primary,elementType:w,externalForwardedProps:b,ownerState:v}),[O,L]=q("secondary",{className:h.secondary,elementType:w,externalForwardedProps:b,ownerState:v});return m!=null&&m.type!==w&&!r&&(m=s.jsx(E,{variant:f?"body2":"body1",component:y!=null&&y.variant?void 0:"span",...y,children:m})),p!=null&&p.type!==w&&!r&&(p=s.jsx(O,{variant:"body2",color:"textSecondary",...L,children:p})),s.jsxs(U,{...k,children:[m,p]})});function W(t){return s.jsx(Lt,{alignItems:"flex-start",children:s.jsxs(vt,{href:t.href,children:[s.jsx(Rt,{children:t.icon}),s.jsx(Mt,{primary:t.title,secondary:s.jsxs(z.Fragment,{children:[s.jsx(w,{component:"span",variant:"body2",sx:{color:"text.primary",display:"inline"},children:t.summary}),t.description]})})]})})}function $t(){return s.jsxs(z.Fragment,{children:[s.jsx(w,{variant:"h4",children:"Agentica Playground"}),s.jsx("hr",{}),s.jsxs(it,{sx:{width:"100%",maxWidth:720,bgcolor:"background.paper"},children:[s.jsx(W,{href:"./uploader/",title:"Swagger Uploader",summary:"Test your backend server's AI chatbot",icon:s.jsx(dt,{}),description:s.jsx("p",{children:"Upload your Swagger document file to the playground website, and start conversation with your backend server. Validate your backend server's Swagger documentation quality before developing your AI chatbot application."})}),s.jsx(Z,{variant:"inset",component:"li"}),s.jsx(W,{href:"./shopping/",title:"Shopping AI Chatbot",summary:"AI chatbot by Swagger document",icon:s.jsx(ct,{}),description:s.jsxs(z.Fragment,{children:[s.jsx("p",{children:"Shopping AI chatbot which can search products, and take orders just by conversation texts."}),s.jsxs("p",{children:["This example project has been developed to prove a key concept of"," ",s.jsx("code",{children:"nestia/agent"})," ","that every backend servers providing Swagger documents can be conversed with the AI chatbot. You can search products, and take orders just by conversation texts."]}),s.jsx("p",{children:"If you've developed a backend server, then you can chat with the backend server just by delivering the Swagger document. If your documentation quality is enough, you can experience the new AI era. No more GUI development required. Just develop only backend server and chat with it."})]})}),s.jsx(Z,{variant:"inset",component:"li"}),s.jsx(W,{href:"./bbs/",title:"BBS AI Chatbot",summary:"AI chatbot by TypeScript Class",icon:s.jsx(lt,{}),description:s.jsxs(z.Fragment,{children:[s.jsx("p",{children:"BBS (Bullet-in Board System) AI chatbot posting articles just by conversation texts."}),s.jsxs("p",{children:["This example project has been developed to demonstrate"," ",s.jsx("code",{children:"typia.llm.application<App, Model>()"})," ","function which can generate LLM (Large Language Model) function calling application schema from a TypeScript class type."]}),s.jsx("p",{children:"If you've developed a TypeScript facade class, then you can chat with the class just by taking the class type. If you've done enough documentations on the class methods and DTO (Data Transfer Object) types, you can experience the new AI era. No more GUI development required. Just develop only TypeScript class containing the business logics and chat with it."})]})})]})]})}rt(window.document.getElementById("root")).render(s.jsx($t,{}));
|