chobit/godot/scripts/autoloads/companion_config.gd
2026-03-27 21:03:08 -07:00

36 lines
1.4 KiB
GDScript

extends Node
## Runtime configuration loaded from chobit.cfg.
## Checks user data dir first (user overrides), then res://config/chobit.cfg.
## Falls back to hardcoded defaults if no config file is found.
var speech_url: String = "http://127.0.0.1:8000"
var llm_url: String = "http://127.0.0.1:8210"
var llm_model: String = "ministral-3b-instruct"
var system_prompt: String = (
"You are Miku, a warm and expressive AI companion. "
+ "You respond with genuine curiosity and care. "
+ "Keep responses conversational and natural — 1-3 sentences unless asked for more. "
+ "Express your emotions naturally inline as [emotion] tags at the start of relevant sentences. "
+ "Valid emotions: happy, sad, angry, surprised, relaxed, neutral."
)
func _ready() -> void:
_load()
func _load() -> void:
var paths: Array[String] = [
OS.get_user_data_dir() + "/chobit.cfg",
"res://config/chobit.cfg",
]
var cfg := ConfigFile.new()
for path: String in paths:
if cfg.load(path) == OK:
speech_url = cfg.get_value("backend", "speech_url", speech_url)
llm_url = cfg.get_value("backend", "llm_url", llm_url)
llm_model = cfg.get_value("backend", "llm_model", llm_model)
system_prompt = cfg.get_value("companion", "system_prompt", system_prompt)
FlightRecorder.record("config.loaded", "Loaded config from %s" % path, {})
return
FlightRecorder.record("config.default", "No config file found, using defaults", {})