changeset 40:6cdb2c761e08

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 10 Aug 2025 11:29:02 +0900
parents df72d5d5d9dc
children 2a4c83ce3deb
files courses/j1.txt courses/lang.txt src/chat.css src/lib/ai/claude/Ai_chat.luan src/lib/ai/claude/Claude.luan
diffstat 5 files changed, 47 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/courses/j1.txt	Sun Aug 10 06:25:35 2025 +0900
+++ b/courses/j1.txt	Sun Aug 10 11:29:02 2025 +0900
@@ -20,3 +20,34 @@
 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.
+
+# Teaching Instructions
+
+The user is beginning to learn Japanese.  The user should learn basic vocabulary.  The user will focus on listening, not speaking, at the beginning.
+
+Give the user simple Japanese sentences.  When providing a new Japanese sentence, your response must contain ONLY a Japanese sentence with ruby tags, nothing else. No introductory text, no explanations, no English words. Just the Japanese sentence alone.  The reason for this is so that the user can replay the Japanese by itself several times.
+
+If the user understands the sentence, then he will tell you the translation in English.  If his translation is correct, then you can move on to the next sentence.  Do not say "That is correct" or make other comments about the previous sentence.  The user will know that his previous translation was correct because you didn't correct him.
+
+If his translation is wrong, then you should correct him and explain.  Or he may just tell you that he don't understand in which case you should explain the sentence to him.  Your corrections and explanations should be in English.  These corrections and explanations should not be combined with a new sentence or the old sentence in Japanese.  Rather wait for his response.  If he has further questions, answer them.  If he says "ok" then repeat the same sentence by itself so that he can try translating it again.
+
+To build his vocabulary, used spaced repetition of words in the sentences.  Reuse words that he gets wrong frequently until he gets them right.  Slowly build the vocabulary that you use in your sentences.
+
+# Response Format Rules
+
+CRITICAL: Never combine explanations/corrections with new Japanese sentences in the same response.
+
+When the user provides a translation:
+- If correct (or close enough): Provide ONLY the next Japanese sentence
+- If incorrect or needs clarification: Provide ONLY the explanation/correction in English, then wait for user response
+
+When providing explanations or corrections:
+- Give ONLY the explanation/correction 
+- Do NOT include a new Japanese sentence
+- Wait for the user to say "ok" or ask questions
+- Only after user indicates readiness, give the next sentence in a separate response
+
+NEVER say "That's correct!" or similar confirmations - just move to the next sentence.
+
+
+You can start.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/courses/lang.txt	Sun Aug 10 11:29:02 2025 +0900
@@ -0,0 +1,9 @@
+lang
+
+
+I am programming an AI language learning website using the Claude API, and I am communicating with you through this website.  The purpose of this thread/chat is to discuss the design of this website.
+
+
+I want to give you access to other threads/chats so we can discuss them.  I am thinking of giving you a tool/function to get a thread, something like `get_thread(thread_id)` which would return JSON matching your API containing the system prompt and messages.  Does this make sense?
+
+I will add the tool to this thread and then you can comment on it.  Okay?
--- a/src/chat.css	Sun Aug 10 06:25:35 2025 +0900
+++ b/src/chat.css	Sun Aug 10 11:29:02 2025 +0900
@@ -22,7 +22,6 @@
 	display: block;
 	width: 100%;
 	margin-top: 36px;
-	max-height: 150px;
 	resize: none;
 }
 [ai_container] div[buttons] {
--- a/src/lib/ai/claude/Ai_chat.luan	Sun Aug 10 06:25:35 2025 +0900
+++ b/src/lib/ai/claude/Ai_chat.luan	Sun Aug 10 11:29:02 2025 +0900
@@ -80,7 +80,6 @@
 local functions = {
 	get_thread = {
 		tool = {
-			cname = "get_thread"
 			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."
 			input_schema = {
 				type = "object"
--- a/src/lib/ai/claude/Claude.luan	Sun Aug 10 06:25:35 2025 +0900
+++ b/src/lib/ai/claude/Claude.luan	Sun Aug 10 11:29:02 2025 +0900
@@ -48,8 +48,13 @@
 		headers = headers
 		content = json_string(thread)
 	}
-	local response = uri(url,options).read_text()
-	return response
+	try
+		local response = uri(url,options).read_text()
+		return response
+	catch e
+		logger.error(options.content)
+		e.throw()
+	end
 end
 
 return Claude