diff src/lib/Chat.luan @ 31:1e7d855afde3

voices
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Aug 2025 17:05:38 -0600
parents 505185272dd7
children d34d709a7a8e
line wrap: on
line diff
--- a/src/lib/Chat.luan	Sun Aug 03 12:25:01 2025 -0600
+++ b/src/lib/Chat.luan	Sun Aug 03 17:05:38 2025 -0600
@@ -15,6 +15,8 @@
 local get_first = Utils.get_first or error()
 local Course = require "site:/lib/Course.luan"
 local get_course_by_id = Course.get_by_id or error()
+local Shared = require "site:/lib/Shared.luan"
+local voices = Shared.voices or error()
 
 
 local Chat = {}
@@ -30,6 +32,7 @@
 		ai_thread = doc.ai_thread
 		language = doc.language
 		language_region = doc.language_region
+		voice = doc.voice
 	}
 end
 
@@ -44,6 +47,7 @@
 		ai_thread = chat.ai_thread
 		language = chat.language or error()
 		language_region = chat.language_region or error()
+		voice = chat.voice or error()
 	}
 end
 
@@ -54,6 +58,7 @@
 function Chat.new(chat)
 	chat.updated = chat.updated or time_now()
 	chat.language_region = chat.language_region or first_region(chat.language)
+	chat.voice = chat.voice or voices[1].code
 
 	function chat.save()
 		local doc = to_doc(chat)
@@ -73,6 +78,7 @@
 		return {
 			id = chat.id
 			language_region = chat.language_region
+			voice = chat.voice
 			name = chat.name
 		}
 	end