cicboy commited on
Commit
ca42ff6
·
1 Parent(s): 4edad6b

update application file

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -100,12 +100,14 @@ def rerank_chunks_with_llm(query, chunks):
100
  """
101
 
102
  #Build a short reranking prompt
103
- chunk_list = "\n\n".join([f"[{i+1}] {text[:400].strip().replace('\\n', ' ')}..."
104
- for i, (text, _) in enumerate(chunks)
105
- ])
 
 
106
 
107
  rerank_prompt = f"""
108
- You are a precise HR assistant that ranks excerpts
109
  from a staff handbook by how relevant they are to the user's question
110
 
111
  Question: {query}
@@ -150,7 +152,7 @@ def ask_question(query):
150
  context = "\n\n---\n\n".join(reranked_chunks[:3])
151
 
152
  prompt = f"""
153
- You are an HR assitant answering questions from the staff handbook.
154
  Use only the following content to answer accurately and concisely:
155
  {context}
156
 
 
100
  """
101
 
102
  #Build a short reranking prompt
103
+ chunk_list_parts = []
104
+ for i, (text, _) in enumerate(chunks):
105
+ clean_text = text[:400].strip().replace("\n", " ")
106
+ chunk_list_parts.append(f"[{i+1}] {clean_text}...")
107
+ chunk_list = "\n\n".join(chunk_list_parts)
108
 
109
  rerank_prompt = f"""
110
+ You are a precise HR assistant that ranks excerpts
111
  from a staff handbook by how relevant they are to the user's question
112
 
113
  Question: {query}
 
152
  context = "\n\n---\n\n".join(reranked_chunks[:3])
153
 
154
  prompt = f"""
155
+ You are an HR assitant answering questions from the staff handbook.
156
  Use only the following content to answer accurately and concisely:
157
  {context}
158