@@ -6,11 +6,12 @@ import {
66 HttpLlm ,
77 OpenApi ,
88} from "@samchon/openapi" ;
9+ import { Suspense , use } from "react" ;
910import typia from "typia" ;
1011
1112import { AgenticaChatApplication } from "../../AgenticaChatApplication" ;
1213
13- export function ShoppingChatApplicationSkeleton ( ) {
14+ function ShoppingChatApplicationSkeleton ( ) {
1415 return (
1516 < div >
1617 < h2 > Loading Swagger document</ h2 >
@@ -21,38 +22,58 @@ export function ShoppingChatApplicationSkeleton() {
2122 ) ;
2223}
2324
24- export async function ShoppingChatApplication ( props : ShoppingChatApplication . IProps ) {
25- const application = HttpLlm . application ( {
26- model : props . schemaModel ,
27- document : OpenApi . convert (
28- await fetch (
29- "https://raw.githubusercontent.com/samchon/shopping-backend/refs/heads/master/packages/api/customer.swagger.json" ,
30- )
31- . then ( async r => r . json ( ) as unknown )
32- . then ( v => typia . assert < Parameters < typeof OpenApi . convert > [ 0 ] > ( v ) ) ,
33- ) ,
34- } ) ;
25+ function AsyncAgenticaChatApplication ( { agentPromise, title } : { agentPromise : Promise < Agentica < ILlmSchema . Model > > ; title : string } ) {
26+ const agent = use ( agentPromise ) ;
27+ return (
28+ < AgenticaChatApplication
29+ agent = { agent }
30+ title = { title }
31+ />
32+ ) ;
33+ }
3534
36- const agent : Agentica < ILlmSchema . Model > = new Agentica ( {
37- model : props . schemaModel ,
38- vendor : {
39- api : props . api ,
40- model : props . vendorModel ,
41- } ,
42- controllers : [
43- {
44- protocol : "http" ,
45- name : "main" ,
46- application,
47- connection : props . connection ,
35+ export function ShoppingChatApplication ( props : ShoppingChatApplication . IProps ) {
36+ const getAgent = async ( ) => {
37+ const application = HttpLlm . application ( {
38+ model : props . schemaModel ,
39+ document : OpenApi . convert (
40+ await fetch (
41+ "https://raw.githubusercontent.com/samchon/shopping-backend/refs/heads/master/packages/api/customer.swagger.json" ,
42+ )
43+ . then ( async r => r . json ( ) as unknown )
44+ . then ( v => typia . assert < Parameters < typeof OpenApi . convert > [ 0 ] > ( v ) ) ,
45+ ) ,
46+ } ) ;
47+ const agent : Agentica < ILlmSchema . Model > = new Agentica ( {
48+ model : props . schemaModel ,
49+ vendor : {
50+ api : props . api ,
51+ model : props . vendorModel ,
4852 } ,
49- ] ,
50- config : {
51- locale : props . locale ,
52- } ,
53- } ) ;
53+ controllers : [
54+ {
55+ protocol : "http" ,
56+ name : "main" ,
57+ application,
58+ connection : props . connection ,
59+ } ,
60+ ] ,
61+ config : {
62+ locale : props . locale ,
63+ } ,
64+ } ) ;
65+ return agent ;
66+ } ;
67+
68+ const agentPromise = getAgent ( ) ;
69+
5470 return (
55- < AgenticaChatApplication agent = { agent } title = "Agentica Shopping Chatbot" />
71+ < Suspense fallback = { < ShoppingChatApplicationSkeleton /> } >
72+ < AsyncAgenticaChatApplication
73+ agentPromise = { agentPromise }
74+ title = "Agentica Shopping Chatbot"
75+ />
76+ </ Suspense >
5677 ) ;
5778}
5879export namespace ShoppingChatApplication {
0 commit comments