DHEIVER commited on
Commit
78e552d
·
verified ·
1 Parent(s): 4d5242c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -94,8 +94,6 @@ def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, pr
94
  temperature=temperature,
95
  max_new_tokens=max_tokens,
96
  top_k=top_k,
97
- # Adiciona um prompt de sistema para responder em português
98
- system_prompt="Por favor, responda em português."
99
  )
100
 
101
  progress(0.75, desc="Definindo memória de buffer...")
@@ -116,7 +114,7 @@ def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, pr
116
  )
117
  progress(0.9, desc="Concluído!")
118
  return qa_chain
119
-
120
  # Função para gerar um nome de coleção válido
121
  def create_collection_name(filepath):
122
  collection_name = Path(filepath).stem
@@ -163,10 +161,8 @@ def format_chat_history(message, chat_history):
163
 
164
  # Função para realizar a conversa com o chatbot
165
  def conversation(qa_chain, message, history):
166
- # Adiciona uma instrução para responder em português
167
- message_with_language = "Por favor, responda em português: " + message
168
- formatted_chat_history = format_chat_history(message_with_language, history)
169
- response = qa_chain({"question": message_with_language, "chat_history": formatted_chat_history})
170
  response_answer = response["answer"]
171
  if response_answer.find("Resposta útil:") != -1:
172
  response_answer = response_answer.split("Resposta útil:")[-1]
@@ -285,4 +281,4 @@ def demo():
285
 
286
 
287
  if __name__ == "__main__":
288
- demo()
 
94
  temperature=temperature,
95
  max_new_tokens=max_tokens,
96
  top_k=top_k,
 
 
97
  )
98
 
99
  progress(0.75, desc="Definindo memória de buffer...")
 
114
  )
115
  progress(0.9, desc="Concluído!")
116
  return qa_chain
117
+
118
  # Função para gerar um nome de coleção válido
119
  def create_collection_name(filepath):
120
  collection_name = Path(filepath).stem
 
161
 
162
  # Função para realizar a conversa com o chatbot
163
  def conversation(qa_chain, message, history):
164
+ formatted_chat_history = format_chat_history(message, history)
165
+ response = qa_chain({"question": message, "chat_history": formatted_chat_history})
 
 
166
  response_answer = response["answer"]
167
  if response_answer.find("Resposta útil:") != -1:
168
  response_answer = response_answer.split("Resposta útil:")[-1]
 
281
 
282
 
283
  if __name__ == "__main__":
284
+ demo()