Mercurial Hosting > lang
diff src/lib/ai/claude/Ai_chat.luan @ 54:16e5c14eb800
AI tools
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 17 Aug 2025 17:47:02 +0900 |
parents | 27758f3b2d69 |
children | f5e72f2d1025 |
line wrap: on
line diff
--- 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