FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/static/chat/index.html at spark-compute-patch · feast-dev/feast · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
feast-dev
/
feast
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
7.2k
Code
Issues
218
Pull requests
191
Discussions
Actions
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
static
/
chat
/
index.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
129 lines (121 loc) · 4.35 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
static
/
chat
/
index.html
Copy path
File metadata and controls
129 lines (121 loc) · 4.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html
>
<
html
lang
="
en
"
>
<
head
>
<
meta
charset
="
UTF-8
"
>
<
meta
name
="
viewport
"
content
="
width=device-width, initial-scale=1.0
"
>
<
title
>
Feast Chat
</
title
>
<
style
>
body
{
font-family
:
Arial
,
sans-serif;
margin
:
0
;
padding
:
0
;
display
:
flex;
flex-direction
:
column;
height
:
100
vh
;
}
.
chat-container
{
flex
:
1
;
display
:
flex;
flex-direction
:
column;
padding
:
20
px
;
overflow-y
:
auto;
}
.
message
{
margin-bottom
:
10
px
;
padding
:
10
px
;
border-radius
:
5
px
;
max-width
:
70
%
;
}
.
user-message
{
background-color
:
#
e6f7ff
;
align-self
:
flex-end;
}
.
bot-message
{
background-color
:
#
f0f0f0
;
align-self
:
flex-start;
}
.
input-container
{
display
:
flex;
padding
:
10
px
;
border-top
:
1
px
solid
#
ccc
;
}
#
message-input
{
flex
:
1
;
padding
:
10
px
;
border
:
1
px
solid
#
ccc
;
border-radius
:
5
px
;
margin-right
:
10
px
;
}
#
send-button
{
padding
:
10
px
20
px
;
background-color
:
#
1890ff
;
color
:
white;
border
:
none;
border-radius
:
5
px
;
cursor
:
pointer;
}
</
style
>
</
head
>
<
body
>
<
div
class
="
chat-container
"
id
="
chat-container
"
>
<
div
class
="
message bot-message
"
>
Hello! How can I help you today?
</
div
>
</
div
>
<
div
class
="
input-container
"
>
<
input
type
="
text
"
id
="
message-input
"
placeholder
="
Type your message...
"
>
<
button
id
="
send-button
"
>
Send
</
button
>
</
div
>
<
script
>
const
chatContainer
=
document
.
getElementById
(
'chat-container'
)
;
const
messageInput
=
document
.
getElementById
(
'message-input'
)
;
const
sendButton
=
document
.
getElementById
(
'send-button'
)
;
// WebSocket connection
const
ws
=
new
WebSocket
(
`ws://
${
window
.
location
.
host
}
/ws/chat`
)
;
ws
.
onmessage
=
function
(
event
)
{
// Check if there's an existing bot message being built
const
lastMessage
=
chatContainer
.
lastElementChild
;
if
(
lastMessage
&&
lastMessage
.
classList
.
contains
(
'bot-message'
)
&&
lastMessage
.
dataset
.
streaming
===
'true'
)
{
// Append to the existing message
lastMessage
.
textContent
+=
event
.
data
;
}
else
{
// Create a new bot message
const
botMessage
=
document
.
createElement
(
'div'
)
;
botMessage
.
classList
.
add
(
'message'
,
'bot-message'
)
;
botMessage
.
dataset
.
streaming
=
'true'
;
botMessage
.
textContent
=
event
.
data
;
chatContainer
.
appendChild
(
botMessage
)
;
chatContainer
.
scrollTop
=
chatContainer
.
scrollHeight
;
}
}
;
ws
.
onclose
=
function
(
event
)
{
console
.
log
(
'Connection closed'
)
;
// Mark the last message as complete if it was streaming
const
lastMessage
=
chatContainer
.
lastElementChild
;
if
(
lastMessage
&&
lastMessage
.
classList
.
contains
(
'bot-message'
)
&&
lastMessage
.
dataset
.
streaming
===
'true'
)
{
lastMessage
.
dataset
.
streaming
=
'false'
;
}
}
;
function
sendMessage
(
)
{
const
message
=
messageInput
.
value
.
trim
(
)
;
if
(
message
)
{
// Add user message to chat
const
userMessage
=
document
.
createElement
(
'div'
)
;
userMessage
.
classList
.
add
(
'message'
,
'user-message'
)
;
userMessage
.
textContent
=
message
;
chatContainer
.
appendChild
(
userMessage
)
;
// Send message to server
ws
.
send
(
message
)
;
// Clear input
messageInput
.
value
=
''
;
// Scroll to bottom
chatContainer
.
scrollTop
=
chatContainer
.
scrollHeight
;
}
}
sendButton
.
addEventListener
(
'click'
,
sendMessage
)
;
messageInput
.
addEventListener
(
'keypress'
,
function
(
event
)
{
if
(
event
.
key
===
'Enter'
)
{
sendMessage
(
)
;
}
}
)
;
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL