Skip to content

Commit

Permalink
Update cursor focus
Browse files Browse the repository at this point in the history
  • Loading branch information
svilupp authored May 3, 2024
2 parents 9eb1834 + c391d0a commit 0fa7b76
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ProToPortal"
uuid = "f9496bd6-a3bb-4afc-927d-7268532ebfa9"
authors = ["J S <[email protected]> and contributors"]
version = "0.1.0"
version = "0.2.0-DEV"

[deps]
GenieFramework = "a59fdf5c-6bf0-4f5d-949c-a137c9e2f353"
Expand Down
38 changes: 35 additions & 3 deletions app.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ using GenieFramework.Genie.Requests: postpayload
Stipple.Layout.add_script("https://cdn.tailwindcss.com")

#! CONFIGURATION
const HISTORY_DIR = joinpath(@__DIR__, "chat_history")
# Change if you want to save conversations to a specific folder
const HISTORY_DIR = get(ENV, "PROTO_HISTORY_DIR", joinpath(@__DIR__, "chat_history"))
# Change if you don't want to auto-save conversations (after clicking "New chat")
const HISTORY_SAVE = true
const HISTORY_SAVE = get(ENV, "PROTO_HISTORY_SAVE", true)

@appname Portal

Expand Down Expand Up @@ -78,6 +79,7 @@ const HISTORY_SAVE = true
@in chat_submit = false
@in chat_reset = false
@in chat_rm_last_msg = false
@in chat_fork = false
# Template browser
@in template_filter = ""
@in template_submit = false
Expand All @@ -91,6 +93,7 @@ const HISTORY_SAVE = true
# Dashboard logic
@onchange isready begin
@info "> Dashboard is ready!"
isdir(HISTORY_DIR) || mkpath(HISTORY_DIR)
end
@onbutton model_submit begin
if !isempty(model_input)
Expand Down Expand Up @@ -224,6 +227,12 @@ const HISTORY_SAVE = true
pop!(conv_displayed)
conv_displayed = conv_displayed
end
@onbutton chat_fork begin
@info "> Forking conversation (reset+load)!"
conv_displayed_temp = deepcopy(conv_displayed)
chat_reset = true
conv_displayed = conv_displayed_temp
end
### Template browsing behavior
@onbutton template_submit begin
@info "> Template filter: $template_filter"
Expand Down Expand Up @@ -261,8 +270,32 @@ end
## TODO: add cost tracking on configuration pages + token tracking
## TODO: add RAG/knowledge loading from folder or URL
# Required for the JS events

# set focus to the first variable when it changes
@watch begin
raw"""
chat_template_variables() {
this.$nextTick(() => {
this.$refs.variables[0].focus();
})
}
"""
end
@methods begin
raw"""
buttonFunc(index) {
console.log("buttonFunc",index);
console.log("length", this.conv_displayed.length);
if (this.conv_displayed.length==index) {
console.log("woowza");
}
},
focusTemplateSelect() {
this.$nextTick(() => {
this.$refs.tpl_select.focus();
});
},
filterFn (val, update) {
if (val === '') {
update(() => {
Expand All @@ -271,7 +304,6 @@ end
})
return
}
update(() => {
// filter down based on user provided input
const needle = val.toLowerCase()
Expand Down
18 changes: 14 additions & 4 deletions src/view_chat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ function tab_chat_settings()
[
btn("Delete last message",
icon = "delete", @click(:chat_rm_last_msg)),
btn("New Chat", icon = "refresh", @click(:chat_reset))]),
btn("New Chat", icon = "refresh", @click(:chat_reset)),
btn("Fork Conversation", icon = "refresh", @click(:chat_fork))
]),
separator(),
p("Generation Settings", class = "text-lg text-weight-bold pt-4"),
p("Temperature (0=conservative, 2=crazy)"),
slider(
0.0:0.1:2, :chat_temperature, labelalways = true, snap = true,
markers = 1, label = "Temperature"),
markers = 1),
##,
separator(),
p("Code Evaluation", class = "text-lg text-weight-bold"),
Expand Down Expand Up @@ -66,6 +68,7 @@ function tab_chat_templates()
dense = true,
densetoggle = true,
v__model = :chat_template_expanded,
@on(:click, "focusTemplateSelect"),
expandseparator = true,
headerstyle = "bg-blue-1",
[
Expand All @@ -75,6 +78,7 @@ function tab_chat_templates()
label = "Template",
clearable = true,
useinput = true,
ref = "tpl_select",
class = "pb-4",
@on(:filter, "filterFn")
),
Expand All @@ -87,7 +91,8 @@ function tab_chat_templates()
key! = R"item.id",
[
textfield(R"item.variable", v__model = "item.content",
@on("keyup.enter.ctrl", "chat_submit!=chat_submit")
ref = "variables",
@on("keyup.enter.ctrl", "chat_submit=true")
)
])
]
Expand Down Expand Up @@ -118,7 +123,12 @@ function tab_chat_messages()
btngroup(flat = true, class = "absolute bottom-0 right-0",
[
btn(flat = true, round = true, size = "xs",
icon = "content_copy", @click("copyToClipboard(index)"))
icon = "content_copy", @click("copyToClipboard(index)")),
## show only for the last, no confirmation required
btn(flat = true, round = true, size = "xs",
icon = "delete", @iif("index == conv_displayed.length-1"),
@click(:chat_rm_last_msg)
)
])]
)
end
Expand Down

0 comments on commit 0fa7b76

Please sign in to comment.