rick commited on
Commit
7cf6d55
·
unverified ·
1 Parent(s): 026b176

patch 1.2.13

Browse files
Files changed (3) hide show
  1. core/core.py +41 -3
  2. pages/main.py +1 -71
  3. var_app.py +25 -2
core/core.py CHANGED
@@ -7,10 +7,11 @@ from os import getenv
7
  #from typing import IO
8
  #from typing import List
9
  from typing import Optional
10
- #from typing import Tuple
11
- #from typing import Union
12
  from core.files import load_ui_language
13
-
 
14
  import streamlit as st
15
  from openai import OpenAI
16
 
@@ -70,3 +71,40 @@ def process_message(
70
  except Exception as e:
71
  st.error(f"Une erreur s'est produite lors de la génération de la réponse : {e}")
72
  return ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  #from typing import IO
8
  #from typing import List
9
  from typing import Optional
10
+ from typing import Tuple
11
+ from typing import Union
12
  from core.files import load_ui_language
13
+ from core.files import read_file
14
+ from var_app import GlobalSystemPrompts
15
  import streamlit as st
16
  from openai import OpenAI
17
 
 
71
  except Exception as e:
72
  st.error(f"Une erreur s'est produite lors de la génération de la réponse : {e}")
73
  return ""
74
+
75
+ # Function to configure the translation mode
76
+ def set_translation_mode(from_lang: str, dest_lang: str) -> Tuple[str, str]:
77
+ """
78
+ Configure les prompts globaux pour le mode de traduction.
79
+
80
+ Args:
81
+ from_lang (str): La langue source.
82
+ dest_lang (str): La langue de destination.
83
+
84
+ Returns:
85
+ Tuple[str, str]: Un tuple contenant le prompt système et le prompt d'opération.
86
+ """
87
+ system_prompt_ = GlobalSystemPrompts.linguascribe()
88
+ operation_prompt_ = f"Translate({from_lang} to {dest_lang})"
89
+ return system_prompt_, operation_prompt_
90
+
91
+ def init_process_mode(
92
+ from_lang: str,
93
+ to_lang: str,
94
+ process_mode: Optional[str|list] = "translator"
95
+ ) -> Tuple[str, str]:
96
+ """
97
+ Initialise le mode de traitement pour la traduction si nécessaire.
98
+
99
+ Returns:
100
+ Tuple[str, str]: Un tuple contenant le prompt système et le prompt d'opération.
101
+ """
102
+ # from (e.g.: st.session_state.language_detected)
103
+ # dest (e.g.: st.session_state.target_language)
104
+ if "translator" in process_mode:
105
+ system_prompt, operation_prompt = set_translation_mode(
106
+ from_lang=f"{from_lang}",
107
+ dest_lang=f"{to_lang}"
108
+ )
109
+ return system_prompt, operation_prompt
110
+ return "", ""
pages/main.py CHANGED
@@ -48,7 +48,7 @@ from core.audio_files import split_audio
48
  from core.text_to_speech import process_tts_message
49
  from core.files import load_ui_language
50
  from core.core import process_message
51
-
52
 
53
 
54
 
@@ -61,76 +61,6 @@ st.set_page_config(
61
  )
62
 
63
 
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
- class GlobalSystemPrompts:
72
- """Class to store global system prompts."""
73
-
74
- @staticmethod
75
- def linguascribe():
76
- """
77
- Retrieve the system prompt for the Linguascribe feature.
78
-
79
- Returns:
80
- str: The system prompt for Linguascribe.
81
- """
82
- try:
83
- system_prompt = read_file('linguascribe.prompt')
84
- return system_prompt
85
- except FileNotFoundError:
86
- print("Le fichier 'linguascribe.prompt' n'a pas été trouvé.")
87
- return ""
88
- except IOError as e:
89
- print(f"Erreur lors de la lecture du fichier 'linguascribe.prompt': {e}")
90
- return ""
91
-
92
- # Function to configure the translation mode
93
- def set_translation_mode(from_lang: str, dest_lang: str) -> Tuple[str, str]:
94
- """
95
- Configure les prompts globaux pour le mode de traduction.
96
-
97
- Args:
98
- from_lang (str): La langue source.
99
- dest_lang (str): La langue de destination.
100
-
101
- Returns:
102
- Tuple[str, str]: Un tuple contenant le prompt système et le prompt d'opération.
103
- """
104
- system_prompt_ = GlobalSystemPrompts.linguascribe()
105
- operation_prompt_ = f"Translate({from_lang} to {dest_lang})"
106
- return system_prompt_, operation_prompt_
107
-
108
-
109
-
110
-
111
-
112
-
113
- def init_process_mode(
114
- from_lang: str,
115
- to_lang: str,
116
- process_mode: Optional[str|list] = "translator"
117
- ) -> Tuple[str, str]:
118
- """
119
- Initialise le mode de traitement pour la traduction si nécessaire.
120
-
121
- Returns:
122
- Tuple[str, str]: Un tuple contenant le prompt système et le prompt d'opération.
123
- """
124
- # from (e.g.: st.session_state.language_detected)
125
- # dest (e.g.: st.session_state.target_language)
126
- if "translator" in process_mode:
127
- system_prompt, operation_prompt = set_translation_mode(
128
- from_lang=f"{from_lang}",
129
- dest_lang=f"{to_lang}"
130
- )
131
- return system_prompt, operation_prompt
132
- return "", ""
133
-
134
  @st.dialog("Settings")
135
  def tts_settings(name__tts_voice,
136
  state__tts_with_text,
 
48
  from core.text_to_speech import process_tts_message
49
  from core.files import load_ui_language
50
  from core.core import process_message
51
+ from core.core import init_process_mode
52
 
53
 
54
 
 
61
  )
62
 
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  @st.dialog("Settings")
65
  def tts_settings(name__tts_voice,
66
  state__tts_with_text,
var_app.py CHANGED
@@ -1,4 +1,6 @@
1
- __version__ = "1.2.12"
 
 
2
 
3
  # List of languages supported by the application
4
  SUPPORTED_LANGUAGES = [
@@ -26,4 +28,25 @@ LANGUAGES_EMOJI = {
26
  "Slovenian": "🇸🇮", "Spanish": "🇪🇸", "Swahili": "🇰🇪", "Swedish": "🇸🇪", "Tagalog": "🇵🇭",
27
  "Tamil": "🇮🇳", "Thai": "🇹🇭", "Turkish": "🇹🇷", "Ukrainian": "🇺🇦", "Urdu": "🇵🇰",
28
  "Vietnamese": "🇻🇳", "Welsh": "🏴󠁧󠁢󠁷󠁬󠁳󠁿"
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __version__ = "1.2.13"
2
+
3
+ from core.files import read_file
4
 
5
  # List of languages supported by the application
6
  SUPPORTED_LANGUAGES = [
 
28
  "Slovenian": "🇸🇮", "Spanish": "🇪🇸", "Swahili": "🇰🇪", "Swedish": "🇸🇪", "Tagalog": "🇵🇭",
29
  "Tamil": "🇮🇳", "Thai": "🇹🇭", "Turkish": "🇹🇷", "Ukrainian": "🇺🇦", "Urdu": "🇵🇰",
30
  "Vietnamese": "🇻🇳", "Welsh": "🏴󠁧󠁢󠁷󠁬󠁳󠁿"
31
+ }
32
+
33
+ class GlobalSystemPrompts:
34
+ """Class to store global system prompts."""
35
+
36
+ @staticmethod
37
+ def linguascribe():
38
+ """
39
+ Retrieve the system prompt for the Linguascribe feature.
40
+
41
+ Returns:
42
+ str: The system prompt for Linguascribe.
43
+ """
44
+ try:
45
+ system_prompt = read_file('linguascribe.prompt')
46
+ return system_prompt
47
+ except FileNotFoundError:
48
+ print("Le fichier 'linguascribe.prompt' n'a pas été trouvé.")
49
+ return ""
50
+ except IOError as e:
51
+ print(f"Erreur lors de la lecture du fichier 'linguascribe.prompt': {e}")
52
+ return ""