Mercurial Hosting > lang
diff src/lib/Chat.luan @ 52:27758f3b2d69
add hide_ruby
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 16 Aug 2025 09:56:10 +0900 |
parents | cc20eebaa74a |
children | ecb851fabd75 |
line wrap: on
line diff
--- a/src/lib/Chat.luan Fri Aug 15 23:24:38 2025 +0900 +++ b/src/lib/Chat.luan Sat Aug 16 09:56:10 2025 +0900 @@ -31,9 +31,10 @@ language = doc.language tts_instructions = doc.tts_instructions voice = doc.voice - show_text = doc.show_text == "true" + show_text = doc.show_text autoplay = doc.autoplay == "true" is_private = doc.is_private == "true" + has_ruby = doc.has_ruby == "true" } end @@ -49,16 +50,16 @@ language = chat.language or error() tts_instructions = chat.tts_instructions -- or error() voice = chat.voice or error() - show_text = chat.show_text and "true" or "false" + show_text = chat.show_text autoplay = chat.autoplay and "true" or "false" is_private = chat.is_private and "true" or nil + has_ruby = chat.has_ruby and "true" or nil } end function Chat.new(chat) chat.updated = chat.updated or time_now() chat.voice = chat.voice or voices[1] - if chat.show_text==nil then chat.show_text = true end if chat.autoplay==nil then chat.autoplay = true end function chat.save() @@ -103,8 +104,32 @@ Ai_chat.output_system_prompt(chat.ai_thread) end + local function option(name,text) + local selected = name==chat.show_text and " selected" or "" +%> + <option <%=name%><%=selected%>><%=text%></option> +<% + end + + local function assistant_controls() + return `%> + <div controls> + <audio controls preload=none></audio> + <select> +<% + option("show_text","Show text") + if chat.has_ruby then + option("hide_ruby","Hide pronunciation") + end + option("hide_text","Hide text") +%> + </select> + </div> +<% ` + end + function chat.output_messages_html() - Ai_chat.output_messages_html(chat.show_text,chat.ai_thread) + Ai_chat.output_messages_html(assistant_controls(),chat.ai_thread) end function chat.ask(input) @@ -115,7 +140,7 @@ chat.ai_thread = ai_thread chat.save() end ) - return `Ai_chat.output_messages_html(chat.show_text,ai_thread,old_thread)` + return `Ai_chat.output_messages_html(assistant_controls(),ai_thread,old_thread)` end function chat.language_name()