@agentica/chat 0.34.2 → 0.35.0

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.
Files changed (33) hide show
  1. package/dist/assets/VendorConfigurationMovie-A3EDRuuv.js +3445 -0
  2. package/dist/assets/bbs/index-DJ2TSI_V.js +41 -0
  3. package/dist/assets/shopping/index.html-DwrDQLUl.js +3 -0
  4. package/dist/assets/uploader/index.html-qTzoYxoF.js +17 -0
  5. package/dist/bbs/index.html +2 -2
  6. package/dist/shopping/index.html +2 -2
  7. package/dist/uploader/index.html +2 -2
  8. package/lib/AgenticaChatApplication.d.ts +3 -4
  9. package/lib/examples/bbs/BbsChatApplication.d.ts +0 -2
  10. package/lib/examples/common/VendorConfigurationMovie.d.ts +0 -2
  11. package/lib/examples/shopping/ShoppingChatApplication.d.ts +1 -2
  12. package/lib/index.mjs +0 -3
  13. package/lib/index.mjs.map +1 -1
  14. package/lib/movies/AgenticaChatMovie.d.ts +3 -4
  15. package/lib/movies/messages/AgenticaChatDescribeMessageMovie.d.ts +3 -4
  16. package/lib/movies/messages/AgenticaChatExecuteMessageMovie.d.ts +3 -4
  17. package/lib/movies/messages/AgenticaChatMessageMovie.d.ts +3 -4
  18. package/lib/movies/messages/AgenticaChatSelectMessageMovie.d.ts +3 -4
  19. package/lib/movies/sides/AgenticaChatFunctionStackSideMovie.d.ts +3 -4
  20. package/lib/movies/sides/AgenticaChatSideMovie.d.ts +4 -6
  21. package/package.json +7 -7
  22. package/src/AgenticaChatApplication.tsx +3 -4
  23. package/src/movies/AgenticaChatMovie.tsx +11 -13
  24. package/src/movies/messages/AgenticaChatDescribeMessageMovie.tsx +4 -7
  25. package/src/movies/messages/AgenticaChatExecuteMessageMovie.tsx +5 -8
  26. package/src/movies/messages/AgenticaChatMessageMovie.tsx +4 -5
  27. package/src/movies/messages/AgenticaChatSelectMessageMovie.tsx +4 -5
  28. package/src/movies/sides/AgenticaChatFunctionStackSideMovie.tsx +5 -6
  29. package/src/movies/sides/AgenticaChatSideMovie.tsx +4 -11
  30. package/dist/assets/VendorConfigurationMovie-RyNqJgVh.js +0 -3472
  31. package/dist/assets/bbs/index-Cm56m_DU.js +0 -257
  32. package/dist/assets/shopping/index.html-CWl5SH2s.js +0 -3
  33. package/dist/assets/uploader/index.html-Yr3xbsVI.js +0 -17
@@ -0,0 +1,41 @@
1
+ import{j as d,o as A,r as g,T as b}from"../client-B3aq8qpT.js";import{n as B,t as U,o as v,p as T,q as $,r as S,s as F,v as R,w as k,x as M,_,d as P,V as j,c as z,F as O,T as q,B as E}from"../VendorConfigurationMovie-A3EDRuuv.js";import{D}from"../Divider-DX1xhf0M.js";class w{constructor(t){this.props=t,this.operations_=B.compose({controllers:t.controllers,config:t.config}),this.histories_=(t.histories??[]).map(a=>U({operations:this.operations_.group,history:a})),this.token_usage_=this.props.tokenUsage!==void 0?this.props.tokenUsage instanceof v?this.props.tokenUsage:new v(this.props.tokenUsage):v.zero(),this.listeners_=new Map,this.semaphore_=t.vendor.semaphore!=null?typeof t.vendor.semaphore=="object"?t.vendor.semaphore:new T(t.vendor.semaphore):null}clone(){var t;return new w({...this.props,histories:(t=this.props.histories)==null?void 0:t.slice()})}async conversate(t,a={}){var n,e,i,r;const s=[],u=async l=>{try{await this.dispatch(l),"toHistory"in l&&("join"in l?s.push(async()=>(await l.join(),l.toHistory())):s.push(async()=>l.toHistory()))}catch{}},f=$({contents:Array.isArray(t)?t:typeof t=="string"?[{type:"text",text:t}]:[t]});u(f).catch(()=>{});const h=this.getContext({prompt:f,dispatch:u,usage:this.token_usage_,abortSignal:a.abortSignal}),p=await S(h,this.operations_.array);p.length&&((e=(n=this.props.config)==null?void 0:n.executor)==null?void 0:e.describe)!==null&&((r=(i=this.props.config)==null?void 0:i.executor)==null?void 0:r.describe)!==!1&&await F(h,p);const o=await Promise.all(s.map(async l=>l()));return this.histories_.push(...o),o}getConfig(){return this.props.config}getVendor(){return this.props.vendor}getOperations(){return this.operations_.array}getControllers(){return this.props.controllers}getHistories(){return this.histories_}getTokenUsage(){return this.token_usage_}getContext(t){const a=R({vendor:this.props.vendor,config:this.props.config,dispatch:t.dispatch,abortSignal:t.abortSignal,usage:this.token_usage_});return{operations:this.operations_,config:this.props.config,histories:this.histories_,prompt:t.prompt,dispatch:t.dispatch,request:this.semaphore_===null?a:async(s,u)=>{await this.semaphore_.acquire();try{return await a(s,u)}finally{this.semaphore_.release().catch(()=>{})}}}}on(t,a){return k(this.listeners_,t,()=>new Set).add(a),this}off(t,a){const s=this.listeners_.get(t);return s!==void 0&&(s.delete(a),s.size===0&&this.listeners_.delete(t)),this}async dispatch(t){const a=this.listeners_.get(t.type);a!==void 0&&await Promise.all(Array.from(a).map(async s=>{try{await s(t)}catch{}}))}}var x={};Object.defineProperty(x,"__esModule",{value:!0});var m=x._isFormatUri=void 0;const L=c=>H.test(c)&&K.test(c);m=x._isFormatUri=L;const H=/\/|:/,K=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;var I={};Object.defineProperty(I,"__esModule",{value:!0});var y=I._isFormatUuid=void 0;const V=c=>N.test(c);y=I._isFormatUuid=V;const N=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;class W{constructor(){this.articles=[]}index(){return this.articles}create(t){const a={id:M(),title:t.input.title,body:t.input.body,thumbnail:t.input.thumbnail,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return this.articles.push(a),a}update(t){const a=this.articles.find(s=>s.id===t.id);if(a===void 0)throw new Error("Unable to find the matched article.");t.input.title!==void 0&&(a.title=t.input.title),t.input.body!==void 0&&(a.body=t.input.body),t.input.thumbnail!==void 0&&(a.thumbnail=t.input.thumbnail),a.updated_at=new Date().toISOString()}erase(t){const a=this.articles.findIndex(s=>s.id===t.id);if(a===-1)throw new Error("Unable to find the matched article.");this.articles.splice(a,1)}}function G(c){const t=new W,a=new w({vendor:{api:c.api,model:c.vendorModel},controllers:[{protocol:"class",name:"bbs",application:{config:{reference:!0,strict:!1,separate:null,validate:null},functions:[{name:"index",parameters:{type:"object",properties:{},additionalProperties:!1,required:[],$defs:{IBbsArticle:{description:"Article entity.\n\n`IBbsArticle` is an entity representing an article in the BBS (Bulletin Board System).",type:"object",properties:{id:{description:"Primary Key.",type:"string",format:"uuid"},created_at:{description:"Creation time of the article.",type:"string",format:"date-time"},updated_at:{description:"Last updated time of the article.",type:"string",format:"date-time"},title:{description:`Title of the article.
2
+
3
+ Representative title of the article.`,type:"string"},body:{description:`Content body.
4
+
5
+ Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{description:`Thumbnail image URI.
6
+
7
+ Thumbnail image URI which can represent the article.
8
+
9
+ If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",format:"uri",contentMediaType:"image/*"}]}},required:["id","created_at","updated_at","title","body","thumbnail"]}}},output:{description:"List of every articles",type:"array",items:{$ref:"#/$defs/IBbsArticle"}},description:`Get all articles.
10
+
11
+ List up every articles archived in the BBS DB.`,validate:s=>({success:!0,data:s})},{name:"create",parameters:{description:" Properties of create function",type:"object",properties:{input:{description:"Information of the article to create",$ref:"#/$defs/IBbsArticle.ICreate"}},required:["input"],additionalProperties:!1,$defs:{"IBbsArticle.ICreate":{description:"Information of the article to create.",type:"object",properties:{title:{description:`Title of the article.
12
+
13
+ Representative title of the article.`,type:"string"},body:{description:`Content body.
14
+
15
+ Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{description:`Thumbnail image URI.
16
+
17
+ Thumbnail image URI which can represent the article.
18
+
19
+ If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",format:"uri",contentMediaType:"image/*"}]}},required:["title","body","thumbnail"]},IBbsArticle:{description:"Article entity.\n\n`IBbsArticle` is an entity representing an article in the BBS (Bulletin Board System).",type:"object",properties:{id:{description:"Primary Key.",type:"string",format:"uuid"},created_at:{description:"Creation time of the article.",type:"string",format:"date-time"},updated_at:{description:"Last updated time of the article.",type:"string",format:"date-time"},title:{description:`Title of the article.
20
+
21
+ Representative title of the article.`,type:"string"},body:{description:`Content body.
22
+
23
+ Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{description:`Thumbnail image URI.
24
+
25
+ Thumbnail image URI which can represent the article.
26
+
27
+ If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",format:"uri",contentMediaType:"image/*"}]}},required:["id","created_at","updated_at","title","body","thumbnail"]}}},output:{$ref:"#/$defs/IBbsArticle"},description:`Create a new article.
28
+
29
+ Writes a new article and archives it into the DB.`,validate:(()=>{const s=e=>typeof e.input=="object"&&e.input!==null&&u(e.input),u=e=>typeof e.title=="string"&&typeof e.body=="string"&&(e.thumbnail===null||typeof e.thumbnail=="string"&&m(e.thumbnail)),f=(e,i,r=!0)=>[(typeof e.input=="object"&&e.input!==null||n(r,{path:i+".input",expected:"IBbsArticle.ICreate",value:e.input}))&&h(e.input,i+".input",r)||n(r,{path:i+".input",expected:"IBbsArticle.ICreate",value:e.input})].every(l=>l),h=(e,i,r=!0)=>[typeof e.title=="string"||n(r,{path:i+".title",expected:"string",value:e.title}),typeof e.body=="string"||n(r,{path:i+".body",expected:"string",value:e.body}),e.thumbnail===null||typeof e.thumbnail=="string"&&(m(e.thumbnail)||n(r,{path:i+".thumbnail",expected:'string & Format<"uri">',value:e.thumbnail}))||n(r,{path:i+".thumbnail",expected:'((string & Format<"uri"> & ContentMediaType<"image/*">) | null)',value:e.thumbnail})].every(l=>l),p=e=>typeof e=="object"&&e!==null&&s(e);let o,n;return e=>{if(p(e)===!1){o=[],n=_(o),((r,l,C=!0)=>(typeof r=="object"&&r!==null||n(!0,{path:l+"",expected:"__type",value:r}))&&f(r,l+"",!0)||n(!0,{path:l+"",expected:"__type",value:r}))(e,"$input",!0);const i=o.length===0;return i?{success:i,data:e}:{success:i,errors:o,data:e}}return{success:!0,data:e}}})()},{name:"update",parameters:{description:" Properties of update function",type:"object",properties:{id:{description:"Target article's {@link IBbsArticle.id}.",type:"string",format:"uuid"},input:{description:"New content to update.",$ref:"#/$defs/PartialIBbsArticle.ICreate"}},required:["id","input"],additionalProperties:!1,$defs:{"PartialIBbsArticle.ICreate":{description:"Make all properties in T optional",type:"object",properties:{title:{description:`Title of the article.
30
+
31
+ Representative title of the article.`,type:"string"},body:{description:`Content body.
32
+
33
+ Content body of the article writtn in the markdown format.`,type:"string"},thumbnail:{description:`Thumbnail image URI.
34
+
35
+ Thumbnail image URI which can represent the article.
36
+
37
+ If configured as \`null\`, it means that no thumbnail image in the article.`,anyOf:[{type:"null"},{type:"string",format:"uri",contentMediaType:"image/*"}]}},required:[]}}},description:`Update an article.
38
+
39
+ Updates an article with new content.`,validate:(()=>{const s=e=>typeof e.id=="string"&&y(e.id)&&typeof e.input=="object"&&e.input!==null&&Array.isArray(e.input)===!1&&u(e.input),u=e=>(e.title===void 0||typeof e.title=="string")&&(e.body===void 0||typeof e.body=="string")&&(e.thumbnail===null||e.thumbnail===void 0||typeof e.thumbnail=="string"&&m(e.thumbnail)),f=(e,i,r=!0)=>[typeof e.id=="string"&&(y(e.id)||n(r,{path:i+".id",expected:'string & Format<"uuid">',value:e.id}))||n(r,{path:i+".id",expected:'(string & Format<"uuid">)',value:e.id}),(typeof e.input=="object"&&e.input!==null&&Array.isArray(e.input)===!1||n(r,{path:i+".input",expected:"Partial<IBbsArticle.ICreate>",value:e.input}))&&h(e.input,i+".input",r)||n(r,{path:i+".input",expected:"Partial<IBbsArticle.ICreate>",value:e.input})].every(l=>l),h=(e,i,r=!0)=>[e.title===void 0||typeof e.title=="string"||n(r,{path:i+".title",expected:"(string | undefined)",value:e.title}),e.body===void 0||typeof e.body=="string"||n(r,{path:i+".body",expected:"(string | undefined)",value:e.body}),e.thumbnail===null||e.thumbnail===void 0||typeof e.thumbnail=="string"&&(m(e.thumbnail)||n(r,{path:i+".thumbnail",expected:'string & Format<"uri">',value:e.thumbnail}))||n(r,{path:i+".thumbnail",expected:'((string & Format<"uri"> & ContentMediaType<"image/*">) | null | undefined)',value:e.thumbnail})].every(l=>l),p=e=>typeof e=="object"&&e!==null&&s(e);let o,n;return e=>{if(p(e)===!1){o=[],n=_(o),((r,l,C=!0)=>(typeof r=="object"&&r!==null||n(!0,{path:l+"",expected:"__type",value:r}))&&f(r,l+"",!0)||n(!0,{path:l+"",expected:"__type",value:r}))(e,"$input",!0);const i=o.length===0;return i?{success:i,data:e}:{success:i,errors:o,data:e}}return{success:!0,data:e}}})()},{name:"erase",parameters:{description:" Properties of erase function",type:"object",properties:{id:{description:"Target article's {@link IBbsArticle.id}.",type:"string",format:"uuid"}},required:["id"],additionalProperties:!1,$defs:{}},description:`Erase an article.
40
+
41
+ Erases an article from the DB.`,validate:(()=>{const s=o=>typeof o.id=="string"&&y(o.id),u=(o,n,e=!0)=>[typeof o.id=="string"&&(y(o.id)||p(e,{path:n+".id",expected:'string & Format<"uuid">',value:o.id}))||p(e,{path:n+".id",expected:'(string & Format<"uuid">)',value:o.id})].every(i=>i),f=o=>typeof o=="object"&&o!==null&&s(o);let h,p;return o=>{if(f(o)===!1){h=[],p=_(h),((e,i,r=!0)=>(typeof e=="object"&&e!==null||p(!0,{path:i+"",expected:"__type",value:e}))&&u(e,i+"",!0)||p(!0,{path:i+"",expected:"__type",value:e}))(o,"$input",!0);const n=h.length===0;return n?{success:n,data:o}:{success:n,errors:h,data:o}}return{success:!0,data:o}}})()}]},execute:t}],config:{locale:c.locale,timezone:c.timezone}});return d.jsx(P,{agent:a})}function J(){const[c,t]=g.useState(j.defaultConfig()),[a,s]=g.useState(window.navigator.language),[u,f]=g.useState(!1);return d.jsx("div",{style:{width:"100%",height:"100%",overflow:u===!0?void 0:"auto"},children:u===!0?d.jsx(G,{api:new z({apiKey:c.apiKey,baseURL:c.baseURL,dangerouslyAllowBrowser:!0}),vendorModel:c.vendorModel,locale:a}):d.jsxs(O,{style:{width:"calc(100% - 60px)",padding:15,margin:15},children:[d.jsx(b,{variant:"h6",children:"BBS AI Chatbot"}),d.jsx("br",{}),d.jsx(D,{}),d.jsx("br",{}),"Demonstration of Agentica with TypeScript Controller Class.",d.jsx("br",{}),d.jsx("br",{}),d.jsx(b,{variant:"h6",children:" OpenAI Configuration "}),d.jsx("br",{}),d.jsx(j,{config:c,onChange:t}),d.jsx("br",{}),d.jsx(b,{variant:"h6",children:" Membership Information "}),d.jsx("br",{}),d.jsx(q,{onChange:h=>s(h.target.value),defaultValue:a,label:"Locale",variant:"outlined",error:a.length===0}),d.jsx("br",{}),d.jsx("br",{}),d.jsx(E,{component:"a",fullWidth:!0,variant:"contained",color:"info",size:"large",disabled:c.apiKey.length===0||c.vendorModel.length===0||a.length===0,onClick:()=>f(!0),children:"Start AI Chatbot"})]})})}A(window.document.getElementById("root")).render(d.jsx(J,{}));