Jake-seong commited on
Commit
4567d8b
·
verified ·
1 Parent(s): 53be236

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -107,9 +107,14 @@ def search_similar_chat(query: str, max_results: int = 100) -> List[Dict]:
107
  query_embedding, agent_w,
108
  limit
109
  )
 
110
  cur.execute(sql, params)
111
  rows = cur.fetchall()
112
 
 
 
 
 
113
  results = []
114
  for row in rows:
115
  id_val = row[0]
@@ -139,10 +144,16 @@ def search_similar_chat(query: str, max_results: int = 100) -> List[Dict]:
139
  results.append(result)
140
  except Exception as e:
141
  print(f"메타데이터 파싱 오류: {e}")
 
142
  continue
143
 
144
  # 임계값 필터링
145
  filtered_results = [r for r in results if r["similarityScore"] >= threshold]
 
 
 
 
 
146
 
147
  return filtered_results
148
 
@@ -261,9 +272,14 @@ def search_similar_chat_by_date(
261
  params.append(limit)
262
 
263
  with conn.cursor() as cur:
 
264
  cur.execute(sql, tuple(params))
265
  rows = cur.fetchall()
266
 
 
 
 
 
267
  results = []
268
  for row in rows:
269
  id_val = row[0]
@@ -293,10 +309,16 @@ def search_similar_chat_by_date(
293
  results.append(result)
294
  except Exception as e:
295
  print(f"메타데이터 파싱 오류: {e}")
 
296
  continue
297
 
298
  # 임계값 필터링
299
  filtered_results = [r for r in results if r["similarityScore"] >= threshold]
 
 
 
 
 
300
 
301
  return filtered_results
302
 
 
107
  query_embedding, agent_w,
108
  limit
109
  )
110
+ print(f"쿼리 실행 - 파라미터: 가중치 설정={full_w}, {topic_w}, {customer_w}, {agent_w}, 결과 제한={limit}")
111
  cur.execute(sql, params)
112
  rows = cur.fetchall()
113
 
114
+ print(f"검색 결과: 총 {len(rows)}개 데이터 조회됨")
115
+ if len(rows) > 0:
116
+ print(f"첫 번째 결과 ID: {rows[0][0]}, 유사도: {float(rows[0][3])}")
117
+
118
  results = []
119
  for row in rows:
120
  id_val = row[0]
 
144
  results.append(result)
145
  except Exception as e:
146
  print(f"메타데이터 파싱 오류: {e}")
147
+ print(f"문제가 발생한 메타데이터: {metadata_json[:200]}...")
148
  continue
149
 
150
  # 임계값 필터링
151
  filtered_results = [r for r in results if r["similarityScore"] >= threshold]
152
+ print(f"임계값({threshold}) 이상 결과: {len(filtered_results)}개 / 전체 {len(results)}개")
153
+
154
+ if len(filtered_results) > 0:
155
+ print(f"가장 높은 유사도 점수: {filtered_results[0]['similarityScore']}")
156
+ print(f"상위 결과 챗ID: {filtered_results[0].get('chatId')}, 주제: {filtered_results[0].get('topic', '')[:50]}...")
157
 
158
  return filtered_results
159
 
 
272
  params.append(limit)
273
 
274
  with conn.cursor() as cur:
275
+ print(f"날짜 검색 쿼리 실행: 시작일={start_date}({start_timestamp}), 종료일={end_date}({end_timestamp})")
276
  cur.execute(sql, tuple(params))
277
  rows = cur.fetchall()
278
 
279
+ print(f"날짜 필터링 검색 결과: 총 {len(rows)}개 데이터 조회됨")
280
+ if len(rows) > 0:
281
+ print(f"첫 번째 결과 ID: {rows[0][0]}, 유사도: {float(rows[0][3])}")
282
+
283
  results = []
284
  for row in rows:
285
  id_val = row[0]
 
309
  results.append(result)
310
  except Exception as e:
311
  print(f"메타데이터 파싱 오류: {e}")
312
+ print(f"문제가 발생한 메타데이터: {metadata_json[:200]}...")
313
  continue
314
 
315
  # 임계값 필터링
316
  filtered_results = [r for r in results if r["similarityScore"] >= threshold]
317
+ print(f"날짜 검색 - 임계값({threshold}) 이상 결과: {len(filtered_results)}개 / 전체 {len(results)}개")
318
+
319
+ if len(filtered_results) > 0:
320
+ print(f"날짜 검색 - 가장 높은 유사도 점수: {filtered_results[0]['similarityScore']}")
321
+ print(f"날짜 검색 - 상위 결과 챗ID: {filtered_results[0].get('chatId')}, 시작시간: {filtered_results[0].get('startTime')}")
322
 
323
  return filtered_results
324