@agentica/chat 0.1.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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/assets/AgenticaChatApplication-BAduZMpY.js +4092 -0
- package/dist/assets/Divider-D4B39gYv.js +1 -0
- package/dist/assets/OpenApi-C5xvfAk3.js +1 -0
- package/dist/assets/_isFormatUri-YqTfGpHo.js +1 -0
- package/dist/assets/bbs-Ds5p4_Sb.js +89 -0
- package/dist/assets/client-BwmHWUFW.js +141 -0
- package/dist/assets/index-BZb7BC3J.js +1 -0
- package/dist/assets/playground-BHs_VQiq.js +27 -0
- package/dist/assets/shopping-DB4jM1UG.js +1 -0
- package/dist/bbs.html +26 -0
- package/dist/index.html +24 -0
- package/dist/playground.html +25 -0
- package/dist/shopping.html +27 -0
- package/lib/AgenticaChatApplication.d.ts +8 -0
- package/lib/components/MarkdownViewer.d.ts +6 -0
- package/lib/examples/bbs/BbsArticleService.d.ts +58 -0
- package/lib/examples/bbs/BbsChatApplication.d.ts +10 -0
- package/lib/examples/bbs/IBbsArticle.d.ts +53 -0
- package/lib/examples/bbs/index.d.ts +1 -0
- package/lib/examples/index.d.ts +1 -0
- package/lib/examples/playground/AgenticaChatPlaygroundApplication.d.ts +9 -0
- package/lib/examples/playground/AgenticaChatPlaygroundFileUploadMovie.d.ts +7 -0
- package/lib/examples/playground/index.d.ts +1 -0
- package/lib/examples/shopping/ShoppingChatApplication.d.ts +12 -0
- package/lib/examples/shopping/index.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +537 -0
- package/lib/index.mjs.map +1 -0
- package/lib/movies/AgenticaChatMovie.d.ts +8 -0
- package/lib/movies/messages/AgenticaChatDescribeMessageMovie.d.ts +8 -0
- package/lib/movies/messages/AgenticaChatExecuteMessageMovie.d.ts +8 -0
- package/lib/movies/messages/AgenticaChatMessageMovie.d.ts +8 -0
- package/lib/movies/messages/AgenticaChatSelectMessageMovie.d.ts +8 -0
- package/lib/movies/messages/AgenticaChatTextMessageMovie.d.ts +7 -0
- package/lib/movies/sides/AgenticaChatFunctionStackSideMovie.d.ts +8 -0
- package/lib/movies/sides/AgenticaChatSideMovie.d.ts +12 -0
- package/lib/movies/sides/AgenticaChatTokenUsageSideMovie.d.ts +7 -0
- package/package.json +93 -0
- package/src/AgenticaChatApplication.tsx +15 -0
- package/src/components/MarkdownViewer.tsx +32 -0
- package/src/index.ts +1 -0
- package/src/movies/AgenticaChatMovie.tsx +330 -0
- package/src/movies/messages/AgenticaChatDescribeMessageMovie.tsx +62 -0
- package/src/movies/messages/AgenticaChatExecuteMessageMovie.tsx +43 -0
- package/src/movies/messages/AgenticaChatMessageMovie.tsx +25 -0
- package/src/movies/messages/AgenticaChatSelectMessageMovie.tsx +68 -0
- package/src/movies/messages/AgenticaChatTextMessageMovie.tsx +46 -0
- package/src/movies/sides/AgenticaChatFunctionStackSideMovie.tsx +46 -0
- package/src/movies/sides/AgenticaChatSideMovie.tsx +65 -0
- package/src/movies/sides/AgenticaChatTokenUsageSideMovie.tsx +78 -0
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@agentica/chat",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "./lib/index.mjs",
|
|
6
|
+
"typings": "./lib/index.d.ts",
|
|
7
|
+
"description": "Frontend Application of Agentica",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npm run build:static && npm run build:lib",
|
|
10
|
+
"build:static": "rimraf dist && tsc -b && vite build",
|
|
11
|
+
"build:lib": "rimraf lib && tsc --project tsconfig.lib.json --emitDeclarationOnly && rollup -c",
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"prepare": "ts-patch install",
|
|
15
|
+
"preview": "vite preview",
|
|
16
|
+
"deploy": "node build/deploy.mjs"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/wrtnlabs/agentica"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"openapi",
|
|
24
|
+
"swagger",
|
|
25
|
+
"generator",
|
|
26
|
+
"typescript",
|
|
27
|
+
"editor",
|
|
28
|
+
"sdk",
|
|
29
|
+
"nestjs",
|
|
30
|
+
"nestia"
|
|
31
|
+
],
|
|
32
|
+
"author": "Wrtn Technologies",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/wrtnlabs/agentica/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://wrtnlabs.io/agentica",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@mui/icons-material": "^6.4.0",
|
|
40
|
+
"@mui/material": "^6.4.0",
|
|
41
|
+
"@samchon/openapi": "^3.0.0",
|
|
42
|
+
"@agentica/core": "workspace:^",
|
|
43
|
+
"html2canvas": "^1.4.1",
|
|
44
|
+
"js-file-download": "^0.4.12",
|
|
45
|
+
"openai": "^4.80.0",
|
|
46
|
+
"react-markdown": "^9.0.3",
|
|
47
|
+
"rehype-raw": "^7.0.0",
|
|
48
|
+
"rehype-stringify": "^10.0.1",
|
|
49
|
+
"remark-mermaid-plugin": "^1.0.2",
|
|
50
|
+
"typia": "^8.0.0",
|
|
51
|
+
"uuid": "^11.0.5"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/js": "^9.13.0",
|
|
55
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
56
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
57
|
+
"@ryoppippi/unplugin-typia": "^1.2.0",
|
|
58
|
+
"@samchon/shopping-api": "^0.16.0",
|
|
59
|
+
"@types/js-yaml": "^4.0.9",
|
|
60
|
+
"@types/node": "^22.10.5",
|
|
61
|
+
"@types/react": "^18.3.11",
|
|
62
|
+
"@types/react-dom": "^18.3.1",
|
|
63
|
+
"@types/react-json-editor-ajrm": "^2.5.6",
|
|
64
|
+
"@types/uuid": "^10.0.0",
|
|
65
|
+
"@vitejs/plugin-react": "^4.3.3",
|
|
66
|
+
"eslint": "^9.13.0",
|
|
67
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
68
|
+
"eslint-plugin-react-refresh": "^0.4.13",
|
|
69
|
+
"gh-pages": "^6.3.0",
|
|
70
|
+
"globals": "^15.11.0",
|
|
71
|
+
"js-yaml": "^4.1.0",
|
|
72
|
+
"openai": "^4.82.0",
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"react-dom": "^18.3.1",
|
|
75
|
+
"react-json-editor-ajrm": "^2.5.14",
|
|
76
|
+
"react-mui-fileuploader": "^0.5.2",
|
|
77
|
+
"rimraf": "^6.0.1",
|
|
78
|
+
"rollup": "^4.24.2",
|
|
79
|
+
"ts-patch": "^3.3.0",
|
|
80
|
+
"typescript": "~5.8.2",
|
|
81
|
+
"typescript-eslint": "^8.10.0",
|
|
82
|
+
"vite": "^5.4.9"
|
|
83
|
+
},
|
|
84
|
+
"files": [
|
|
85
|
+
"README.md",
|
|
86
|
+
"LICENSE",
|
|
87
|
+
"package.json",
|
|
88
|
+
"dist",
|
|
89
|
+
"lib",
|
|
90
|
+
"src",
|
|
91
|
+
"!src/examples"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Agentica } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AgenticaChatMovie } from "./movies/AgenticaChatMovie";
|
|
5
|
+
|
|
6
|
+
export const AgenticaChatApplication = <Model extends ILlmSchema.Model>({
|
|
7
|
+
agent,
|
|
8
|
+
}: AgenticaChatApplication.IProps<Model>) => {
|
|
9
|
+
return <AgenticaChatMovie agent={agent} />;
|
|
10
|
+
};
|
|
11
|
+
export namespace AgenticaChatApplication {
|
|
12
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
13
|
+
agent: Agentica<Model>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Markdown from "react-markdown";
|
|
2
|
+
import rehypeRaw from "rehype-raw";
|
|
3
|
+
import rehypeStringify from "rehype-stringify";
|
|
4
|
+
import remarkMermaidPlugin from "remark-mermaid-plugin";
|
|
5
|
+
|
|
6
|
+
export const MarkdownViewer = (props: MarkdownViewer.IProps) => {
|
|
7
|
+
return (
|
|
8
|
+
<Markdown
|
|
9
|
+
remarkPlugins={[remarkMermaidPlugin as any]}
|
|
10
|
+
rehypePlugins={[rehypeRaw, rehypeStringify]}
|
|
11
|
+
components={{
|
|
12
|
+
img: ({ ...props }) => (
|
|
13
|
+
<img
|
|
14
|
+
{...props}
|
|
15
|
+
style={{
|
|
16
|
+
display: "block",
|
|
17
|
+
maxWidth: "100%",
|
|
18
|
+
height: "auto",
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{props.children}
|
|
25
|
+
</Markdown>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export namespace MarkdownViewer {
|
|
29
|
+
export interface IProps {
|
|
30
|
+
children: string | null | undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AgenticaChatApplication";
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Agentica,
|
|
3
|
+
IAgenticaEvent,
|
|
4
|
+
IAgenticaOperationSelection,
|
|
5
|
+
IAgenticaPrompt,
|
|
6
|
+
IAgenticaTokenUsage,
|
|
7
|
+
} from "@agentica/core";
|
|
8
|
+
import AddAPhotoIcon from "@mui/icons-material/AddAPhoto";
|
|
9
|
+
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
|
10
|
+
import SendIcon from "@mui/icons-material/Send";
|
|
11
|
+
import {
|
|
12
|
+
AppBar,
|
|
13
|
+
Button,
|
|
14
|
+
Container,
|
|
15
|
+
Drawer,
|
|
16
|
+
IconButton,
|
|
17
|
+
Input,
|
|
18
|
+
Theme,
|
|
19
|
+
Toolbar,
|
|
20
|
+
Typography,
|
|
21
|
+
useMediaQuery,
|
|
22
|
+
useTheme,
|
|
23
|
+
} from "@mui/material";
|
|
24
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
25
|
+
import html2canvas from "html2canvas";
|
|
26
|
+
import fileDownload from "js-file-download";
|
|
27
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
28
|
+
|
|
29
|
+
import { AgenticaChatMessageMovie } from "./messages/AgenticaChatMessageMovie";
|
|
30
|
+
import { AgenticaChatSideMovie } from "./sides/AgenticaChatSideMovie";
|
|
31
|
+
|
|
32
|
+
export const AgenticaChatMovie = <Model extends ILlmSchema.Model>({
|
|
33
|
+
agent,
|
|
34
|
+
}: AgenticaChatMovie.IProps<Model>) => {
|
|
35
|
+
//----
|
|
36
|
+
// VARIABLES
|
|
37
|
+
//----
|
|
38
|
+
// REFERENCES
|
|
39
|
+
const upperDivRef = useRef<HTMLDivElement>(null);
|
|
40
|
+
const middleDivRef = useRef<HTMLDivElement>(null);
|
|
41
|
+
const bottomDivRef = useRef<HTMLDivElement>(null);
|
|
42
|
+
const bodyContainerRef = useRef<HTMLDivElement>(null);
|
|
43
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
44
|
+
|
|
45
|
+
// STATES
|
|
46
|
+
const [error, setError] = useState<Error | null>(null);
|
|
47
|
+
const [text, setText] = useState("");
|
|
48
|
+
const [histories, setHistories] = useState<IAgenticaPrompt<Model>[]>(
|
|
49
|
+
agent.getPromptHistories().slice(),
|
|
50
|
+
);
|
|
51
|
+
const [tokenUsage, setTokenUsage] = useState<IAgenticaTokenUsage>(
|
|
52
|
+
JSON.parse(JSON.stringify(agent.getTokenUsage())),
|
|
53
|
+
);
|
|
54
|
+
const [height, setHeight] = useState(122);
|
|
55
|
+
const [enabled, setEnabled] = useState(true);
|
|
56
|
+
const [selections, setSelections] = useState<
|
|
57
|
+
IAgenticaOperationSelection<Model>[]
|
|
58
|
+
>([]);
|
|
59
|
+
const [openSide, setOpenSide] = useState(false);
|
|
60
|
+
|
|
61
|
+
//----
|
|
62
|
+
// EVENT INTERACTIONS
|
|
63
|
+
//----
|
|
64
|
+
// EVENT LISTENERS
|
|
65
|
+
const handleText = (evt: IAgenticaEvent.IText) => {
|
|
66
|
+
histories.push(evt);
|
|
67
|
+
setHistories(histories);
|
|
68
|
+
};
|
|
69
|
+
const handleDescribe = (evt: IAgenticaEvent.IDescribe<Model>) => {
|
|
70
|
+
histories.push(evt);
|
|
71
|
+
setHistories(histories);
|
|
72
|
+
};
|
|
73
|
+
const handleSelect = (evt: IAgenticaEvent.ISelect<Model>) => {
|
|
74
|
+
histories.push({
|
|
75
|
+
type: "select",
|
|
76
|
+
id: "something",
|
|
77
|
+
operations: [
|
|
78
|
+
{
|
|
79
|
+
...evt.operation,
|
|
80
|
+
reason: evt.reason,
|
|
81
|
+
toJSON: () => ({}) as any,
|
|
82
|
+
} satisfies IAgenticaOperationSelection<Model>,
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
setHistories(histories);
|
|
86
|
+
|
|
87
|
+
selections.push({
|
|
88
|
+
...evt.operation,
|
|
89
|
+
reason: evt.reason,
|
|
90
|
+
toJSON: () => ({}) as any,
|
|
91
|
+
} satisfies IAgenticaOperationSelection<Model>);
|
|
92
|
+
setSelections(selections);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// INITIALIZATION
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (inputRef.current !== null) inputRef.current.select();
|
|
98
|
+
agent.on("text", handleText);
|
|
99
|
+
agent.on("describe", handleDescribe);
|
|
100
|
+
agent.on("select", handleSelect);
|
|
101
|
+
setTokenUsage(agent.getTokenUsage());
|
|
102
|
+
return () => {
|
|
103
|
+
agent.off("text", handleText);
|
|
104
|
+
agent.off("describe", handleDescribe);
|
|
105
|
+
agent.off("select", handleSelect);
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
// EVENT HANDLERS
|
|
110
|
+
const handleKeyUp = async (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
111
|
+
if (event.key === "Enter" && event.shiftKey === false) {
|
|
112
|
+
if (enabled === false) event.preventDefault();
|
|
113
|
+
else await conversate();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleResize = () => {
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
if (
|
|
120
|
+
upperDivRef.current === null ||
|
|
121
|
+
middleDivRef.current === null ||
|
|
122
|
+
bottomDivRef.current === null
|
|
123
|
+
)
|
|
124
|
+
return;
|
|
125
|
+
const newHeight: number =
|
|
126
|
+
upperDivRef.current.clientHeight + bottomDivRef.current.clientHeight;
|
|
127
|
+
if (newHeight !== height) setHeight(newHeight);
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const conversate = async () => {
|
|
132
|
+
setText("");
|
|
133
|
+
setEnabled(false);
|
|
134
|
+
handleResize();
|
|
135
|
+
try {
|
|
136
|
+
await agent.conversate(text);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof Error) {
|
|
139
|
+
alert(error.message);
|
|
140
|
+
setError(error);
|
|
141
|
+
} else setError(new Error("Unknown error"));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
histories.splice(0, histories.length);
|
|
146
|
+
histories.push(...agent.getPromptHistories());
|
|
147
|
+
setHistories(histories);
|
|
148
|
+
setTokenUsage(agent.getTokenUsage());
|
|
149
|
+
setEnabled(true);
|
|
150
|
+
|
|
151
|
+
const selections: IAgenticaOperationSelection<Model>[] = agent
|
|
152
|
+
.getPromptHistories()
|
|
153
|
+
.filter((h) => h.type === "select")
|
|
154
|
+
.map((h) => h.operations)
|
|
155
|
+
.flat();
|
|
156
|
+
for (const cancel of agent
|
|
157
|
+
.getPromptHistories()
|
|
158
|
+
.filter((h) => h.type === "cancel")
|
|
159
|
+
.map((h) => h.operations)
|
|
160
|
+
.flat()) {
|
|
161
|
+
const index: number = selections.findIndex(
|
|
162
|
+
(s) =>
|
|
163
|
+
s.protocol === cancel.protocol &&
|
|
164
|
+
s.controller.name === cancel.controller.name &&
|
|
165
|
+
s.function.name === cancel.function.name,
|
|
166
|
+
);
|
|
167
|
+
if (index !== -1) selections.splice(index, 1);
|
|
168
|
+
}
|
|
169
|
+
setSelections(selections);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const capture = async () => {
|
|
173
|
+
if (bodyContainerRef.current === null) return;
|
|
174
|
+
const canvas: HTMLCanvasElement = await html2canvas(
|
|
175
|
+
bodyContainerRef.current,
|
|
176
|
+
{
|
|
177
|
+
scrollX: 0,
|
|
178
|
+
scrollY: 0,
|
|
179
|
+
width: bodyContainerRef.current.scrollWidth,
|
|
180
|
+
height: bodyContainerRef.current.scrollHeight,
|
|
181
|
+
useCORS: true,
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
canvas.toBlob((blob) => {
|
|
185
|
+
if (blob === null) return;
|
|
186
|
+
fileDownload(blob, "nestia-chat-screenshot.png");
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
//----
|
|
191
|
+
// RENDERERS
|
|
192
|
+
//----
|
|
193
|
+
const theme: Theme = useTheme();
|
|
194
|
+
const isMobile: boolean = useMediaQuery(theme.breakpoints.down("lg"));
|
|
195
|
+
const bodyMovie = (): JSX.Element => (
|
|
196
|
+
<Container
|
|
197
|
+
ref={bodyContainerRef}
|
|
198
|
+
maxWidth={false}
|
|
199
|
+
style={{
|
|
200
|
+
marginBottom: 15,
|
|
201
|
+
paddingBottom: 50,
|
|
202
|
+
width: isMobile ? "100%" : `calc(100% - ${SIDE_WIDTH}px)`,
|
|
203
|
+
height: "100%",
|
|
204
|
+
overflowY: "scroll",
|
|
205
|
+
backgroundColor: "lightblue",
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
{histories
|
|
209
|
+
.map((prompt) => <AgenticaChatMessageMovie prompt={prompt} />)
|
|
210
|
+
.filter((elem) => elem !== null)}
|
|
211
|
+
</Container>
|
|
212
|
+
);
|
|
213
|
+
const sideMovie = (): JSX.Element => (
|
|
214
|
+
<div
|
|
215
|
+
style={{
|
|
216
|
+
width: isMobile ? undefined : SIDE_WIDTH,
|
|
217
|
+
height: "100%",
|
|
218
|
+
overflowY: "auto",
|
|
219
|
+
backgroundColor: "#eeeeee",
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<Container
|
|
223
|
+
maxWidth={false}
|
|
224
|
+
onClick={isMobile ? () => setOpenSide(false) : undefined}
|
|
225
|
+
>
|
|
226
|
+
<AgenticaChatSideMovie
|
|
227
|
+
vendor={agent.getVendor()}
|
|
228
|
+
config={agent.getConfig()}
|
|
229
|
+
usage={tokenUsage}
|
|
230
|
+
selections={selections}
|
|
231
|
+
error={error}
|
|
232
|
+
/>
|
|
233
|
+
</Container>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<div style={{ width: "100%", height: "100%" }}>
|
|
239
|
+
<AppBar ref={upperDivRef} position="relative" component="div">
|
|
240
|
+
<Toolbar>
|
|
241
|
+
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
|
|
242
|
+
Agentica Chatbot
|
|
243
|
+
</Typography>
|
|
244
|
+
{isMobile ? (
|
|
245
|
+
<>
|
|
246
|
+
<IconButton onClick={capture}>
|
|
247
|
+
<AddAPhotoIcon />
|
|
248
|
+
</IconButton>
|
|
249
|
+
<IconButton onClick={() => setOpenSide(true)}>
|
|
250
|
+
<ReceiptLongIcon />
|
|
251
|
+
</IconButton>
|
|
252
|
+
</>
|
|
253
|
+
) : (
|
|
254
|
+
<Button
|
|
255
|
+
color="inherit"
|
|
256
|
+
startIcon={<AddAPhotoIcon />}
|
|
257
|
+
onClick={capture}
|
|
258
|
+
>
|
|
259
|
+
Screenshot Capture
|
|
260
|
+
</Button>
|
|
261
|
+
)}
|
|
262
|
+
</Toolbar>
|
|
263
|
+
</AppBar>
|
|
264
|
+
<div
|
|
265
|
+
ref={middleDivRef}
|
|
266
|
+
style={{
|
|
267
|
+
width: "100%",
|
|
268
|
+
height: `calc(100% - ${height}px)`,
|
|
269
|
+
display: "flex",
|
|
270
|
+
flexDirection: "row",
|
|
271
|
+
}}
|
|
272
|
+
>
|
|
273
|
+
{isMobile ? (
|
|
274
|
+
<>
|
|
275
|
+
{bodyMovie()}
|
|
276
|
+
<Drawer
|
|
277
|
+
anchor="right"
|
|
278
|
+
open={openSide}
|
|
279
|
+
onClose={() => setOpenSide(false)}
|
|
280
|
+
>
|
|
281
|
+
{sideMovie()}
|
|
282
|
+
</Drawer>
|
|
283
|
+
</>
|
|
284
|
+
) : (
|
|
285
|
+
<>
|
|
286
|
+
{bodyMovie()}
|
|
287
|
+
{sideMovie()}
|
|
288
|
+
</>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
<AppBar
|
|
292
|
+
ref={bottomDivRef}
|
|
293
|
+
position="static"
|
|
294
|
+
component="div"
|
|
295
|
+
color="inherit"
|
|
296
|
+
>
|
|
297
|
+
<Toolbar>
|
|
298
|
+
<Input
|
|
299
|
+
inputRef={inputRef}
|
|
300
|
+
fullWidth
|
|
301
|
+
placeholder="Conversate with AI Chatbot"
|
|
302
|
+
value={text}
|
|
303
|
+
multiline={true}
|
|
304
|
+
onKeyUp={handleKeyUp}
|
|
305
|
+
onChange={(e) => {
|
|
306
|
+
setText(e.target.value);
|
|
307
|
+
handleResize();
|
|
308
|
+
}}
|
|
309
|
+
/>
|
|
310
|
+
<Button
|
|
311
|
+
variant="contained"
|
|
312
|
+
style={{ marginLeft: 10 }}
|
|
313
|
+
startIcon={<SendIcon />}
|
|
314
|
+
disabled={!enabled}
|
|
315
|
+
onClick={conversate}
|
|
316
|
+
>
|
|
317
|
+
Send
|
|
318
|
+
</Button>
|
|
319
|
+
</Toolbar>
|
|
320
|
+
</AppBar>
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
};
|
|
324
|
+
export namespace AgenticaChatMovie {
|
|
325
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
326
|
+
agent: Agentica<Model>;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const SIDE_WIDTH = 450;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IAgenticaPrompt } from "@agentica/core";
|
|
2
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Card,
|
|
6
|
+
CardActions,
|
|
7
|
+
CardContent,
|
|
8
|
+
Chip,
|
|
9
|
+
Collapse,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
|
|
14
|
+
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
15
|
+
import { AgenticaChatExecuteMessageMovie } from "./AgenticaChatExecuteMessageMovie";
|
|
16
|
+
|
|
17
|
+
export const AgenticaChatDescribeMessageMovie = <Model extends ILlmSchema.Model>({
|
|
18
|
+
prompt,
|
|
19
|
+
}: AgenticaChatDescribeMessageMovie.IProps<Model>) => {
|
|
20
|
+
const [expanded, setExpanded] = useState(false);
|
|
21
|
+
return (
|
|
22
|
+
<Card
|
|
23
|
+
elevation={3}
|
|
24
|
+
style={{
|
|
25
|
+
marginTop: 15,
|
|
26
|
+
marginBottom: 15,
|
|
27
|
+
marginRight: "15%",
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
<CardContent>
|
|
31
|
+
<Chip label="Function Describer" variant="outlined" color="secondary" />
|
|
32
|
+
<MarkdownViewer>{prompt.text}</MarkdownViewer>
|
|
33
|
+
</CardContent>
|
|
34
|
+
<CardActions style={{ textAlign: "right" }}>
|
|
35
|
+
<Button
|
|
36
|
+
startIcon={
|
|
37
|
+
<ExpandMoreIcon
|
|
38
|
+
style={{
|
|
39
|
+
transform: `rotate(${expanded ? 180 : 0}deg)`,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
}
|
|
43
|
+
onClick={() => setExpanded(!expanded)}
|
|
44
|
+
>
|
|
45
|
+
{expanded ? "Hide Function Calls" : "Show Function Calls"}
|
|
46
|
+
</Button>
|
|
47
|
+
</CardActions>
|
|
48
|
+
<Collapse in={expanded} timeout="auto" unmountOnExit>
|
|
49
|
+
<CardContent>
|
|
50
|
+
{prompt.executions.map((execute) => (
|
|
51
|
+
<AgenticaChatExecuteMessageMovie execute={execute} />
|
|
52
|
+
))}
|
|
53
|
+
</CardContent>
|
|
54
|
+
</Collapse>
|
|
55
|
+
</Card>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
export namespace AgenticaChatDescribeMessageMovie {
|
|
59
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
60
|
+
prompt: IAgenticaPrompt.IDescribe<Model>;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IAgenticaPrompt } from "@agentica/core";
|
|
2
|
+
import { Typography } from "@mui/material";
|
|
3
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
7
|
+
|
|
8
|
+
export const AgenticaChatExecuteMessageMovie = <Model extends ILlmSchema.Model>({
|
|
9
|
+
execute,
|
|
10
|
+
}: AgenticaChatExecuteMessageMovie.IProps<Model>) => {
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Typography variant="h5"> {getTitle(execute)} </Typography>
|
|
14
|
+
<hr />
|
|
15
|
+
<Typography variant="h6"> Description </Typography>
|
|
16
|
+
<MarkdownViewer>{execute.function.description}</MarkdownViewer>
|
|
17
|
+
<br />
|
|
18
|
+
<Typography variant="h6"> Arguments </Typography>
|
|
19
|
+
<MarkdownViewer>
|
|
20
|
+
{["```json", JSON.stringify(execute.arguments, null, 2), "```"].join(
|
|
21
|
+
"\n",
|
|
22
|
+
)}
|
|
23
|
+
</MarkdownViewer>
|
|
24
|
+
<br />
|
|
25
|
+
<Typography variant="h6"> Return Value </Typography>
|
|
26
|
+
<MarkdownViewer>
|
|
27
|
+
{["```json", JSON.stringify(execute.value, null, 2), "```"].join("\n")}
|
|
28
|
+
</MarkdownViewer>
|
|
29
|
+
</React.Fragment>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
export namespace AgenticaChatExecuteMessageMovie {
|
|
33
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
34
|
+
execute: IAgenticaPrompt.IExecute<Model>;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const getTitle = <Model extends ILlmSchema.Model>(
|
|
39
|
+
exec: IAgenticaPrompt.IExecute<Model>,
|
|
40
|
+
) =>
|
|
41
|
+
exec.protocol === "http"
|
|
42
|
+
? `${exec.function.method.toUpperCase()} ${exec.function.path}`
|
|
43
|
+
: exec.function.name;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IAgenticaPrompt } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AgenticaChatDescribeMessageMovie } from "./AgenticaChatDescribeMessageMovie";
|
|
5
|
+
import { AgenticaChatSelectMessageMovie } from "./AgenticaChatSelectMessageMovie";
|
|
6
|
+
import { AgenticaChatTextMessageMovie } from "./AgenticaChatTextMessageMovie";
|
|
7
|
+
|
|
8
|
+
export const AgenticaChatMessageMovie = <Model extends ILlmSchema.Model>({
|
|
9
|
+
prompt,
|
|
10
|
+
}: AgenticaChatMessageMovie.IProps<Model>) => {
|
|
11
|
+
if (prompt.type === "text")
|
|
12
|
+
return <AgenticaChatTextMessageMovie prompt={prompt} />;
|
|
13
|
+
else if (prompt.type === "select")
|
|
14
|
+
return prompt.operations.map((selection) => (
|
|
15
|
+
<AgenticaChatSelectMessageMovie selection={selection} />
|
|
16
|
+
));
|
|
17
|
+
else if (prompt.type === "describe")
|
|
18
|
+
return <AgenticaChatDescribeMessageMovie prompt={prompt} />;
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
export namespace AgenticaChatMessageMovie {
|
|
22
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
23
|
+
prompt: IAgenticaPrompt<Model>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IAgenticaOperationSelection } from "@agentica/core";
|
|
2
|
+
import GradingIcon from "@mui/icons-material/Grading";
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Card,
|
|
6
|
+
CardActions,
|
|
7
|
+
CardContent,
|
|
8
|
+
Chip,
|
|
9
|
+
Collapse,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
|
|
14
|
+
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
15
|
+
|
|
16
|
+
export const AgenticaChatSelectMessageMovie = <Model extends ILlmSchema.Model>({
|
|
17
|
+
selection,
|
|
18
|
+
}: AgenticaChatSelectMessageMovie.IProps<Model>) => {
|
|
19
|
+
const [expanded, setExpanded] = useState(false);
|
|
20
|
+
return (
|
|
21
|
+
<Card
|
|
22
|
+
elevation={3}
|
|
23
|
+
style={{
|
|
24
|
+
marginTop: 15,
|
|
25
|
+
marginBottom: 15,
|
|
26
|
+
marginRight: "15%",
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<CardContent>
|
|
30
|
+
<Chip
|
|
31
|
+
icon={<GradingIcon />}
|
|
32
|
+
label="Function Selector"
|
|
33
|
+
variant="outlined"
|
|
34
|
+
color="warning"
|
|
35
|
+
/>
|
|
36
|
+
<br />
|
|
37
|
+
<br />
|
|
38
|
+
Operation:
|
|
39
|
+
{selection.protocol === "http" ? (
|
|
40
|
+
<ul>
|
|
41
|
+
<li>{selection.function.method.toUpperCase()}</li>
|
|
42
|
+
<li>{selection.function.path}</li>
|
|
43
|
+
</ul>
|
|
44
|
+
) : (
|
|
45
|
+
<ul>
|
|
46
|
+
<li>{selection.function.name}</li>
|
|
47
|
+
</ul>
|
|
48
|
+
)}
|
|
49
|
+
<MarkdownViewer>{selection.reason}</MarkdownViewer>
|
|
50
|
+
</CardContent>
|
|
51
|
+
<CardActions style={{ textAlign: "right" }}>
|
|
52
|
+
<Button onClick={() => setExpanded(!expanded)}>
|
|
53
|
+
{expanded ? "Hide Function Description" : "Show Function Description"}
|
|
54
|
+
</Button>
|
|
55
|
+
</CardActions>
|
|
56
|
+
<Collapse in={expanded} timeout="auto" unmountOnExit>
|
|
57
|
+
<CardContent>
|
|
58
|
+
<MarkdownViewer>{selection.function.description}</MarkdownViewer>
|
|
59
|
+
</CardContent>
|
|
60
|
+
</Collapse>
|
|
61
|
+
</Card>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export namespace AgenticaChatSelectMessageMovie {
|
|
65
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
66
|
+
selection: IAgenticaOperationSelection<Model>;
|
|
67
|
+
}
|
|
68
|
+
}
|