cicboy commited on
Commit
6fbaaf8
·
1 Parent(s): d2f8a91

update application file

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -85,9 +85,19 @@ def insert_chunks(chunks):
85
  def expand_query(query):
86
  try:
87
  prompt = f"""Expand the following short questions into a more detailed search query
88
- that includes synonyms and related HR terms, but also restate the keywords clearly:
89
 
90
- {query}
 
 
 
 
 
 
 
 
 
 
91
  """
92
  response = openai_client.chat.completions.create(
93
  model = "gpt-4.1-mini",
@@ -120,7 +130,7 @@ def search_weaviate(query, k=12):
120
  # Keep results above a relevance threshold
121
  if (distance is None or distance < 1.2) or (certainty and certainty >0.3):
122
  filtered_objects.append(o)
123
-
124
  return [(o.properties["text"], o.metadata.distance)for o in result.objects]
125
 
126
  def rerank_chunks_with_llm(query, chunks):
 
85
  def expand_query(query):
86
  try:
87
  prompt = f"""Expand the following short questions into a more detailed search query
88
+ that includes synonyms and related HR terms, but also restate the keywords clearly.
89
 
90
+ Examples:
91
+
92
+ Q: Who should I contact if I am sick?
93
+ Expanded: Who should I notify or contact if I am ill, unwell, or absent due to sickness — such as my Deputy Head or line manager.
94
+
95
+ Q: What do I do if I am late?
96
+ Expanded: What procedure should I follow if I expect to be late, delayed, or absent for work — who must I contact, for example my Deputy Head or line manager?
97
+
98
+ Now expand this query in the same way:
99
+ Q: {query}
100
+ Expanded:
101
  """
102
  response = openai_client.chat.completions.create(
103
  model = "gpt-4.1-mini",
 
130
  # Keep results above a relevance threshold
131
  if (distance is None or distance < 1.2) or (certainty and certainty >0.3):
132
  filtered_objects.append(o)
133
+
134
  return [(o.properties["text"], o.metadata.distance)for o in result.objects]
135
 
136
  def rerank_chunks_with_llm(query, chunks):