GitHub Actions commited on
Commit
9ae9702
ยท
1 Parent(s): 68e25b1

Auto-deploy from GitHub Actions - 2025-12-12 07:34:05

Browse files
Files changed (1) hide show
  1. app/routes.py +20 -4
app/routes.py CHANGED
@@ -1720,16 +1720,21 @@ def search_relevant_chunks(query, file_ids=None, model_name=None, top_k=5, min_s
1720
  expanded_file_ids.extend([child.id for child in child_files])
1721
 
1722
  # ๋ชจ๋ธ ํ•„ํ„ฐ๋ง์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ํŒŒ์ผ ID ํ•„ํ„ฐ๋ง
1723
- if model_name and expanded_file_ids:
 
1724
  filtered_files = UploadedFile.query.filter(
1725
  UploadedFile.id.in_(expanded_file_ids),
1726
  UploadedFile.model_name == model_name
1727
  ).all()
1728
  expanded_file_ids = [f.id for f in filtered_files]
1729
- elif model_name and not expanded_file_ids:
1730
  # ํŒŒ์ผ ID๊ฐ€ ์—†์œผ๋ฉด ๋ชจ๋ธ ์ด๋ฆ„์œผ๋กœ๋งŒ ํ•„ํ„ฐ๋ง
1731
  filtered_files = UploadedFile.query.filter_by(model_name=model_name).all()
1732
  expanded_file_ids = [f.id for f in filtered_files]
 
 
 
 
1733
 
1734
  # 1๋‹จ๊ณ„: ๋ฒกํ„ฐ ๊ฒ€์ƒ‰์œผ๋กœ ์ดˆ๊ธฐ 30๊ฐœ ๋ฌธ์„œ ๊ฒ€์ƒ‰
1735
  print(f"[๋ฒกํ„ฐ ๊ฒ€์ƒ‰] ์ฟผ๋ฆฌ: {query[:50]}..., ํŒŒ์ผ ID: {expanded_file_ids if expanded_file_ids else '๋ชจ๋“  ํŒŒ์ผ'}")
@@ -3382,6 +3387,17 @@ def chat():
3382
  if not answer_model:
3383
  answer_model = analysis_model
3384
 
 
 
 
 
 
 
 
 
 
 
 
3385
  # ๋‹ต๋ณ€์šฉ ๋ชจ๋ธ์ด ์—ฌ์ „ํžˆ ์—†์œผ๋ฉด ์—๋Ÿฌ ๋ฐ˜ํ™˜
3386
  if not answer_model:
3387
  return jsonify({'error': '๋‹ต๋ณ€์„ ์ƒ์„ฑํ•  AI ๋ชจ๋ธ์ด ์„ ํƒ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. "์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ AI ๋ชฉ๋ก"์—์„œ ๋‹ต๋ณ€์„ ์ƒ์„ฑํ•  AI ๋ชจ๋ธ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.'}), 400
@@ -3415,11 +3431,11 @@ def chat():
3415
  print(f"[RAG ๊ฒ€์ƒ‰ 2๋‹จ๊ณ„] GraphRAG ๋ฐ์ดํ„ฐ ์กฐํšŒ ์™„๋ฃŒ: ์—”ํ‹ฐํ‹ฐ {len(graph_data['entities'])}๊ฐœ, ๊ด€๊ณ„ {len(graph_data['relationships'])}๊ฐœ, ์‚ฌ๊ฑด {len(graph_data['events'])}๊ฐœ")
3416
 
3417
  # 3๋‹จ๊ณ„: ๋ฒกํ„ฐ ๊ฒ€์ƒ‰ + ๋ฆฌ๋žญํ‚น์œผ๋กœ Child Chunk ์ •๋ฐ€ ๊ฒ€์ƒ‰ (๋ถ„์„ ๋ชจ๋ธ ์‚ฌ์šฉ)
3418
- print(f"[RAG ๊ฒ€์ƒ‰ 3๋‹จ๊ณ„] ๋ฒกํ„ฐ ๊ฒ€์ƒ‰ + ๋ฆฌ๋žญํ‚น ์‹œ์ž‘ (๋ถ„์„ ๋ชจ๋ธ: {analysis_model})...")
3419
  relevant_chunks = search_relevant_chunks(
3420
  query=message,
3421
  file_ids=file_ids if file_ids else None,
3422
- model_name=analysis_model, # ์งˆ๋ฌธ ๋ถ„์„์€ analysis_model ์‚ฌ์šฉ
3423
  top_k=5, # ๋ฆฌ๋žญํ‚น ํ›„ ์ƒ์œ„ 5๊ฐœ๋งŒ ์„ ํƒ
3424
  min_score=0.5 # ์ตœ์†Œ ์ ์ˆ˜ ์ž„๊ณ„๊ฐ’
3425
  )
 
1720
  expanded_file_ids.extend([child.id for child in child_files])
1721
 
1722
  # ๋ชจ๋ธ ํ•„ํ„ฐ๋ง์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ํŒŒ์ผ ID ํ•„ํ„ฐ๋ง
1723
+ # model_name์ด 'all'์ธ ๊ฒฝ์šฐ ํ•„ํ„ฐ๋ง์„ ๊ฑด๋„ˆ๋œ€ (์ „์ฒด ๋ชจ๋ธ ๊ฒ€์ƒ‰)
1724
+ if model_name and model_name != 'all' and expanded_file_ids:
1725
  filtered_files = UploadedFile.query.filter(
1726
  UploadedFile.id.in_(expanded_file_ids),
1727
  UploadedFile.model_name == model_name
1728
  ).all()
1729
  expanded_file_ids = [f.id for f in filtered_files]
1730
+ elif model_name and model_name != 'all' and not expanded_file_ids:
1731
  # ํŒŒ์ผ ID๊ฐ€ ์—†์œผ๋ฉด ๋ชจ๋ธ ์ด๋ฆ„์œผ๋กœ๋งŒ ํ•„ํ„ฐ๋ง
1732
  filtered_files = UploadedFile.query.filter_by(model_name=model_name).all()
1733
  expanded_file_ids = [f.id for f in filtered_files]
1734
+ elif model_name == 'all' and not expanded_file_ids:
1735
+ # 'all'์ด๊ณ  ํŒŒ์ผ ID๊ฐ€ ์—†์œผ๋ฉด ๋ชจ๋“  ํŒŒ์ผ ๊ฒ€์ƒ‰ (ํ•˜์ง€๋งŒ ๋ณดํ†ต์€ ํŒŒ์ผ ID๊ฐ€ ์ „๋‹ฌ๋จ)
1736
+ # ์—ฌ๊ธฐ์„œ๋Š” ์•„๋ฌด๊ฒƒ๋„ ํ•˜์ง€ ์•Š์Œ (expanded_file_ids๊ฐ€ None์ด๋ฉด ๋ชจ๋“  ํŒŒ์ผ ๊ฒ€์ƒ‰ํ•˜๋ฏ€๋กœ)
1737
+ pass
1738
 
1739
  # 1๋‹จ๊ณ„: ๋ฒกํ„ฐ ๊ฒ€์ƒ‰์œผ๋กœ ์ดˆ๊ธฐ 30๊ฐœ ๋ฌธ์„œ ๊ฒ€์ƒ‰
1740
  print(f"[๋ฒกํ„ฐ ๊ฒ€์ƒ‰] ์ฟผ๋ฆฌ: {query[:50]}..., ํŒŒ์ผ ID: {expanded_file_ids if expanded_file_ids else '๋ชจ๋“  ํŒŒ์ผ'}")
 
3387
  if not answer_model:
3388
  answer_model = analysis_model
3389
 
3390
+ # 'all' ๋ชจ๋ธ ์ฒ˜๋ฆฌ: ์‹ค์ œ LLM ํ˜ธ์ถœ์šฉ ๋ชจ๋ธ๊ณผ ๊ฒ€์ƒ‰ ํ•„ํ„ฐ์šฉ ๋ชจ๋ธ ๊ตฌ๋ถ„
3391
+ search_model_filter = analysis_model
3392
+
3393
+ if analysis_model == 'all':
3394
+ # ๋ถ„์„์šฉ ๋ชจ๋ธ์€ ๊ธฐ๋ณธ๊ฐ’ ์‚ฌ์šฉ (Gemini Flash ๊ถŒ์žฅ)
3395
+ analysis_model = 'gemini:gemini-1.5-flash'
3396
+
3397
+ if answer_model == 'all':
3398
+ # ๋‹ต๋ณ€์šฉ ๋ชจ๋ธ๋„ ๊ธฐ๋ณธ๊ฐ’ ์‚ฌ์šฉ
3399
+ answer_model = 'gemini:gemini-1.5-flash'
3400
+
3401
  # ๋‹ต๋ณ€์šฉ ๋ชจ๋ธ์ด ์—ฌ์ „ํžˆ ์—†์œผ๋ฉด ์—๋Ÿฌ ๋ฐ˜ํ™˜
3402
  if not answer_model:
3403
  return jsonify({'error': '๋‹ต๋ณ€์„ ์ƒ์„ฑํ•  AI ๋ชจ๋ธ์ด ์„ ํƒ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. "์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ AI ๋ชฉ๋ก"์—์„œ ๋‹ต๋ณ€์„ ์ƒ์„ฑํ•  AI ๋ชจ๋ธ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”.'}), 400
 
3431
  print(f"[RAG ๊ฒ€์ƒ‰ 2๋‹จ๊ณ„] GraphRAG ๋ฐ์ดํ„ฐ ์กฐํšŒ ์™„๋ฃŒ: ์—”ํ‹ฐํ‹ฐ {len(graph_data['entities'])}๊ฐœ, ๊ด€๊ณ„ {len(graph_data['relationships'])}๊ฐœ, ์‚ฌ๊ฑด {len(graph_data['events'])}๊ฐœ")
3432
 
3433
  # 3๋‹จ๊ณ„: ๋ฒกํ„ฐ ๊ฒ€์ƒ‰ + ๋ฆฌ๋žญํ‚น์œผ๋กœ Child Chunk ์ •๋ฐ€ ๊ฒ€์ƒ‰ (๋ถ„์„ ๋ชจ๋ธ ์‚ฌ์šฉ)
3434
+ print(f"[RAG ๊ฒ€์ƒ‰ 3๋‹จ๊ณ„] ๋ฒกํ„ฐ ๊ฒ€์ƒ‰ + ๋ฆฌ๋žญํ‚น ์‹œ์ž‘ (๊ฒ€์ƒ‰ ํ•„ํ„ฐ: {search_model_filter})...")
3435
  relevant_chunks = search_relevant_chunks(
3436
  query=message,
3437
  file_ids=file_ids if file_ids else None,
3438
+ model_name=search_model_filter, # 'all'์ด๋ฉด ๋ชจ๋“  ๋ชจ๋ธ ๊ฒ€์ƒ‰
3439
  top_k=5, # ๋ฆฌ๋žญํ‚น ํ›„ ์ƒ์œ„ 5๊ฐœ๋งŒ ์„ ํƒ
3440
  min_score=0.5 # ์ตœ์†Œ ์ ์ˆ˜ ์ž„๊ณ„๊ฐ’
3441
  )