Spaces:
Sleeping
Sleeping
Update settings.py
Browse files- settings.py +28 -7
settings.py
CHANGED
@@ -1,12 +1,21 @@
|
|
|
|
1 |
from enum import Enum
|
2 |
|
3 |
class ChatLength(Enum):
|
4 |
SHORT = "Short (5 replies)"
|
5 |
MEDIUM = "Medium (10 replies)"
|
6 |
-
LONG = "Long (20 replies"
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
"chat_length": ChatLength.MEDIUM,
|
11 |
"show_en_translation": True
|
12 |
}
|
@@ -14,16 +23,28 @@ settings = {
|
|
14 |
def show_settings_updated_alert():
|
15 |
gr.Info("Settings updated.")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def set_chat_length(length):
|
18 |
-
|
19 |
show_settings_updated_alert()
|
20 |
|
21 |
def get_chat_length():
|
22 |
-
return
|
|
|
|
|
|
|
23 |
|
24 |
def set_show_en_translation(show):
|
25 |
-
|
26 |
show_settings_updated_alert()
|
27 |
|
28 |
def get_show_en_translation():
|
29 |
-
return
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from enum import Enum
|
3 |
|
4 |
class ChatLength(Enum):
|
5 |
SHORT = "Short (5 replies)"
|
6 |
MEDIUM = "Medium (10 replies)"
|
7 |
+
LONG = "Long (20 replies)"
|
8 |
|
9 |
+
def to_int(self) -> int:
|
10 |
+
return {
|
11 |
+
ChatLength.SHORT: 5,
|
12 |
+
ChatLength.MEDIUM: 10,
|
13 |
+
ChatLength.LONG: 20,
|
14 |
+
}[self]
|
15 |
+
|
16 |
+
# Storage for settings.
|
17 |
+
_settings = {
|
18 |
+
"api_key": "",
|
19 |
"chat_length": ChatLength.MEDIUM,
|
20 |
"show_en_translation": True
|
21 |
}
|
|
|
23 |
def show_settings_updated_alert():
|
24 |
gr.Info("Settings updated.")
|
25 |
|
26 |
+
def set_api_key(api_key):
|
27 |
+
_settings["api_key"] = api_key
|
28 |
+
|
29 |
+
def get_api_key():
|
30 |
+
return _settings["api_key"]
|
31 |
+
|
32 |
def set_chat_length(length):
|
33 |
+
_settings["chat_length"] = length
|
34 |
show_settings_updated_alert()
|
35 |
|
36 |
def get_chat_length():
|
37 |
+
return ChatLength(_settings["chat_length"])
|
38 |
+
|
39 |
+
def get_chat_length_int():
|
40 |
+
return get_chat_length().to_int()
|
41 |
|
42 |
def set_show_en_translation(show):
|
43 |
+
_settings["show_en_translation"] = show
|
44 |
show_settings_updated_alert()
|
45 |
|
46 |
def get_show_en_translation():
|
47 |
+
return _settings["show_en_translation"]
|
48 |
+
|
49 |
+
def get_current_chat_language():
|
50 |
+
return "Spanish"
|