Demosthene-OR commited on
Commit
338b634
1 Parent(s): 865221f

Update chatbot_tab.py

Browse files
Files changed (1) hide show
  1. tabs/chatbot_tab.py +23 -2
tabs/chatbot_tab.py CHANGED
@@ -82,11 +82,13 @@ selected_options6 = []
82
  selected_options7 = []
83
  selected_index8 = 0
84
  virulence = 1
 
 
85
 
86
  # @st.cache_data
87
  def init():
88
  global config,thread_id, context,human_message1,ai_message1,language, app, model_speech,prompt,model
89
- global selected_index1, selected_index2, selected_index3, selected_options4,selected_options5,selected_options6,selected_options7, selected_index8, virulence
90
 
91
  model_speech = whisper.load_model("base")
92
 
@@ -100,6 +102,16 @@ def init():
100
  selected_options7 = []
101
  selected_index8 = 0
102
  virulence = 1
 
 
 
 
 
 
 
 
 
 
103
 
104
  options1 = ["Directeur Commercial", "Directeur Général", "Directeur Marketing"]
105
  translated_options1 = [tr(o) for o in options1]
@@ -231,7 +243,7 @@ Attention: Ce n'est pas toi qui m'aide, c'est moi qui t'aide avec ma solution.
231
 
232
  st.write("")
233
  if ("context" in st.session_state) and ("human_message1" in st.session_state):
234
- if (st.session_state.context != context) or (st.session_state.human_message1 != human_message1 ):
235
  to_init = True
236
  else:
237
  to_init = False
@@ -251,6 +263,15 @@ Attention: Ce n'est pas toi qui m'aide, c'est moi qui t'aide avec ma solution.
251
  st.session_state.context = context
252
  st.session_state.human_message1 = human_message1
253
  st.session_state.messages = []
 
 
 
 
 
 
 
 
 
254
 
255
  return config, thread_id
256
 
 
82
  selected_options7 = []
83
  selected_index8 = 0
84
  virulence = 1
85
+ if 'model' in st.session_state:
86
+ used_model = st.session_state.model
87
 
88
  # @st.cache_data
89
  def init():
90
  global config,thread_id, context,human_message1,ai_message1,language, app, model_speech,prompt,model
91
+ global selected_index1, selected_index2, selected_index3, selected_options4,selected_options5,selected_options6,selected_options7, selected_index8, virulence, used_model
92
 
93
  model_speech = whisper.load_model("base")
94
 
 
102
  selected_options7 = []
103
  selected_index8 = 0
104
  virulence = 1
105
+ if 'model' in st.session_state and (st.session_state.model[:3]=="gpt") and ("OPENAI_API_KEY" in st.session_state):
106
+ model = ChatOpenAI(model=st.session_state.model,
107
+ temperature=0.8, # Adjust creativity level
108
+ max_tokens=150 # Define max output token limit
109
+ )
110
+ else:
111
+ model = ChatMistralAI(model=st.session_state.model)
112
+ if 'model' in st.session_state:
113
+ used_model=st.session_state.model
114
+
115
 
116
  options1 = ["Directeur Commercial", "Directeur Général", "Directeur Marketing"]
117
  translated_options1 = [tr(o) for o in options1]
 
243
 
244
  st.write("")
245
  if ("context" in st.session_state) and ("human_message1" in st.session_state):
246
+ if (st.session_state.context != context) or (st.session_state.human_message1 != human_message1 ) or (used_model != st.session_state.model):
247
  to_init = True
248
  else:
249
  to_init = False
 
263
  st.session_state.context = context
264
  st.session_state.human_message1 = human_message1
265
  st.session_state.messages = []
266
+ if 'model' in st.session_state and (st.session_state.model[:3]=="gpt") and ("OPENAI_API_KEY" in st.session_state):
267
+ model = ChatOpenAI(model=st.session_state.model,
268
+ temperature=0.8, # Adjust creativity level
269
+ max_tokens=150 # Define max output token limit
270
+ )
271
+ else:
272
+ model = ChatMistralAI(model=st.session_state.model)
273
+ if 'model' in st.session_state:
274
+ used_model=st.session_state.model
275
 
276
  return config, thread_id
277