Mercurial Hosting > lang
comparison src/lib/ai/claude/Ai_chat.luan @ 52:27758f3b2d69
add hide_ruby
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 16 Aug 2025 09:56:10 +0900 |
parents | 5ecfdf43f72d |
children | 16e5c14eb800 |
comparison
equal
deleted
inserted
replaced
51:4581a20b8124 | 52:27758f3b2d69 |
---|---|
23 local system_prompt = thread.system or error | 23 local system_prompt = thread.system or error |
24 system_prompt = html_encode(system_prompt) | 24 system_prompt = html_encode(system_prompt) |
25 %><%=system_prompt%><% | 25 %><%=system_prompt%><% |
26 end | 26 end |
27 | 27 |
28 function Ai_chat.output_messages_html(show_text,thread,old_thread) | 28 function Ai_chat.output_messages_html(assistant_controls,thread,old_thread) |
29 thread = json_parse(thread) | 29 thread = json_parse(thread) |
30 local messages = thread.messages or error | 30 local messages = thread.messages or error |
31 local n = 0 | 31 local n = 0 |
32 if old_thread ~= nil then | 32 if old_thread ~= nil then |
33 old_thread = json_parse(old_thread) | 33 old_thread = json_parse(old_thread) |
34 local old_messages = old_thread.messages or error | 34 local old_messages = old_thread.messages or error |
35 n = #old_messages | 35 n = #old_messages |
36 end | 36 end |
37 local checked = show_text and "checked" or "" | |
38 for i, message in ipairs(messages) do | 37 for i, message in ipairs(messages) do |
39 if i <= n then | 38 if i <= n then |
40 continue | 39 continue |
41 end | 40 end |
42 local role = message.role or error() | 41 local role = message.role or error() |
53 %> | 52 %> |
54 <h3><%=who%></h3> | 53 <h3><%=who%></h3> |
55 <div role="<%=role%>"> | 54 <div role="<%=role%>"> |
56 <div message markdown><%=text%></div> | 55 <div message markdown><%=text%></div> |
57 <% if role=="assistant" then %> | 56 <% if role=="assistant" then %> |
58 <div controls> | 57 <%= assistant_controls %> |
59 <audio controls preload=none></audio> | |
60 <label clickable><input type=checkbox name=show_text <%=checked%> >Show text</label> | |
61 </div> | |
62 <% end %> | 58 <% end %> |
63 </div> | 59 </div> |
64 <% | 60 <% |
65 end | 61 end |
66 local content = message.content or error() | 62 local content = message.content or error() |