### What problem does this PR solve? Fix graphrag + infinity bugs ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)tags/v0.14.1
| q_vec = matchDense.embedding_data | q_vec = matchDense.embedding_data | ||||
| src = req.get("fields", ["docnm_kwd", "content_ltks", "kb_id", "img_id", "title_tks", "important_kwd", | src = req.get("fields", ["docnm_kwd", "content_ltks", "kb_id", "img_id", "title_tks", "important_kwd", | ||||
| "doc_id", f"q_{len(q_vec)}_vec", "position_list", "name_kwd", | "doc_id", f"q_{len(q_vec)}_vec", "position_list", "name_kwd", | ||||
| "q_1024_vec", "q_1536_vec", "available_int", "content_with_weight", | |||||
| "weight_int", "weight_flt", "rank_int" | |||||
| "available_int", "content_with_weight", | |||||
| "weight_int", "weight_flt" | |||||
| ]) | ]) | ||||
| fusionExpr = FusionExpr("weighted_sum", 32, {"weights": "0.5, 0.5"}) | fusionExpr = FusionExpr("weighted_sum", 32, {"weights": "0.5, 0.5"}) |
| if prog is not None: | if prog is not None: | ||||
| d["progress"] = prog | d["progress"] = prog | ||||
| try: | try: | ||||
| logging.info(f"set_progress({task_id}), progress: {prog}, progress_msg: {msg}") | |||||
| TaskService.update_progress(task_id, d) | TaskService.update_progress(task_id, d) | ||||
| except Exception: | except Exception: | ||||
| logging.exception(f"set_progress({task_id}) got exception") | logging.exception(f"set_progress({task_id}) got exception") |
| vector_similarity_weight = float(weights.split(",")[1]) | vector_similarity_weight = float(weights.split(",")[1]) | ||||
| for m in matchExprs: | for m in matchExprs: | ||||
| if isinstance(m, MatchTextExpr): | if isinstance(m, MatchTextExpr): | ||||
| minimum_should_match = "0%" | |||||
| if "minimum_should_match" in m.extra_options: | |||||
| minimum_should_match = str(int(m.extra_options["minimum_should_match"] * 100)) + "%" | |||||
| minimum_should_match = m.extra_options.get("minimum_should_match", 0.0) | |||||
| if isinstance(minimum_should_match, float): | |||||
| minimum_should_match = str(int(minimum_should_match * 100)) + "%" | |||||
| bqry.must.append(Q("query_string", fields=m.fields, | bqry.must.append(Q("query_string", fields=m.fields, | ||||
| type="best_fields", query=m.matching_text, | type="best_fields", query=m.matching_text, | ||||
| minimum_should_match=minimum_should_match, | minimum_should_match=minimum_should_match, |
| if len(filter_cond) != 0: | if len(filter_cond) != 0: | ||||
| filter_fulltext = f"({filter_cond}) AND {filter_fulltext}" | filter_fulltext = f"({filter_cond}) AND {filter_fulltext}" | ||||
| logging.debug(f"filter_fulltext: {filter_fulltext}") | logging.debug(f"filter_fulltext: {filter_fulltext}") | ||||
| minimum_should_match = "0%" | |||||
| if "minimum_should_match" in matchExpr.extra_options: | |||||
| minimum_should_match = ( | |||||
| str(int(matchExpr.extra_options["minimum_should_match"] * 100)) | |||||
| + "%" | |||||
| ) | |||||
| matchExpr.extra_options.update( | |||||
| {"minimum_should_match": minimum_should_match} | |||||
| ) | |||||
| minimum_should_match = matchExpr.extra_options.get("minimum_should_match", 0.0) | |||||
| if isinstance(minimum_should_match, float): | |||||
| str_minimum_should_match = str(int(minimum_should_match * 100)) + "%" | |||||
| matchExpr.extra_options["minimum_should_match"] = str_minimum_should_match | |||||
| for k, v in matchExpr.extra_options.items(): | for k, v in matchExpr.extra_options.items(): | ||||
| if not isinstance(v, str): | if not isinstance(v, str): | ||||
| matchExpr.extra_options[k] = str(v) | matchExpr.extra_options[k] = str(v) |