Pclanglais commited on
Commit
3481362
1 Parent(s): c36de6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -15
app.py CHANGED
@@ -100,21 +100,6 @@ class StopOnTokens(StoppingCriteria):
100
  return False
101
 
102
 
103
- def user(message, history):
104
- global source_text
105
- global assess_rag
106
- #For now, we only query the vector database once, at the start.
107
- if len(history) == 0:
108
- assess_rag = classification_chatrag(message)
109
- if assess_rag:
110
- source_text = vector_search(message)
111
- else:
112
- source_text = "Albert-Tchap n'utilise pas de sources comme votre requête n'a pas l'air d'en recueillir."
113
-
114
- history_transformer_format = history + [[message, ""]]
115
-
116
- return history_transformer_format
117
-
118
  def predict(history_transformer_format):
119
 
120
  print(history_transformer_format)
@@ -144,6 +129,8 @@ def predict(history_transformer_format):
144
 
145
  messages = system_prompt + messages
146
 
 
 
147
  model_inputs = tokenizer([messages], return_tensors="pt").to("cuda")
148
  streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
149
  generate_kwargs = dict(
@@ -165,6 +152,23 @@ def predict(history_transformer_format):
165
  yield partial_message
166
  return messages
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  # Define the Gradio interface
169
  title = "Tchap"
170
  description = "Le chatbot du service public"
 
100
  return False
101
 
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  def predict(history_transformer_format):
104
 
105
  print(history_transformer_format)
 
129
 
130
  messages = system_prompt + messages
131
 
132
+ print(messages)
133
+
134
  model_inputs = tokenizer([messages], return_tensors="pt").to("cuda")
135
  streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
136
  generate_kwargs = dict(
 
152
  yield partial_message
153
  return messages
154
 
155
+ def user(message, history):
156
+ global source_text
157
+ global assess_rag
158
+ #For now, we only query the vector database once, at the start.
159
+ if len(history) == 0:
160
+ assess_rag = classification_chatrag(message)
161
+ if assess_rag:
162
+ source_text = vector_search(message)
163
+ else:
164
+ source_text = "Albert-Tchap n'utilise pas de sources comme votre requête n'a pas l'air d'en recueillir."
165
+
166
+ history_transformer_format = history + [[message, ""]]
167
+
168
+ print(history_transformer_format)
169
+
170
+ return history_transformer_format
171
+
172
  # Define the Gradio interface
173
  title = "Tchap"
174
  description = "Le chatbot du service public"