@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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/assets/AgenticaChatApplication-BAduZMpY.js +4092 -0
  4. package/dist/assets/Divider-D4B39gYv.js +1 -0
  5. package/dist/assets/OpenApi-C5xvfAk3.js +1 -0
  6. package/dist/assets/_isFormatUri-YqTfGpHo.js +1 -0
  7. package/dist/assets/bbs-Ds5p4_Sb.js +89 -0
  8. package/dist/assets/client-BwmHWUFW.js +141 -0
  9. package/dist/assets/index-BZb7BC3J.js +1 -0
  10. package/dist/assets/playground-BHs_VQiq.js +27 -0
  11. package/dist/assets/shopping-DB4jM1UG.js +1 -0
  12. package/dist/bbs.html +26 -0
  13. package/dist/index.html +24 -0
  14. package/dist/playground.html +25 -0
  15. package/dist/shopping.html +27 -0
  16. package/lib/AgenticaChatApplication.d.ts +8 -0
  17. package/lib/components/MarkdownViewer.d.ts +6 -0
  18. package/lib/examples/bbs/BbsArticleService.d.ts +58 -0
  19. package/lib/examples/bbs/BbsChatApplication.d.ts +10 -0
  20. package/lib/examples/bbs/IBbsArticle.d.ts +53 -0
  21. package/lib/examples/bbs/index.d.ts +1 -0
  22. package/lib/examples/index.d.ts +1 -0
  23. package/lib/examples/playground/AgenticaChatPlaygroundApplication.d.ts +9 -0
  24. package/lib/examples/playground/AgenticaChatPlaygroundFileUploadMovie.d.ts +7 -0
  25. package/lib/examples/playground/index.d.ts +1 -0
  26. package/lib/examples/shopping/ShoppingChatApplication.d.ts +12 -0
  27. package/lib/examples/shopping/index.d.ts +1 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.mjs +537 -0
  30. package/lib/index.mjs.map +1 -0
  31. package/lib/movies/AgenticaChatMovie.d.ts +8 -0
  32. package/lib/movies/messages/AgenticaChatDescribeMessageMovie.d.ts +8 -0
  33. package/lib/movies/messages/AgenticaChatExecuteMessageMovie.d.ts +8 -0
  34. package/lib/movies/messages/AgenticaChatMessageMovie.d.ts +8 -0
  35. package/lib/movies/messages/AgenticaChatSelectMessageMovie.d.ts +8 -0
  36. package/lib/movies/messages/AgenticaChatTextMessageMovie.d.ts +7 -0
  37. package/lib/movies/sides/AgenticaChatFunctionStackSideMovie.d.ts +8 -0
  38. package/lib/movies/sides/AgenticaChatSideMovie.d.ts +12 -0
  39. package/lib/movies/sides/AgenticaChatTokenUsageSideMovie.d.ts +7 -0
  40. package/package.json +93 -0
  41. package/src/AgenticaChatApplication.tsx +15 -0
  42. package/src/components/MarkdownViewer.tsx +32 -0
  43. package/src/index.ts +1 -0
  44. package/src/movies/AgenticaChatMovie.tsx +330 -0
  45. package/src/movies/messages/AgenticaChatDescribeMessageMovie.tsx +62 -0
  46. package/src/movies/messages/AgenticaChatExecuteMessageMovie.tsx +43 -0
  47. package/src/movies/messages/AgenticaChatMessageMovie.tsx +25 -0
  48. package/src/movies/messages/AgenticaChatSelectMessageMovie.tsx +68 -0
  49. package/src/movies/messages/AgenticaChatTextMessageMovie.tsx +46 -0
  50. package/src/movies/sides/AgenticaChatFunctionStackSideMovie.tsx +46 -0
  51. package/src/movies/sides/AgenticaChatSideMovie.tsx +65 -0
  52. package/src/movies/sides/AgenticaChatTokenUsageSideMovie.tsx +78 -0
@@ -0,0 +1,46 @@
1
+ import { IAgenticaPrompt } from "@agentica/core";
2
+ import FaceIcon from "@mui/icons-material/Face";
3
+ import SmartToyIcon from "@mui/icons-material/SmartToy";
4
+ import { Card, CardContent, Chip } from "@mui/material";
5
+
6
+ import { MarkdownViewer } from "../../components/MarkdownViewer";
7
+
8
+ export const AgenticaChatTextMessageMovie = ({
9
+ prompt,
10
+ }: AgenticaChatTextMessageMovie.IProps) => {
11
+ return (
12
+ <div
13
+ style={{
14
+ display: "flex",
15
+ justifyContent: prompt.role === "user" ? "flex-end" : "flex-start",
16
+ }}
17
+ >
18
+ <Card
19
+ elevation={3}
20
+ style={{
21
+ marginTop: 15,
22
+ marginBottom: 15,
23
+ marginLeft: prompt.role === "user" ? "15%" : undefined,
24
+ marginRight: prompt.role === "assistant" ? "15%" : undefined,
25
+ textAlign: prompt.role === "user" ? "right" : "left",
26
+ backgroundColor: prompt.role === "user" ? "lightyellow" : undefined,
27
+ }}
28
+ >
29
+ <CardContent>
30
+ <Chip
31
+ icon={prompt.role === "user" ? <FaceIcon /> : <SmartToyIcon />}
32
+ label={prompt.role === "user" ? "User" : "Assistant"}
33
+ variant="outlined"
34
+ color={prompt.role === "user" ? "primary" : "success"}
35
+ />
36
+ <MarkdownViewer>{prompt.text}</MarkdownViewer>
37
+ </CardContent>
38
+ </Card>
39
+ </div>
40
+ );
41
+ };
42
+ export namespace AgenticaChatTextMessageMovie {
43
+ export interface IProps {
44
+ prompt: IAgenticaPrompt.IText;
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ import { IAgenticaOperationSelection } from "@agentica/core";
2
+ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
3
+ import {
4
+ Accordion,
5
+ AccordionDetails,
6
+ AccordionSummary,
7
+ Typography,
8
+ } from "@mui/material";
9
+ import { ILlmSchema } from "@samchon/openapi";
10
+ import React from "react";
11
+
12
+ import { MarkdownViewer } from "../../components/MarkdownViewer";
13
+
14
+ export const AgenticaChatFunctionStackSideMovie = <Model extends ILlmSchema.Model>(
15
+ props: AgenticaChatFunctionStackSideMovie.IProps<Model>,
16
+ ) => {
17
+ return (
18
+ <React.Fragment>
19
+ <Typography variant="h5"> Function Stack </Typography>
20
+ <hr />
21
+ {props.selections.map((select) => (
22
+ <Accordion>
23
+ <AccordionSummary expandIcon={<ExpandMoreIcon />}>
24
+ <Typography component="h6">
25
+ {select.protocol === "http"
26
+ ? `${select.function.method.toUpperCase()} ${select.function.path}`
27
+ : select.function.name}
28
+ </Typography>
29
+ </AccordionSummary>
30
+ <AccordionDetails>
31
+ <hr />
32
+ {select.reason}
33
+ <br />
34
+ <br />
35
+ <MarkdownViewer>{select.function.description}</MarkdownViewer>
36
+ </AccordionDetails>
37
+ </Accordion>
38
+ ))}
39
+ </React.Fragment>
40
+ );
41
+ };
42
+ export namespace AgenticaChatFunctionStackSideMovie {
43
+ export interface IProps<Model extends ILlmSchema.Model> {
44
+ selections: IAgenticaOperationSelection<Model>[];
45
+ }
46
+ }
@@ -0,0 +1,65 @@
1
+ import {
2
+ IAgenticaConfig,
3
+ IAgenticaOperationSelection,
4
+ IAgenticaTokenUsage,
5
+ IAgenticaVendor,
6
+ } from "@agentica/core";
7
+ import { Typography } from "@mui/material";
8
+ import { ILlmSchema } from "@samchon/openapi";
9
+
10
+ import { AgenticaChatFunctionStackSideMovie } from "./AgenticaChatFunctionStackSideMovie";
11
+ import { AgenticaChatTokenUsageSideMovie } from "./AgenticaChatTokenUsageSideMovie";
12
+
13
+ export const AgenticaChatSideMovie = <Model extends ILlmSchema.Model>(
14
+ props: AgenticaChatSideMovie.IProps<Model>,
15
+ ) => {
16
+ return (
17
+ <div
18
+ style={{
19
+ padding: 25,
20
+ }}
21
+ >
22
+ {props.error !== null ? (
23
+ <>
24
+ <Typography variant="h5" color="error">
25
+ OpenAI Error
26
+ </Typography>
27
+ <hr />
28
+ {props.error.message}
29
+ <br />
30
+ <br />
31
+ Your OpenAI API key may not valid.
32
+ <br />
33
+ <br />
34
+ <br />
35
+ </>
36
+ ) : null}
37
+ <Typography variant="h5">Agent Information</Typography>
38
+ <hr />
39
+ <ul>
40
+ <li> Model: {props.vendor.model} </li>
41
+ <li> Locale: {props.config?.locale ?? navigator.language} </li>
42
+ <li>
43
+ Timezone:{" "}
44
+ {props.config?.timezone ??
45
+ Intl.DateTimeFormat().resolvedOptions().timeZone}
46
+ </li>
47
+ </ul>
48
+ <br />
49
+ <br />
50
+ <AgenticaChatTokenUsageSideMovie usage={props.usage} />
51
+ <br />
52
+ <br />
53
+ <AgenticaChatFunctionStackSideMovie selections={props.selections} />
54
+ </div>
55
+ );
56
+ };
57
+ export namespace AgenticaChatSideMovie {
58
+ export interface IProps<Model extends ILlmSchema.Model> {
59
+ vendor: IAgenticaVendor;
60
+ config: IAgenticaConfig<Model> | undefined;
61
+ usage: IAgenticaTokenUsage;
62
+ selections: IAgenticaOperationSelection<Model>[];
63
+ error: Error | null;
64
+ }
65
+ }
@@ -0,0 +1,78 @@
1
+ import { IAgenticaTokenUsage } from "@agentica/core";
2
+ import {
3
+ Table,
4
+ TableBody,
5
+ TableCell,
6
+ TableHead,
7
+ TableRow,
8
+ Typography,
9
+ } from "@mui/material";
10
+ import React from "react";
11
+
12
+ export const AgenticaChatTokenUsageSideMovie = (
13
+ props: AgenticaChatTokenUsageSideMovie.IProps,
14
+ ) => {
15
+ const price: IPrice = compute(props.usage);
16
+ return (
17
+ <React.Fragment>
18
+ <Typography variant="h5"> Token Usage </Typography>
19
+ <hr />
20
+ <Table>
21
+ <TableHead>
22
+ <TableRow>
23
+ <TableCell>Type</TableCell>
24
+ <TableCell>Token Usage</TableCell>
25
+ <TableCell>Price</TableCell>
26
+ </TableRow>
27
+ </TableHead>
28
+ <TableBody>
29
+ <TableRow>
30
+ <TableCell>Total</TableCell>
31
+ <TableCell>
32
+ {props.usage.aggregate.total.toLocaleString()}
33
+ </TableCell>
34
+ <TableCell>${price.total.toLocaleString()}</TableCell>
35
+ </TableRow>
36
+ <TableRow>
37
+ <TableCell>Input</TableCell>
38
+ <TableCell>
39
+ {props.usage.aggregate.input.total.toLocaleString()}
40
+ </TableCell>
41
+ <TableCell>${price.prompt.toLocaleString()}</TableCell>
42
+ </TableRow>
43
+ <TableRow>
44
+ <TableCell>Output</TableCell>
45
+ <TableCell>
46
+ {props.usage.aggregate.output.total.toLocaleString()}
47
+ </TableCell>
48
+ <TableCell>${price.completion.toLocaleString()}</TableCell>
49
+ </TableRow>
50
+ </TableBody>
51
+ </Table>
52
+ </React.Fragment>
53
+ );
54
+ };
55
+ export namespace AgenticaChatTokenUsageSideMovie {
56
+ export interface IProps {
57
+ usage: IAgenticaTokenUsage;
58
+ }
59
+ }
60
+
61
+ interface IPrice {
62
+ total: number;
63
+ prompt: number;
64
+ completion: number;
65
+ }
66
+
67
+ const compute = (usage: IAgenticaTokenUsage): IPrice => {
68
+ const prompt: number =
69
+ (usage.aggregate.input.total - usage.aggregate.input.cached) *
70
+ (2.5 / 1_000_000) +
71
+ usage.aggregate.input.cached * (1.25 / 1_000_000);
72
+ const completion: number = usage.aggregate.output.total * (10.0 / 1_000_000);
73
+ return {
74
+ total: prompt + completion,
75
+ prompt,
76
+ completion,
77
+ };
78
+ };