Mercurial Hosting > lang
changeset 54:16e5c14eb800
AI tools
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 17 Aug 2025 17:47:02 +0900 |
parents | 6c78fd83518f |
children | 5bdd4bc11123 |
files | courses/course.txt src/lib/ai/claude/Ai_chat.luan |
diffstat | 2 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/courses/course.txt Sun Aug 17 17:47:02 2025 +0900 @@ -0,0 +1,5 @@ +Course Design + +This is an AI language learning website using the Claude API. Users can create courses on this website by entering a system prompt for Claude. The purpose of this thread/chat is to help users design these courses, mostly by editing the system prompt of the course. This website also has text-to-speech and speech-to-text using OpenAI. A course also has instructions for text-to-speech. + +Users can discuss a chat with you by giving you a chat ID so you can read the chat using the tool/function `get_chat`.
--- a/src/lib/ai/claude/Ai_chat.luan Sun Aug 17 16:59:37 2025 +0900 +++ b/src/lib/ai/claude/Ai_chat.luan Sun Aug 17 17:47:02 2025 +0900 @@ -73,31 +73,55 @@ end_for end +local function get_chat(chat_id) + local Chat = require "site:/lib/Chat.luan" + local User = require "site:/lib/User.luan" + local chat = Chat.get_by_id(chat_id) or error() + local user = User.current() + local is_owner = user ~= nil and user.id == chat.user_id + is_owner or not chat.is_private or error "private" + return chat +end + local functions = { - get_thread = { + get_chat = { tool = { - description = "Get the contents of a thread/chat with Claude on this website. The contents will be JSON in the format of the Claude API." + description = "Get the contents of a chat/thread with Claude on this website. The contents will be JSON in the format of the Claude API." input_schema = { type = "object" properties = { - thread_id = { - description = "The ID of the thread" - type = "string" + chat_id = { + description = "The ID of the chat" + type = "integer" } } } } fn = function(input) - local Chat = require "site:/lib/Chat.luan" - local User = require "site:/lib/User.luan" - local thread_id = input.thread_id or error() - local chat = Chat.get_by_id(thread_id) or error() - local user = User.current() - local is_owner = user ~= nil and user.id == chat.user_id - is_owner or not chat.is_private or error "private" + local chat_id = input.chat_id or error() + local chat = get_chat(chat_id) return chat.ai_thread or error() end } + get_tts_instructions = { + tool = { + description = "Get the text-to-speech instructions of a chat/thread on this website. These instruction are passed to OpenAI. If there are no instructions, the empty string is returned." + input_schema = { + type = "object" + properties = { + chat_id = { + description = "The ID of the chat" + type = "integer" + } + } + } + } + fn = function(input) + local chat_id = input.chat_id or error() + local chat = get_chat(chat_id) + return chat.tts_instructions or error() + end + } } local tools = {nil} for name, f in pairs(functions) do