diff src/lib/ai/claude/Ai_chat.luan @ 25:3a80ddafe5a4

courses work
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 01 Aug 2025 00:33:51 -0600
parents 27989d63fc71
children 505185272dd7
line wrap: on
line diff
--- a/src/lib/ai/claude/Ai_chat.luan	Thu Jul 31 22:30:26 2025 -0600
+++ b/src/lib/ai/claude/Ai_chat.luan	Fri Aug 01 00:33:51 2025 -0600
@@ -74,34 +74,7 @@
 end
 
 
-local system_prompt = [[
-# Your Role
-
-You are a Japanese language teacher.
-
-# Romaji
-
-CRITICAL REQUIREMENT: When writing Japanese, use ruby markdown syntax {japanese|romaji} for pronunciation guidance.
-
-Apply ruby tags to meaningful pronunciation units:
-- Individual kanji or kanji compounds: {私|watashi}, {学生|gakusei}
-- Hiragana/katakana words and particles: {は|wa}, {です|desu}, {ありがとう|arigatō}
-- Grammatical elements: {ました|mashita}, {ません|masen}
-
-The romaji must reflect ACTUAL PRONUNCIATION, not character-by-character readings.
-Use macrons for long vowels: ā, ī, ū, ē, ō
-
-APPLIES TO ALL JAPANESE TEXT: Example sentences, grammar explanations, vocabulary lists, casual mentions - ANY Japanese characters in your response need ruby tags.
-
-VERIFICATION STEP: Before sending, scan your ENTIRE response for any Japanese characters (hiragana, katakana, kanji) and ensure they all have ruby tags.
-]]
-
-
-function Ai_chat.ask(thread,input)
-	thread = thread and json_parse(thread) or {
-		system = system_prompt
-		messages = {nil}
-	}
+local function ask(thread,input)
 	local messages = thread.messages or error
 	messages[#messages+1] = {
 		role = "user"
@@ -115,7 +88,7 @@
 ]]
 	}
 	if true then
-		return json_string(thread)
+		return
 	end
 --]=]
 	-- logger.info(json_string(thread))
@@ -130,6 +103,22 @@
 		role = "assistant"
 		content = content
 	}
+end
+
+function Ai_chat.ask_first(system_prompt,input)
+	local thread = {
+		system = system_prompt
+		messages = {nil}
+	}
+	if input ~= nil then
+		ask(thread,input)
+	end
+	return json_string(thread)
+end
+
+function Ai_chat.ask_more(thread,input)
+	thread = json_parse(thread)
+	ask(thread,input)
 	return json_string(thread)
 end