Skip to content

Commit a5749e7

Browse files
committed
add new chat-widget component
1 parent 7c89d6b commit a5749e7

File tree

7 files changed

+159
-52
lines changed

7 files changed

+159
-52
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
2+
.yalc
3+
yalc.lock
24

35
/.cache
46
/build
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { GWChatWidget, GWChatWidgetProps } from "gooey-web-widget";
2+
3+
export default function GooeyChatWidget({
4+
state,
5+
onChange,
6+
...rest
7+
}: GWChatWidgetProps & {
8+
state: Record<string, any>;
9+
onChange: (value: string) => void;
10+
}) {
11+
12+
const handleSend = (message: string) => {
13+
// Handle the send event here
14+
console.log("Message sent:", message);
15+
// You can also call onChange if needed
16+
onChange(message);
17+
};
18+
19+
const handleClear = () => {
20+
// Handle the clear event here
21+
console.log("Chat cleared");
22+
// You can also call onChange if needed
23+
// onChange("");
24+
};
25+
26+
return (
27+
<div className="h-100">
28+
<GWChatWidget
29+
{...rest}
30+
onSend={handleSend}
31+
onNewConversation={handleClear}
32+
/>
33+
</div>
34+
);
35+
}

app/renderer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import GooeySelect from "./components/GooeySelect";
2222
import GooeySwitch from "./components/GooeySwitch";
2323
import { GooeyTooltip } from "./components/GooeyTooltip";
2424
import { lazyImport } from "./lazyImports";
25+
import GooeyChatWidget from "./components/ChatComponents/GooeyChatWidget";
2526

2627
const { DataTable, DataTableRaw } = lazyImport(() => import("~/dataTable"));
2728

@@ -338,6 +339,9 @@ function RenderedTreeNode({
338339
case "code-editor": {
339340
return <CodeEditor props={props} state={state} onChange={onChange} />;
340341
}
342+
case "gw-chat-widget": {
343+
return <GooeyChatWidget {...props} state={state} onChange={onChange} />;
344+
}
341345
case "switch":
342346
return <GooeySwitch props={props} state={state} />;
343347
case "input": {

package-lock.json

Lines changed: 99 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gooey-gui",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"sideEffects": false,
55
"scripts": {
66
"build": "remix build",
@@ -44,6 +44,7 @@
4444
"@uppy/webcam": "^3.3.1",
4545
"@uppy/xhr-upload": "^3.2.0",
4646
"firebase-admin": "^11.9.0",
47+
"gooey-web-widget": "file:.yalc/gooey-web-widget",
4748
"html-react-parser": "^4.0.0",
4849
"isbot": "^3.6.8",
4950
"jshint": "^2.13.6",
@@ -53,8 +54,8 @@
5354
"nprogress": "^0.2.0",
5455
"plotly.js": "^2.27.1",
5556
"puppeteer": "^22.14.0",
56-
"react": "^17.0.2",
57-
"react-dom": "^17.0.2",
57+
"react": "^18.2.0",
58+
"react-dom": "^18.2.0",
5859
"react-plotly.js": "^2.6.0",
5960
"react-select": "^5.7.3",
6061
"react-syntax-highlighter": "^15.5.0",

py/gooey_gui/components/common.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,3 +922,17 @@ def tooltip(
922922
)
923923
tooltip.mount()
924924
return core.NestingCtx(tooltip)
925+
926+
def gooey_chat_widget(
927+
messages,
928+
config,
929+
**props,
930+
):
931+
return core.RenderTreeNode(
932+
name="gw-chat-widget",
933+
props=dict(
934+
messages=messages,
935+
config=config,
936+
**props,
937+
),
938+
).mount()

remix.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
/p-queue/,
3131
/p-timeout/,
3232
/is-network-error/,
33+
/gooey-web-widget/
3334
],
3435
routes(defineRoutes) {
3536
return defineRoutes((route) => {

0 commit comments

Comments
 (0)