Mercurial Hosting > lang
view src/ai_ask.js.luan @ 66:2ff1f78bb13e
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 22 Aug 2025 07:25:35 -0600 |
parents | a970b7a01a74 |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local User = require "site:/lib/User.luan" local current_user = User.current or error() local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() return function() Io.stdout = Http.response.text_writer() local parameters = Http.request.parameters local chat = parameters.chat or error() chat = get_chat_by_id(chat) or error() chat.user_id == current_user().id or error() local input = parameters.input or error() if input == "" then %> hideWaitingAiIcon(); <% return end local html = chat.ask(input) %> updateAi(<%=json_string(html)%>); <% end