rick commited on
Commit
ba0e382
·
unverified ·
1 Parent(s): 6971407

update demorrha

Browse files
Files changed (1) hide show
  1. app.py +38 -4
app.py CHANGED
@@ -100,10 +100,24 @@ def process_message(message, operation_prompt="", is_audio_input=False):
100
  tts_audio = text_to_speech(full_response)
101
  st.audio(tts_audio, format="audio/mp3", autoplay=True)
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- # Définition du prompt système initial
105
- SYSTEM_PROMPT = f"{lire_fichier('linguascribe.prompt')}"
106
-
107
 
108
  def main():
109
  st.title("------- DEMORRHA -------")
@@ -111,6 +125,14 @@ def main():
111
  # Initialisation des variables d'état de la session
112
  if "language_detected" not in st.session_state:
113
  st.session_state["language_detected"] = None
 
 
 
 
 
 
 
 
114
 
115
  # Initialisation de l'historique des messages avec le prompt système
116
  if "messages" not in st.session_state:
@@ -125,7 +147,7 @@ def main():
125
 
126
  # Interface utilisateur pour le chat
127
  user_input = st.chat_input("Entrez votre message ici:")
128
- OP_PROMPT = "Translate(fr_FR to en_US)"
129
 
130
  # Ajout de l'enregistreur audio
131
  st.write("Ou enregistrez votre message audio :")
@@ -152,5 +174,17 @@ def main():
152
  "Abattre les barrieres linguistiques entre les hommes."
153
  ]))
154
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  if __name__ == "__main__":
156
  main()
 
100
  tts_audio = text_to_speech(full_response)
101
  st.audio(tts_audio, format="audio/mp3", autoplay=True)
102
 
103
+ # Définition de la classe GlobalSystemPrompts pour stocker les prompts système globaux
104
+ class GlobalSystemPrompts:
105
+ # ########################################################################
106
+ # Définition des prompts système globaux pour différentes fonctionnalités
107
+ # Chaque méthode retourne un prompt système spécifique
108
+ def linguascribe():
109
+ SYSTEM_PROMPT = f"{lire_fichier('linguascribe.prompt')}"
110
+ return SYSTEM_PROMPT
111
+
112
+ def set_mode_translation(from_lang ,dest_lang):
113
+ SYSTEM_PROMPT=GlobalSystemPrompts.linguascribe()
114
+ OP_PROMPT = f"Translate({from_lang} to {dest_lang})"
115
+ return {
116
+ "system_prompt": SYSTEM_PROMPT,
117
+ "operation_prompt": OP_PROMPT
118
+ }
119
 
120
+ SUPPORTED_LANGUAGES=["Afrikaans", "Arabic", "Armenian", "Azerbaijani", "Belarusian", "Bosnian", "Bulgarian", "Catalan", "Chinese", "Croatian", "Czech", "Danish", "Dutch", "English", "Estonian", "Finnish", "French", "Galician", "German", "Greek", "Hebrew", "Hindi", "Hungarian", "Icelandic", "Indonesian", "Italian", "Japanese", "Kannada", "Kazakh", "Korean", "Latvian", "Lithuanian", "Macedonian", "Malay", "Marathi", "Maori", "Nepali", "Norwegian", "Persian", "Polish", "Portuguese", "Romanian", "Russian", "Serbian", "Slovak", "Slovenian", "Spanish", "Swahili", "Swedish", "Tagalog", "Tamil", "Thai", "Turkish", "Ukrainian", "Urdu", "Vietnamese", "Welsh"]
 
 
121
 
122
  def main():
123
  st.title("------- DEMORRHA -------")
 
125
  # Initialisation des variables d'état de la session
126
  if "language_detected" not in st.session_state:
127
  st.session_state["language_detected"] = None
128
+
129
+ if "process_mode" not in st.session_state:
130
+ st.session_state["process_mode"] = "translation"
131
+
132
+
133
+ if "translation" == st.session_state["process_mode"]:
134
+ pass
135
+ #set_mode_translation()
136
 
137
  # Initialisation de l'historique des messages avec le prompt système
138
  if "messages" not in st.session_state:
 
147
 
148
  # Interface utilisateur pour le chat
149
  user_input = st.chat_input("Entrez votre message ici:")
150
+
151
 
152
  # Ajout de l'enregistreur audio
153
  st.write("Ou enregistrez votre message audio :")
 
174
  "Abattre les barrieres linguistiques entre les hommes."
175
  ]))
176
 
177
+ # Sélection de la langue de destination
178
+ def on_language_change():
179
+ st.session_state.target_language = st.session_state.language_selector
180
+
181
+ st.selectbox(
182
+ label="Choisissez la langue de destination",
183
+ options=tuple(SUPPORTED_LANGUAGES),
184
+ placeholder="Sélectionnez une langue",
185
+ key="language_selector",
186
+ on_change=on_language_change
187
+ )
188
+
189
  if __name__ == "__main__":
190
  main()