@agentica/chat 0.43.3 → 0.44.0-dev.20260313
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 -21
- package/README.md +218 -218
- package/dist/assets/{Divider-DX1xhf0M.js → Divider-Cos-Ru5Z.js} +1 -1
- package/dist/assets/VendorConfigurationMovie-C1-X-OfL.js +2126 -0
- package/dist/assets/_accessExpressionAsString-CTLekF-M.js +1 -0
- package/dist/assets/bbs/index-BQdHwlZB.js +41 -0
- package/dist/assets/client-B8OTM7em.js +141 -0
- package/dist/assets/{index-BIyKUwoU.js → index-BtWQqbio.js} +1 -1
- package/dist/assets/shopping/index.html-BG-EZSvQ.js +39 -0
- package/dist/assets/uploader/index.html-xsq3E3-m.js +17 -0
- package/dist/bbs/index.html +32 -32
- package/dist/index.html +31 -31
- package/dist/shopping/index.html +33 -33
- package/dist/uploader/index.html +32 -32
- package/lib/examples/shopping/ShoppingChatApplication.d.ts +1 -1
- package/lib/examples/uploader/AgenticaChatUploaderMovie.d.ts +1 -1
- package/lib/index.mjs +26 -26
- package/lib/index.mjs.map +1 -1
- package/package.json +7 -6
- package/src/AgenticaChatApplication.tsx +13 -13
- package/src/components/MarkdownViewer.tsx +32 -32
- package/src/index.ts +1 -1
- package/src/movies/AgenticaChatMovie.tsx +381 -381
- package/src/movies/messages/AgenticaChatAssistantMessageMovie.tsx +44 -44
- package/src/movies/messages/AgenticaChatDescribeMessageMovie.tsx +63 -63
- package/src/movies/messages/AgenticaChatExecuteMessageMovie.tsx +46 -46
- package/src/movies/messages/AgenticaChatMessageMovie.tsx +43 -43
- package/src/movies/messages/AgenticaChatSelectMessageMovie.tsx +72 -72
- package/src/movies/messages/AgenticaChatSystemMessageMovie.tsx +44 -44
- package/src/movies/messages/AgenticaChatUserMessageMovie.tsx +56 -56
- package/src/movies/sides/AgenticaChatFunctionStackSideMovie.tsx +48 -48
- package/src/movies/sides/AgenticaChatSideMovie.tsx +75 -75
- package/src/movies/sides/AgenticaChatTokenUsageSideMovie.tsx +86 -86
- package/dist/assets/VendorConfigurationMovie-Cpx1jhtO.js +0 -2325
- package/dist/assets/_accessExpressionAsString-J5NhZ9FO.js +0 -1
- package/dist/assets/bbs/index-DxVHwWX6.js +0 -41
- package/dist/assets/client-B3aq8qpT.js +0 -141
- package/dist/assets/shopping/index.html-B8CDZvK4.js +0 -3
- package/dist/assets/uploader/index.html-taNoaQTw.js +0 -17
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import type { AgenticaUserMessageHistory } from "@agentica/core";
|
|
2
|
-
|
|
3
|
-
import FaceIcon from "@mui/icons-material/Face";
|
|
4
|
-
import { Card, CardContent, Chip } from "@mui/material";
|
|
5
|
-
|
|
6
|
-
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
7
|
-
|
|
8
|
-
export function AgenticaChatUserMessageMovie({
|
|
9
|
-
prompt,
|
|
10
|
-
}: AgenticaChatUserMessageMovie.IProps) {
|
|
11
|
-
return (
|
|
12
|
-
<div
|
|
13
|
-
style={{
|
|
14
|
-
display: "flex",
|
|
15
|
-
justifyContent: "flex-end",
|
|
16
|
-
}}
|
|
17
|
-
>
|
|
18
|
-
{
|
|
19
|
-
prompt.contents.map((content, index) => (
|
|
20
|
-
content.type === "text"
|
|
21
|
-
? (
|
|
22
|
-
<Card
|
|
23
|
-
key={index}
|
|
24
|
-
elevation={3}
|
|
25
|
-
style={{
|
|
26
|
-
marginTop: 15,
|
|
27
|
-
marginBottom: 15,
|
|
28
|
-
marginLeft: "15%",
|
|
29
|
-
textAlign: "right",
|
|
30
|
-
backgroundColor: "lightyellow",
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
|
|
34
|
-
<CardContent>
|
|
35
|
-
<Chip
|
|
36
|
-
icon={<FaceIcon />}
|
|
37
|
-
label="User"
|
|
38
|
-
variant="outlined"
|
|
39
|
-
color="primary"
|
|
40
|
-
/>
|
|
41
|
-
<MarkdownViewer>{content.text}</MarkdownViewer>
|
|
42
|
-
</CardContent>
|
|
43
|
-
</Card>
|
|
44
|
-
)
|
|
45
|
-
// @todo handle other content types (multi modal)
|
|
46
|
-
: null
|
|
47
|
-
))
|
|
48
|
-
}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
export namespace AgenticaChatUserMessageMovie {
|
|
53
|
-
export interface IProps {
|
|
54
|
-
prompt: AgenticaUserMessageHistory;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
import type { AgenticaUserMessageHistory } from "@agentica/core";
|
|
2
|
+
|
|
3
|
+
import FaceIcon from "@mui/icons-material/Face";
|
|
4
|
+
import { Card, CardContent, Chip } from "@mui/material";
|
|
5
|
+
|
|
6
|
+
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
7
|
+
|
|
8
|
+
export function AgenticaChatUserMessageMovie({
|
|
9
|
+
prompt,
|
|
10
|
+
}: AgenticaChatUserMessageMovie.IProps) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
display: "flex",
|
|
15
|
+
justifyContent: "flex-end",
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
{
|
|
19
|
+
prompt.contents.map((content, index) => (
|
|
20
|
+
content.type === "text"
|
|
21
|
+
? (
|
|
22
|
+
<Card
|
|
23
|
+
key={index}
|
|
24
|
+
elevation={3}
|
|
25
|
+
style={{
|
|
26
|
+
marginTop: 15,
|
|
27
|
+
marginBottom: 15,
|
|
28
|
+
marginLeft: "15%",
|
|
29
|
+
textAlign: "right",
|
|
30
|
+
backgroundColor: "lightyellow",
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
<CardContent>
|
|
35
|
+
<Chip
|
|
36
|
+
icon={<FaceIcon />}
|
|
37
|
+
label="User"
|
|
38
|
+
variant="outlined"
|
|
39
|
+
color="primary"
|
|
40
|
+
/>
|
|
41
|
+
<MarkdownViewer>{content.text}</MarkdownViewer>
|
|
42
|
+
</CardContent>
|
|
43
|
+
</Card>
|
|
44
|
+
)
|
|
45
|
+
// @todo handle other content types (multi modal)
|
|
46
|
+
: null
|
|
47
|
+
))
|
|
48
|
+
}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
export namespace AgenticaChatUserMessageMovie {
|
|
53
|
+
export interface IProps {
|
|
54
|
+
prompt: AgenticaUserMessageHistory;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import type { AgenticaOperationSelection } from "@agentica/core";
|
|
2
|
-
|
|
3
|
-
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
4
|
-
import {
|
|
5
|
-
Accordion,
|
|
6
|
-
AccordionDetails,
|
|
7
|
-
AccordionSummary,
|
|
8
|
-
Typography,
|
|
9
|
-
} from "@mui/material";
|
|
10
|
-
import React from "react";
|
|
11
|
-
|
|
12
|
-
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
13
|
-
|
|
14
|
-
export function AgenticaChatFunctionStackSideMovie(
|
|
15
|
-
props: AgenticaChatFunctionStackSideMovie.IProps,
|
|
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.operation.protocol === "http"
|
|
26
|
-
? `${select.operation.function.method.toUpperCase()} ${select.operation.function.path}`
|
|
27
|
-
: select.operation.function.name}
|
|
28
|
-
</Typography>
|
|
29
|
-
</AccordionSummary>
|
|
30
|
-
<AccordionDetails>
|
|
31
|
-
<hr />
|
|
32
|
-
{select.reason}
|
|
33
|
-
<br />
|
|
34
|
-
<br />
|
|
35
|
-
<MarkdownViewer>
|
|
36
|
-
{select.operation.function.description}
|
|
37
|
-
</MarkdownViewer>
|
|
38
|
-
</AccordionDetails>
|
|
39
|
-
</Accordion>
|
|
40
|
-
))}
|
|
41
|
-
</React.Fragment>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
export namespace AgenticaChatFunctionStackSideMovie {
|
|
45
|
-
export interface IProps {
|
|
46
|
-
selections: AgenticaOperationSelection[];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
import type { AgenticaOperationSelection } from "@agentica/core";
|
|
2
|
+
|
|
3
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
4
|
+
import {
|
|
5
|
+
Accordion,
|
|
6
|
+
AccordionDetails,
|
|
7
|
+
AccordionSummary,
|
|
8
|
+
Typography,
|
|
9
|
+
} from "@mui/material";
|
|
10
|
+
import React from "react";
|
|
11
|
+
|
|
12
|
+
import { MarkdownViewer } from "../../components/MarkdownViewer";
|
|
13
|
+
|
|
14
|
+
export function AgenticaChatFunctionStackSideMovie(
|
|
15
|
+
props: AgenticaChatFunctionStackSideMovie.IProps,
|
|
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.operation.protocol === "http"
|
|
26
|
+
? `${select.operation.function.method.toUpperCase()} ${select.operation.function.path}`
|
|
27
|
+
: select.operation.function.name}
|
|
28
|
+
</Typography>
|
|
29
|
+
</AccordionSummary>
|
|
30
|
+
<AccordionDetails>
|
|
31
|
+
<hr />
|
|
32
|
+
{select.reason}
|
|
33
|
+
<br />
|
|
34
|
+
<br />
|
|
35
|
+
<MarkdownViewer>
|
|
36
|
+
{select.operation.function.description}
|
|
37
|
+
</MarkdownViewer>
|
|
38
|
+
</AccordionDetails>
|
|
39
|
+
</Accordion>
|
|
40
|
+
))}
|
|
41
|
+
</React.Fragment>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
export namespace AgenticaChatFunctionStackSideMovie {
|
|
45
|
+
export interface IProps {
|
|
46
|
+
selections: AgenticaOperationSelection[];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AgenticaOperationSelection,
|
|
3
|
-
AgenticaTokenUsage,
|
|
4
|
-
IAgenticaConfig,
|
|
5
|
-
IAgenticaVendor,
|
|
6
|
-
IMicroAgenticaConfig,
|
|
7
|
-
} from "@agentica/core";
|
|
8
|
-
|
|
9
|
-
import { Typography } from "@mui/material";
|
|
10
|
-
|
|
11
|
-
import { AgenticaChatFunctionStackSideMovie } from "./AgenticaChatFunctionStackSideMovie";
|
|
12
|
-
import { AgenticaChatTokenUsageSideMovie } from "./AgenticaChatTokenUsageSideMovie";
|
|
13
|
-
|
|
14
|
-
export function AgenticaChatSideMovie(props: AgenticaChatSideMovie.IProps) {
|
|
15
|
-
return (
|
|
16
|
-
<div
|
|
17
|
-
style={{
|
|
18
|
-
padding: 25,
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
{props.error !== null
|
|
22
|
-
? (
|
|
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
|
-
)
|
|
37
|
-
: null}
|
|
38
|
-
<Typography variant="h5">Agent Information</Typography>
|
|
39
|
-
<hr />
|
|
40
|
-
<ul>
|
|
41
|
-
<li>
|
|
42
|
-
Vendor Model:
|
|
43
|
-
{" "}
|
|
44
|
-
{props.vendor.model}
|
|
45
|
-
</li>
|
|
46
|
-
<li>
|
|
47
|
-
Locale:
|
|
48
|
-
{" "}
|
|
49
|
-
{props.config?.locale ?? navigator.language}
|
|
50
|
-
</li>
|
|
51
|
-
<li>
|
|
52
|
-
Timezone:
|
|
53
|
-
{" "}
|
|
54
|
-
{props.config?.timezone
|
|
55
|
-
?? Intl.DateTimeFormat().resolvedOptions().timeZone}
|
|
56
|
-
</li>
|
|
57
|
-
</ul>
|
|
58
|
-
<br />
|
|
59
|
-
<br />
|
|
60
|
-
<AgenticaChatTokenUsageSideMovie usage={props.usage} />
|
|
61
|
-
<br />
|
|
62
|
-
<br />
|
|
63
|
-
<AgenticaChatFunctionStackSideMovie selections={props.selections} />
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
export namespace AgenticaChatSideMovie {
|
|
68
|
-
export interface IProps {
|
|
69
|
-
vendor: IAgenticaVendor;
|
|
70
|
-
config: IAgenticaConfig | IMicroAgenticaConfig | undefined;
|
|
71
|
-
usage: AgenticaTokenUsage;
|
|
72
|
-
selections: AgenticaOperationSelection[];
|
|
73
|
-
error: Error | null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
AgenticaOperationSelection,
|
|
3
|
+
AgenticaTokenUsage,
|
|
4
|
+
IAgenticaConfig,
|
|
5
|
+
IAgenticaVendor,
|
|
6
|
+
IMicroAgenticaConfig,
|
|
7
|
+
} from "@agentica/core";
|
|
8
|
+
|
|
9
|
+
import { Typography } from "@mui/material";
|
|
10
|
+
|
|
11
|
+
import { AgenticaChatFunctionStackSideMovie } from "./AgenticaChatFunctionStackSideMovie";
|
|
12
|
+
import { AgenticaChatTokenUsageSideMovie } from "./AgenticaChatTokenUsageSideMovie";
|
|
13
|
+
|
|
14
|
+
export function AgenticaChatSideMovie(props: AgenticaChatSideMovie.IProps) {
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
style={{
|
|
18
|
+
padding: 25,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
{props.error !== null
|
|
22
|
+
? (
|
|
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
|
+
)
|
|
37
|
+
: null}
|
|
38
|
+
<Typography variant="h5">Agent Information</Typography>
|
|
39
|
+
<hr />
|
|
40
|
+
<ul>
|
|
41
|
+
<li>
|
|
42
|
+
Vendor Model:
|
|
43
|
+
{" "}
|
|
44
|
+
{props.vendor.model}
|
|
45
|
+
</li>
|
|
46
|
+
<li>
|
|
47
|
+
Locale:
|
|
48
|
+
{" "}
|
|
49
|
+
{props.config?.locale ?? navigator.language}
|
|
50
|
+
</li>
|
|
51
|
+
<li>
|
|
52
|
+
Timezone:
|
|
53
|
+
{" "}
|
|
54
|
+
{props.config?.timezone
|
|
55
|
+
?? Intl.DateTimeFormat().resolvedOptions().timeZone}
|
|
56
|
+
</li>
|
|
57
|
+
</ul>
|
|
58
|
+
<br />
|
|
59
|
+
<br />
|
|
60
|
+
<AgenticaChatTokenUsageSideMovie usage={props.usage} />
|
|
61
|
+
<br />
|
|
62
|
+
<br />
|
|
63
|
+
<AgenticaChatFunctionStackSideMovie selections={props.selections} />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
export namespace AgenticaChatSideMovie {
|
|
68
|
+
export interface IProps {
|
|
69
|
+
vendor: IAgenticaVendor;
|
|
70
|
+
config: IAgenticaConfig | IMicroAgenticaConfig | undefined;
|
|
71
|
+
usage: AgenticaTokenUsage;
|
|
72
|
+
selections: AgenticaOperationSelection[];
|
|
73
|
+
error: Error | null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import type { AgenticaTokenUsage } from "@agentica/core";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
TableBody,
|
|
6
|
-
TableCell,
|
|
7
|
-
TableHead,
|
|
8
|
-
TableRow,
|
|
9
|
-
Typography,
|
|
10
|
-
} from "@mui/material";
|
|
11
|
-
import React from "react";
|
|
12
|
-
|
|
13
|
-
export function AgenticaChatTokenUsageSideMovie(props: AgenticaChatTokenUsageSideMovie.IProps) {
|
|
14
|
-
const price: IPrice = compute(props.usage);
|
|
15
|
-
return (
|
|
16
|
-
<React.Fragment>
|
|
17
|
-
<Typography variant="h5"> Token Usage </Typography>
|
|
18
|
-
<hr />
|
|
19
|
-
<Table>
|
|
20
|
-
<TableHead>
|
|
21
|
-
<TableRow>
|
|
22
|
-
<TableCell>Type</TableCell>
|
|
23
|
-
<TableCell>Token Usage</TableCell>
|
|
24
|
-
<TableCell>Price</TableCell>
|
|
25
|
-
</TableRow>
|
|
26
|
-
</TableHead>
|
|
27
|
-
<TableBody>
|
|
28
|
-
<TableRow>
|
|
29
|
-
<TableCell>Total</TableCell>
|
|
30
|
-
<TableCell>
|
|
31
|
-
{props.usage.aggregate.total.toLocaleString()}
|
|
32
|
-
</TableCell>
|
|
33
|
-
<TableCell>
|
|
34
|
-
$
|
|
35
|
-
{price.total.toLocaleString()}
|
|
36
|
-
</TableCell>
|
|
37
|
-
</TableRow>
|
|
38
|
-
<TableRow>
|
|
39
|
-
<TableCell>Input</TableCell>
|
|
40
|
-
<TableCell>
|
|
41
|
-
{props.usage.aggregate.input.total.toLocaleString()}
|
|
42
|
-
</TableCell>
|
|
43
|
-
<TableCell>
|
|
44
|
-
$
|
|
45
|
-
{price.prompt.toLocaleString()}
|
|
46
|
-
</TableCell>
|
|
47
|
-
</TableRow>
|
|
48
|
-
<TableRow>
|
|
49
|
-
<TableCell>Output</TableCell>
|
|
50
|
-
<TableCell>
|
|
51
|
-
{props.usage.aggregate.output.total.toLocaleString()}
|
|
52
|
-
</TableCell>
|
|
53
|
-
<TableCell>
|
|
54
|
-
$
|
|
55
|
-
{price.completion.toLocaleString()}
|
|
56
|
-
</TableCell>
|
|
57
|
-
</TableRow>
|
|
58
|
-
</TableBody>
|
|
59
|
-
</Table>
|
|
60
|
-
</React.Fragment>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
export namespace AgenticaChatTokenUsageSideMovie {
|
|
64
|
-
export interface IProps {
|
|
65
|
-
usage: AgenticaTokenUsage;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface IPrice {
|
|
70
|
-
total: number;
|
|
71
|
-
prompt: number;
|
|
72
|
-
completion: number;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function compute(usage: AgenticaTokenUsage): IPrice {
|
|
76
|
-
const prompt: number
|
|
77
|
-
= (usage.aggregate.input.total - usage.aggregate.input.cached)
|
|
78
|
-
* (2.5 / 1_000_000)
|
|
79
|
-
+ usage.aggregate.input.cached * (1.25 / 1_000_000);
|
|
80
|
-
const completion: number = usage.aggregate.output.total * (10.0 / 1_000_000);
|
|
81
|
-
return {
|
|
82
|
-
total: prompt + completion,
|
|
83
|
-
prompt,
|
|
84
|
-
completion,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
1
|
+
import type { AgenticaTokenUsage } from "@agentica/core";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Table,
|
|
5
|
+
TableBody,
|
|
6
|
+
TableCell,
|
|
7
|
+
TableHead,
|
|
8
|
+
TableRow,
|
|
9
|
+
Typography,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
import React from "react";
|
|
12
|
+
|
|
13
|
+
export function AgenticaChatTokenUsageSideMovie(props: AgenticaChatTokenUsageSideMovie.IProps) {
|
|
14
|
+
const price: IPrice = compute(props.usage);
|
|
15
|
+
return (
|
|
16
|
+
<React.Fragment>
|
|
17
|
+
<Typography variant="h5"> Token Usage </Typography>
|
|
18
|
+
<hr />
|
|
19
|
+
<Table>
|
|
20
|
+
<TableHead>
|
|
21
|
+
<TableRow>
|
|
22
|
+
<TableCell>Type</TableCell>
|
|
23
|
+
<TableCell>Token Usage</TableCell>
|
|
24
|
+
<TableCell>Price</TableCell>
|
|
25
|
+
</TableRow>
|
|
26
|
+
</TableHead>
|
|
27
|
+
<TableBody>
|
|
28
|
+
<TableRow>
|
|
29
|
+
<TableCell>Total</TableCell>
|
|
30
|
+
<TableCell>
|
|
31
|
+
{props.usage.aggregate.total.toLocaleString()}
|
|
32
|
+
</TableCell>
|
|
33
|
+
<TableCell>
|
|
34
|
+
$
|
|
35
|
+
{price.total.toLocaleString()}
|
|
36
|
+
</TableCell>
|
|
37
|
+
</TableRow>
|
|
38
|
+
<TableRow>
|
|
39
|
+
<TableCell>Input</TableCell>
|
|
40
|
+
<TableCell>
|
|
41
|
+
{props.usage.aggregate.input.total.toLocaleString()}
|
|
42
|
+
</TableCell>
|
|
43
|
+
<TableCell>
|
|
44
|
+
$
|
|
45
|
+
{price.prompt.toLocaleString()}
|
|
46
|
+
</TableCell>
|
|
47
|
+
</TableRow>
|
|
48
|
+
<TableRow>
|
|
49
|
+
<TableCell>Output</TableCell>
|
|
50
|
+
<TableCell>
|
|
51
|
+
{props.usage.aggregate.output.total.toLocaleString()}
|
|
52
|
+
</TableCell>
|
|
53
|
+
<TableCell>
|
|
54
|
+
$
|
|
55
|
+
{price.completion.toLocaleString()}
|
|
56
|
+
</TableCell>
|
|
57
|
+
</TableRow>
|
|
58
|
+
</TableBody>
|
|
59
|
+
</Table>
|
|
60
|
+
</React.Fragment>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
export namespace AgenticaChatTokenUsageSideMovie {
|
|
64
|
+
export interface IProps {
|
|
65
|
+
usage: AgenticaTokenUsage;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface IPrice {
|
|
70
|
+
total: number;
|
|
71
|
+
prompt: number;
|
|
72
|
+
completion: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function compute(usage: AgenticaTokenUsage): IPrice {
|
|
76
|
+
const prompt: number
|
|
77
|
+
= (usage.aggregate.input.total - usage.aggregate.input.cached)
|
|
78
|
+
* (2.5 / 1_000_000)
|
|
79
|
+
+ usage.aggregate.input.cached * (1.25 / 1_000_000);
|
|
80
|
+
const completion: number = usage.aggregate.output.total * (10.0 / 1_000_000);
|
|
81
|
+
return {
|
|
82
|
+
total: prompt + completion,
|
|
83
|
+
prompt,
|
|
84
|
+
completion,
|
|
85
|
+
};
|
|
86
|
+
}
|