lozanopastor commited on
Commit
60ae0f7
·
verified ·
1 Parent(s): 38a0374

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -58,6 +58,12 @@ def get_conversational_chain():
58
  prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
59
  chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
60
  return chain
 
 
 
 
 
 
61
 
62
  def user_input(user_question):
63
  """Handles user queries by retrieving answers from the vector store."""
@@ -85,7 +91,7 @@ def user_input(user_question):
85
  thought_process = thought_process_match.group(1).strip()
86
 
87
  # Remove the thought process from the main response
88
- clean_response = original_response.split("<think>")[-1].split("</think>")[0]
89
 
90
  # Debugging: Print the cleaned response
91
  print("Cleaned Response:", clean_response)
 
58
  prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
59
  chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
60
  return chain
61
+
62
+ def eliminar_texto_entre_tags(texto):
63
+ patron = r'<think>.*?</think>'
64
+ texto_limpio = re.sub(patron, '', texto)
65
+ return texto_limpio
66
+
67
 
68
  def user_input(user_question):
69
  """Handles user queries by retrieving answers from the vector store."""
 
91
  thought_process = thought_process_match.group(1).strip()
92
 
93
  # Remove the thought process from the main response
94
+ clean_response = eliminar_texto_entre_tags(original_response)
95
 
96
  # Debugging: Print the cleaned response
97
  print("Cleaned Response:", clean_response)