From f568389235b0e8a2f1d676a3d8ef08f316e35484 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 25 Aug 2024 18:42:27 +0200 Subject: [PATCH] refac --- backend/config.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/backend/config.py b/backend/config.py index 4dde80eda..adb2e1fd5 100644 --- a/backend/config.py +++ b/backend/config.py @@ -127,10 +127,63 @@ def save_config(): log.exception(e) +DEFAULT_CONFIG = { + "version": 0, + "ui": { + "default_locale": "", + "prompt_suggestions": [ + { + "title": [ + "Help me study", + "vocabulary for a college entrance exam", + ], + "content": "Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option.", + }, + { + "title": [ + "Give me ideas", + "for what to do with my kids' art", + ], + "content": "What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.", + }, + { + "title": ["Tell me a fun fact", "about the Roman Empire"], + "content": "Tell me a random fun fact about the Roman Empire", + }, + { + "title": [ + "Show me a code snippet", + "of a website's sticky header", + ], + "content": "Show me a code snippet of a website's sticky header in CSS and JavaScript.", + }, + { + "title": [ + "Explain options trading", + "if I'm familiar with buying and selling stocks", + ], + "content": "Explain options trading in simple terms if I'm familiar with buying and selling stocks.", + }, + { + "title": ["Overcome procrastination", "give me tips"], + "content": "Could you start by asking me about instances when I procrastinate the most and then give me some suggestions to overcome it?", + }, + { + "title": [ + "Grammar check", + "rewrite it for better readability ", + ], + "content": 'Check the following sentence for grammar and clarity: "[sentence]". Rewrite it for better readability while maintaining its original meaning.', + }, + ], + }, +} + + def get_config(): with get_db() as db: config_entry = db.query(Config).order_by(Config.id.desc()).first() - return config_entry.data if config_entry else {} + return config_entry.data if config_entry else DEFAULT_CONFIG CONFIG_DATA = get_config()