### What problem does this PR solve? ### Type of change - [x] Refactoringtags/v0.16.0
| if not e: | if not e: | ||||
| return get_data_error_result( | return get_data_error_result( | ||||
| message="Database error (Knowledgebase rename)!") | message="Database error (Knowledgebase rename)!") | ||||
| kb = kb.to_dict() | |||||
| kb.update(req) | |||||
| return get_json_result(data=kb.to_json()) | |||||
| return get_json_result(data=kb) | |||||
| except Exception as e: | except Exception as e: | ||||
| return server_error_response(e) | return server_error_response(e) | ||||
| ) | ) | ||||
| except Exception: | except Exception: | ||||
| pass | pass | ||||
| try: | |||||
| DB.execute_sql('ALTER TABLE llm DROP PRIMARY KEY;') | |||||
| DB.execute_sql('ALTER TABLE llm ADD PRIMARY KEY (llm_name,fid);') | |||||
| except Exception: | |||||
| pass | |||||
| try: | try: | ||||
| migrate( | migrate( | ||||
| migrator.add_column('task', 'retry_count', IntegerField(default=0)) | migrator.add_column('task', 'retry_count', IntegerField(default=0)) |
| def update_progress(): | def update_progress(): | ||||
| while True: | while True: | ||||
| time.sleep(3) | |||||
| time.sleep(6) | |||||
| try: | try: | ||||
| DocumentService.update_progress() | DocumentService.update_progress() | ||||
| except Exception: | except Exception: |
| def corpNorm(nm, add_region=True): | def corpNorm(nm, add_region=True): | ||||
| global CORP_TKS | global CORP_TKS | ||||
| if not nm or isinstance(nm, str): | |||||
| if not nm or not isinstance(nm, str): | |||||
| return "" | return "" | ||||
| nm = rag_tokenizer.tradi2simp(rag_tokenizer.strQ2B(nm)).lower() | nm = rag_tokenizer.tradi2simp(rag_tokenizer.strQ2B(nm)).lower() | ||||
| nm = re.sub(r"&", "&", nm) | nm = re.sub(r"&", "&", nm) |
| from abc import ABC, abstractmethod | from abc import ABC, abstractmethod | ||||
| from dataclasses import dataclass | from dataclasses import dataclass | ||||
| import numpy as np | import numpy as np | ||||
| import polars as pl | |||||
| DEFAULT_MATCH_VECTOR_TOPN = 10 | DEFAULT_MATCH_VECTOR_TOPN = 10 | ||||
| DEFAULT_MATCH_SPARSE_TOPN = 10 | DEFAULT_MATCH_SPARSE_TOPN = 10 | ||||
| knowledgebaseIds: list[str], | knowledgebaseIds: list[str], | ||||
| aggFields: list[str] = [], | aggFields: list[str] = [], | ||||
| rank_feature: dict | None = None | rank_feature: dict | None = None | ||||
| ) -> list[dict] | pl.DataFrame: | |||||
| ): | |||||
| """ | """ | ||||
| Search with given conjunctive equivalent filtering condition and return all fields of matched documents | Search with given conjunctive equivalent filtering condition and return all fields of matched documents | ||||
| """ | """ |