rag-rag commited on
Commit
b3ecb7a
·
1 Parent(s): 5239075

debug 002

Browse files
backend/chatgpt.py CHANGED
@@ -5,9 +5,11 @@ from backend.populate_vec_db_and_seach import search_book
5
 
6
  def generate(user_prompt,book_name):
7
  #book_name = "Pride And Prejudice"
8
-
 
 
9
  # 1. Vector search (returns list of dicts)
10
- hits = search_book(book_name, user_prompt, 5)
11
 
12
  # 2. Prepare a text block summarizing retrieved context
13
  context_text = "\n\n".join(
 
5
 
6
  def generate(user_prompt,book_name):
7
  #book_name = "Pride And Prejudice"
8
+ print(f"[DEBUG] In Generate Function with book_name :{book_name!r}")
9
+ print(f"[DEBUG] In Generate Function with user_prompt :{user_prompt!r}")
10
+
11
  # 1. Vector search (returns list of dicts)
12
+ hits = search_book(book_name, user_prompt)
13
 
14
  # 2. Prepare a text block summarizing retrieved context
15
  context_text = "\n\n".join(
backend/populate_vec_db_and_seach.py CHANGED
@@ -148,14 +148,16 @@ def create_populate_collection_if_not_exist(book_name_sup):
148
  def search_book(
149
  bookname: str,
150
  query_text: str,
151
- top_k: int = 5,
152
  score_threshold: float | None = None,
153
  ):
154
 
155
  client = get_client()
156
  model = get_model()
157
  # 1) Embed the query text
 
158
  query_vector = list(model.embed([query_text]))[0]
 
159
  collection_name = collection_name_for_book(bookname)
160
  # 2) Query Qdrant with cosine similarity (collection is configured as COSINE)
161
  result = client.query_points(
@@ -176,6 +178,7 @@ def search_book(
176
  "text": point.payload["text"]
177
  }
178
  )
 
179
  return hits
180
 
181
 
 
148
  def search_book(
149
  bookname: str,
150
  query_text: str,
151
+ top_k: int = 10,
152
  score_threshold: float | None = None,
153
  ):
154
 
155
  client = get_client()
156
  model = get_model()
157
  # 1) Embed the query text
158
+ print("[DEBUG] Calculating Query Vector ........")
159
  query_vector = list(model.embed([query_text]))[0]
160
+ print(f"Query Vecot : {query_vector}")
161
  collection_name = collection_name_for_book(bookname)
162
  # 2) Query Qdrant with cosine similarity (collection is configured as COSINE)
163
  result = client.query_points(
 
178
  "text": point.payload["text"]
179
  }
180
  )
181
+ print(f"We got some paragraphs Hits:{hits[0]}")
182
  return hits
183
 
184