Signed-off-by: yihong0618 <zouzou0208@gmail.com>tags/0.15.1
| "SIM108", # if-else-block-instead-of-if-exp | "SIM108", # if-else-block-instead-of-if-exp | ||||
| "SIM113", # enumerate-for-loop | "SIM113", # enumerate-for-loop | ||||
| "SIM117", # multiple-with-statements | "SIM117", # multiple-with-statements | ||||
| "SIM210", # if-expr-with-true-false | |||||
| ] | ] | ||||
| [lint.per-file-ignores] | [lint.per-file-ignores] |
| pinned = None | pinned = None | ||||
| if "pinned" in args and args["pinned"] is not None: | if "pinned" in args and args["pinned"] is not None: | ||||
| pinned = True if args["pinned"] == "true" else False | |||||
| pinned = args["pinned"] == "true" | |||||
| try: | try: | ||||
| with Session(db.engine) as session: | with Session(db.engine) as session: |
| tenant_id=app_model.tenant_id, | tenant_id=app_model.tenant_id, | ||||
| app_id=app_model.id, | app_id=app_model.id, | ||||
| type="service_api", | type="service_api", | ||||
| is_anonymous=True if user_id == "DEFAULT-USER" else False, | |||||
| is_anonymous=user_id == "DEFAULT-USER", | |||||
| session_id=user_id, | session_id=user_id, | ||||
| ) | ) | ||||
| db.session.add(end_user) | db.session.add(end_user) |
| pinned = None | pinned = None | ||||
| if "pinned" in args and args["pinned"] is not None: | if "pinned" in args and args["pinned"] is not None: | ||||
| pinned = True if args["pinned"] == "true" else False | |||||
| pinned = args["pinned"] == "true" | |||||
| try: | try: | ||||
| with Session(db.engine) as session: | with Session(db.engine) as session: |
| if value.lower() not in {"true", "false"}: | if value.lower() not in {"true", "false"}: | ||||
| raise ValueError(f"Variable {credential_form_schema.variable} should be true or false") | raise ValueError(f"Variable {credential_form_schema.variable} should be true or false") | ||||
| value = True if value.lower() == "true" else False | |||||
| value = value.lower() == "true" | |||||
| return value | return value |
| hnsw_ef_construction = kwargs.pop("hnsw_ef_construction", 500) | hnsw_ef_construction = kwargs.pop("hnsw_ef_construction", 500) | ||||
| ivfpq_m = kwargs.pop("ivfpq_m", dimension) | ivfpq_m = kwargs.pop("ivfpq_m", dimension) | ||||
| nlist = kwargs.pop("nlist", 1000) | nlist = kwargs.pop("nlist", 1000) | ||||
| centroids_use_hnsw = kwargs.pop("centroids_use_hnsw", True if nlist >= 5000 else False) | |||||
| centroids_use_hnsw = kwargs.pop("centroids_use_hnsw", nlist >= 5000) | |||||
| centroids_hnsw_m = kwargs.pop("centroids_hnsw_m", 24) | centroids_hnsw_m = kwargs.pop("centroids_hnsw_m", 24) | ||||
| centroids_hnsw_ef_construct = kwargs.pop("centroids_hnsw_ef_construct", 500) | centroids_hnsw_ef_construct = kwargs.pop("centroids_hnsw_ef_construct", 500) | ||||
| centroids_hnsw_ef_search = kwargs.pop("centroids_hnsw_ef_search", 100) | centroids_hnsw_ef_search = kwargs.pop("centroids_hnsw_ef_search", 100) | ||||
| if method_name == "ivfpq": | if method_name == "ivfpq": | ||||
| ivfpq_m = kwargs["ivfpq_m"] | ivfpq_m = kwargs["ivfpq_m"] | ||||
| nlist = kwargs["nlist"] | nlist = kwargs["nlist"] | ||||
| centroids_use_hnsw = True if nlist > 10000 else False | |||||
| centroids_use_hnsw = nlist > 10000 | |||||
| centroids_hnsw_m = 24 | centroids_hnsw_m = 24 | ||||
| centroids_hnsw_ef_construct = 500 | centroids_hnsw_ef_construct = 500 | ||||
| centroids_hnsw_ef_search = 100 | centroids_hnsw_ef_search = 100 |