nkcong206 commited on
Commit
6b6fc50
·
1 Parent(s): 0bd4b96
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -318,14 +318,13 @@ def format_docs(docs):
318
  return "\n\n".join(doc.page_content for doc in docs)
319
 
320
  @st.cache_resource
321
- def compute_rag_chain(_model, embd, docs_texts):
322
- model = _model
323
- results = recursive_embed_cluster_summarize(model, embd, docs_texts, level=1, n_levels=3)
324
  all_texts = docs_texts.copy()
325
  for level in sorted(results.keys()):
326
  summaries = results[level][1]["summaries"].tolist()
327
  all_texts.extend(summaries)
328
- vectorstore = Chroma.from_texts(texts=all_texts, embedding=embd)
329
  retriever = vectorstore.as_retriever()
330
  template = """
331
  Bạn là một trợ lí AI hỗ trợ tuyển sinh và sinh viên. \n
@@ -340,7 +339,7 @@ def compute_rag_chain(_model, embd, docs_texts):
340
  rag_chain = (
341
  {"context": retriever | format_docs, "question": RunnablePassthrough()}
342
  | prompt
343
- | model
344
  | StrOutputParser()
345
  )
346
  return rag_chain
 
318
  return "\n\n".join(doc.page_content for doc in docs)
319
 
320
  @st.cache_resource
321
+ def compute_rag_chain(_model, _embd, docs_texts):
322
+ results = recursive_embed_cluster_summarize(_model, _embd, docs_texts, level=1, n_levels=3)
 
323
  all_texts = docs_texts.copy()
324
  for level in sorted(results.keys()):
325
  summaries = results[level][1]["summaries"].tolist()
326
  all_texts.extend(summaries)
327
+ vectorstore = Chroma.from_texts(texts=all_texts, embedding=_embd)
328
  retriever = vectorstore.as_retriever()
329
  template = """
330
  Bạn là một trợ lí AI hỗ trợ tuyển sinh và sinh viên. \n
 
339
  rag_chain = (
340
  {"context": retriever | format_docs, "question": RunnablePassthrough()}
341
  | prompt
342
+ | _model
343
  | StrOutputParser()
344
  )
345
  return rag_chain