Skip to content

Commit 9d2edda

Browse files
committed
migrate
1 parent eff0152 commit 9d2edda

19 files changed

+845
-127
lines changed

app/oraclejetconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"defaultBrowser": "chrome",
1919
"sassVer": "8.0.0",
2020
"defaultTheme": "redwood",
21-
"typescriptLibraries": "typescript@5.0.4 yargs-parser@~13.1.2",
21+
"typescriptLibraries": "typescript@5.3.2 yargs-parser@~13.1.2",
2222
"webpackLibraries": "[email protected] @types/[email protected] webpack-dev-server style-loader css-loader sass-loader sass [email protected] raw-loader noop-loader html-webpack-plugin html-replace-webpack-plugin copy-webpack-plugin @prefresh/webpack @prefresh/babel-plugin webpack-merge compression-webpack-plugin mini-css-extract-plugin clean-webpack-plugin css-fix-url-loader",
23-
24-
"jestTestingLibraries": "jest@27.5.1 @testing-library/[email protected] @types/jest@27.0 [email protected] @oracle/oraclejet-jest-preset@~15.1.0",
23+
24+
"jestTestingLibraries": "jest@^29 @testing-library/[email protected] @types/jest@29.0 [email protected] @oracle/oraclejet-jest-preset@~16.0.0",
2525
"architecture": "vdom",
2626
"watchInterval": 1000,
2727
"exchange-url": "https://exchange.oraclecorp.com/api/0.2.0/"

app/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"name": "JETGenAI",
33
"version": "1.0.0",
4-
"description": "An Oracle JavaScript Extension Toolkit(JET) web app",
4+
"description": "Sample Client app showing communication with OCI Generative AI services via Websocket",
55
"dependencies": {
6-
"@oracle/oraclejet": "~15.1.0",
7-
"@oracle/oraclejet-core-pack": "~15.1.0",
6+
"@oracle/oraclejet": "~16.0.0",
7+
"@oracle/oraclejet-core-pack": "~16.0.0",
88
"marked": "^4.3.0",
99
"uuid": "^9.0.1"
1010
},
1111
"devDependencies": {
12-
"@oracle/ojet-cli": "~15.1.0",
13-
"@oracle/oraclejet-audit": "^15.1.3",
12+
"@oracle/ojet-cli": "~16.0.0",
13+
"@oracle/oraclejet-audit": "^16.0.0",
1414
"@types/uuid": "^9.0.7",
1515
"extract-zip": "^1.7.0",
1616
"fs-extra": "^8.1.0",
1717
"glob": "7.2.0",
18-
"typescript": "5.0.4",
18+
"typescript": "5.3.2",
1919
"underscore": "^1.10.2",
2020
"yargs-parser": "13.1.2"
2121
},

app/path_mapping.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"use": "local",
33
"cdns": {
44
"jet": {
5-
"prefix": "https://static.oracle.com/cdn/jet/15.1.0/default/js",
6-
"css": "https://static.oracle.com/cdn/jet/15.1.0/default/css",
7-
"csspreact": "https://static.oracle.com/cdn/jet/15.1.0/3rdparty/oraclejet-preact/amd",
5+
"prefix": "https://static.oracle.com/cdn/jet/16.0.0/default/js",
6+
"css": "https://static.oracle.com/cdn/jet/16.0.0/default/css",
7+
"csspreact": "https://static.oracle.com/cdn/jet/16.0.0/3rdparty/oraclejet-preact/amd",
88
"config": "bundles-config.js"
99
},
10-
"3rdparty": "https://static.oracle.com/cdn/jet/15.1.0/3rdparty"
10+
"3rdparty": "https://static.oracle.com/cdn/jet/16.0.0/3rdparty"
1111
},
1212
"libs": {
1313
"knockout": {
@@ -262,7 +262,8 @@
262262
"src": ["compat.umd.js", "compat.umd.js.map"],
263263
"path": "libs/preact/compat/dist/compat.umd.js",
264264
"cdnPath": "preact/compat/dist/compat.umd"
265-
}
265+
},
266+
"requireMap": "react"
266267
},
267268
"preact/jsx-runtime": {
268269
"cdn": "3rdparty",
@@ -365,6 +366,20 @@
365366
"pathSuffix": "/min/ojcss'",
366367
"cdnPath": "ojcss"
367368
}
369+
},
370+
"chai": {
371+
"cdn": "3rdparty",
372+
"cwd": "node_modules/chai/",
373+
"debug": {
374+
"src": "chai.js",
375+
"path": "libs/chai/chai.js",
376+
"cdnPath": "chai/chai-4.3.10"
377+
},
378+
"release": {
379+
"src": "chai.js",
380+
"path": "libs/chai/chai.js",
381+
"cdnPath": "chai/chai-4.3.10.min"
382+
}
368383
}
369384
}
370385
}

app/src/components/content/answer.tsx

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,55 @@ declare global {
1313

1414
type Props = {
1515
item: ojListView.ItemTemplateContext;
16+
sim: boolean;
1617
};
1718

18-
export const Answer = ({ item }: Props) => {
19+
export const Answer = ({ item, sim }: Props) => {
1920
const answer = item.data.answer;
2021
return (
21-
<li class="oj-flex demo-answer-layout">
22-
<div class="oj-flex-item oj-flex-bar">
23-
<div class="oj-sm-justify-content-flex-end oj-flex-bar-middle oj-sm-padding-2x demo-copy-paste oj-color-invert">
24-
<md-wrapper
25-
id="TestingOne"
26-
class="oj-sm-width-full"
27-
markdown={`### Answer \n ${answer} `}
28-
/>
29-
</div>
30-
31-
<div class="oj-flex-bar-end">
32-
<oj-avatar
33-
initials="A"
34-
size="sm"
35-
role="presentation"
36-
background="orange"
37-
></oj-avatar>
38-
</div>
39-
</div>
40-
</li>
22+
<>
23+
{sim && (
24+
<li class="oj-flex demo-sim-answer-layout oj-bg-danger-30">
25+
<div class="oj-flex-item oj-flex-bar">
26+
<div class="oj-sm-justify-content-flex-end oj-flex-bar-middle oj-sm-padding-2x demo-copy-paste">
27+
<md-wrapper
28+
id="TestingOne"
29+
class="oj-sm-width-full"
30+
markdown={answer}
31+
/>
32+
</div>
33+
<div class="oj-flex-bar-end">
34+
<oj-avatar
35+
size="sm"
36+
role="presentation"
37+
src="styles/images/placeholder-female-02.png"
38+
background="orange"
39+
></oj-avatar>
40+
</div>
41+
</div>
42+
</li>
43+
)}
44+
{!sim && (
45+
<li class="oj-flex demo-answer-layout">
46+
<div class="oj-flex-item oj-flex-bar">
47+
<div class="oj-sm-justify-content-flex-end oj-flex-bar-middle oj-sm-padding-2x demo-copy-paste oj-color-invert">
48+
<md-wrapper
49+
id="TestingOne"
50+
class="oj-sm-width-full"
51+
markdown={answer}
52+
/>
53+
</div>
54+
<div class="oj-flex-bar-end">
55+
<oj-avatar
56+
initials="A"
57+
size="sm"
58+
role="presentation"
59+
background="orange"
60+
></oj-avatar>
61+
</div>
62+
</div>
63+
</li>
64+
)}
65+
</>
4166
);
4267
};

app/src/components/content/chat.tsx

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Question } from "./question";
22
import { Answer } from "./answer";
33
import { Loading } from "./loading";
44
import { ComponentProps } from "preact";
5-
import { useEffect, useRef, useState } from "preact/hooks";
5+
import { useEffect, useRef, useState, MutableRef } from "preact/hooks";
66
import "ojs/ojlistview";
77
import { ojListView } from "ojs/ojlistview";
88
import MutableArrayDataProvider = require("ojs/ojmutablearraydataprovider");
@@ -11,6 +11,8 @@ import Context = require("ojs/ojcontext");
1111
type Props = {
1212
testId?: string;
1313
data: any;
14+
questionChanged: (event: any) => void;
15+
question: MutableRef<string | undefined>;
1416
};
1517

1618
type Item = {
@@ -25,7 +27,7 @@ const madp = new MutableArrayDataProvider<Item["id"], Item>([], {
2527
keyAttributes: "id",
2628
});
2729

28-
const Chat = ({ testId, data }: Props) => {
30+
export const Chat = ({ testId, data, questionChanged, question }: Props) => {
2931
const dataProvider = useRef(madp);
3032
const listRef = useRef<ojListView<Item["id"], Item>>(null);
3133
const [lastKey, setLastKey] = useState<number>(0);
@@ -59,29 +61,38 @@ const Chat = ({ testId, data }: Props) => {
5961
const chatItemTemplate = (item: ojListView.ItemTemplateContext) => {
6062
return (
6163
<>
62-
{item.data.answer && <Answer item={item} />}
64+
{item.data.answer && <Answer item={item} sim={false} />}
6365
{item.data.loading && <Loading />}
64-
{item.data.question && <Question item={item} />}
66+
{item.data.question && <Question item={item} sim={false} />}
6567
</>
6668
);
6769
};
6870

6971
return (
70-
<div>
71-
<oj-list-view
72-
id="chatlist"
73-
ref={listRef}
74-
data-oj-context="true"
75-
aria-label="list of questions and answers"
76-
data={dataProvider.current}
77-
selectionMode="none"
78-
scrollPosition={scrollPos}
79-
class="oj-sm-width-full demo-chat-layout"
80-
>
81-
<template slot="itemTemplate" render={chatItemTemplate}></template>
82-
<template slot="noData" render={chatNoDataTemplate}></template>
83-
</oj-list-view>
84-
</div>
72+
<>
73+
<div class="oj-flex-item">
74+
<oj-list-view
75+
id="chatlist"
76+
ref={listRef}
77+
data-oj-context="true"
78+
aria-label="list of questions and answers"
79+
data={dataProvider.current}
80+
selectionMode="none"
81+
scrollPosition={scrollPos}
82+
class="oj-sm-width-full demo-chat-layout"
83+
>
84+
<template slot="itemTemplate" render={chatItemTemplate}></template>
85+
<template slot="noData" render={chatNoDataTemplate}></template>
86+
</oj-list-view>
87+
</div>
88+
<oj-input-search
89+
id="search1"
90+
class="oj-input-search-hero oj-sm-width-3"
91+
value={question?.current}
92+
placeholder="ask me anything..."
93+
aria-label="enter a question"
94+
onojValueAction={questionChanged}
95+
></oj-input-search>
96+
</>
8597
);
8698
};
87-
export default Chat;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"Provide more details on this potential disruption",
3+
"Are there any alternative routes or should we start considering alternate suppliers?",
4+
"Ok, recommend alternative suppliers with comparable pricing. If it's too expensive to use alternate options, then waiting out the traffic delay might be better.",
5+
"Let's proceed with Acme. Create the purchase req, and notify the rest of the SCM team."
6+
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"Hi, there's a high chance of disruption in our supply chain within in the next 24hrs.",
3+
"There may be significant delay in the delivery of epoxy resin within the next 36 hrs from our primary supplier due to severe weather conditions affecting the 101 and 405 on the transportation route.",
4+
"Alternative routes exist but they would also significantly increase delivery times due increased traffic diverted from the 101 and 405. Exploring other suppliers may be a more viable option.",
5+
"I've reviewed our negotiated rate cards for Acme Corp, an alternative supplier. Although their prices are slightly higher, they can deliver on-time via an unaffected route. This higher cost is still more economical than potential operational disruptions if we delay."
6+
]

0 commit comments

Comments
 (0)