Mercurial Hosting > lang
annotate src/new_chat.red.luan @ 53:6c78fd83518f
add delete course
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 17 Aug 2025 16:59:37 +0900 |
| parents | 27758f3b2d69 |
| children | f5e72f2d1025 |
| rev | line source |
|---|---|
| 18 | 1 local Luan = require "luan:Luan.luan" |
| 2 local error = Luan.error | |
| 3 local Http = require "luan:http/Http.luan" | |
| 4 local User = require "site:/lib/User.luan" | |
| 5 local current_user = User.current or error() | |
| 6 local Chat = require "site:/lib/Chat.luan" | |
| 24 | 7 local Course = require "site:/lib/Course.luan" |
| 8 local get_course_by_id = Course.get_by_id or error() | |
|
35
3117876debca
ai_first_message in textarea
Franklin Schmidt <fschmidt@gmail.com>
parents:
24
diff
changeset
|
9 local Ai_chat = require "site:/lib/ai/claude/Ai_chat.luan" |
|
3117876debca
ai_first_message in textarea
Franklin Schmidt <fschmidt@gmail.com>
parents:
24
diff
changeset
|
10 local ai_init = Ai_chat.init or error() |
| 24 | 11 |
| 18 | 12 |
| 13 | |
| 14 return function() | |
| 15 local user = current_user() or error() | |
| 24 | 16 local course_id = Http.request.parameters.course or error() |
| 17 local course = get_course_by_id(course_id) or error() | |
| 18 | 18 local chat = Chat.new{ |
| 19 user_id = user.id | |
| 24 | 20 course_id = course.id |
| 21 name = course.name | |
| 22 language = course.language | |
| 46 | 23 tts_instructions = course.tts_instructions |
| 52 | 24 has_ruby = course.has_ruby |
|
35
3117876debca
ai_first_message in textarea
Franklin Schmidt <fschmidt@gmail.com>
parents:
24
diff
changeset
|
25 ai_thread = ai_init(course.ai_system_prompt) |
| 18 | 26 } |
| 27 chat.save() | |
| 28 Http.response.send_redirect("chat.html?chat="..chat.id) | |
| 29 end |
