fix:ruff
This commit is contained in:
@@ -470,7 +470,7 @@ async def chat_feedback_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
|
||||
handled_message_ids = getattr(self._runtime, "_test_query_message_ids", None)
|
||||
if handled_message_ids is None:
|
||||
handled_message_ids = set()
|
||||
setattr(self._runtime, "_test_query_message_ids", handled_message_ids)
|
||||
self._runtime._test_query_message_ids = handled_message_ids
|
||||
|
||||
if latest_message.message_id not in handled_message_ids and (
|
||||
"回忆" in latest_text or "再查" in latest_text
|
||||
|
||||
@@ -23,10 +23,7 @@ from src.common.logger import get_logger
|
||||
from .presets import (
|
||||
EmbeddingModelConfig,
|
||||
get_custom_config,
|
||||
validate_config_compatibility,
|
||||
are_models_compatible,
|
||||
)
|
||||
from ..utils.quantization import QuantizationType
|
||||
|
||||
logger = get_logger("A_Memorix.EmbeddingManager")
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, Dict, Any, Union
|
||||
from typing import Optional, Union
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import asyncio
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional, List, Dict, Any, Tuple, Union
|
||||
from typing import Optional, List, Dict, Any, Tuple
|
||||
from enum import Enum
|
||||
|
||||
import numpy as np
|
||||
@@ -320,7 +320,7 @@ class DualPathRetriever:
|
||||
|
||||
# 调试模式:打印结果原文
|
||||
if self.config.debug:
|
||||
logger.info(f"[DEBUG] 检索结果内容原文:")
|
||||
logger.info("[DEBUG] 检索结果内容原文:")
|
||||
for i, res in enumerate(results):
|
||||
logger.info(f" {i+1}. [{res.result_type}] (Score: {res.score:.4f}) {res.content}")
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ Personalized PageRank实现
|
||||
提供个性化的图节点排序功能。
|
||||
"""
|
||||
|
||||
from typing import Dict, List, Optional, Tuple, Union, Any
|
||||
from typing import Dict, List, Optional, Tuple, Any
|
||||
from dataclasses import dataclass
|
||||
import numpy as np
|
||||
|
||||
from src.common.logger import get_logger
|
||||
from ..storage import GraphStore
|
||||
@@ -49,7 +48,7 @@ class PageRankConfig:
|
||||
raise ValueError(f"min_iterations必须大于等于0: {self.min_iterations}")
|
||||
|
||||
if self.min_iterations >= self.max_iter:
|
||||
raise ValueError(f"min_iterations必须小于max_iter")
|
||||
raise ValueError("min_iterations必须小于max_iter")
|
||||
|
||||
|
||||
class PersonalizedPageRank:
|
||||
|
||||
@@ -56,7 +56,7 @@ class ThresholdConfig:
|
||||
raise ValueError(f"max_threshold必须在[0, 1]之间: {self.max_threshold}")
|
||||
|
||||
if self.min_threshold >= self.max_threshold:
|
||||
raise ValueError(f"min_threshold必须小于max_threshold")
|
||||
raise ValueError("min_threshold必须小于max_threshold")
|
||||
|
||||
if not 0 <= self.percentile <= 100:
|
||||
raise ValueError(f"percentile必须在[0, 100]之间: {self.percentile}")
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Coroutine, cast
|
||||
|
||||
from src.common.logger import get_logger
|
||||
|
||||
@@ -4,7 +4,6 @@ import asyncio
|
||||
import json
|
||||
import pickle
|
||||
import time
|
||||
import uuid
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
@@ -19,7 +18,7 @@ from src.services.llm_service import LLMServiceClient
|
||||
|
||||
from ...paths import default_data_dir, resolve_repo_path
|
||||
from ..embedding import create_embedding_api_adapter
|
||||
from ..retrieval import RetrievalResult, SparseBM25Config, SparseBM25Index, TemporalQueryOptions
|
||||
from ..retrieval import RetrievalResult, SparseBM25Config, SparseBM25Index
|
||||
from ..storage import GraphStore, MetadataStore, QuantizationType, SparseMatrixFormat, VectorStore
|
||||
from ..utils.aggregate_query_service import AggregateQueryService
|
||||
from ..utils.episode_retrieval_service import EpisodeRetrievalService
|
||||
|
||||
@@ -9,7 +9,6 @@ from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union, Tuple, List, Dict, Set, Any
|
||||
from collections import defaultdict
|
||||
import threading
|
||||
import asyncio
|
||||
|
||||
import numpy as np
|
||||
@@ -42,7 +41,6 @@ except ImportError:
|
||||
|
||||
import contextlib
|
||||
from src.common.logger import get_logger
|
||||
from ..utils.hash import compute_hash
|
||||
from ..utils.io import atomic_write
|
||||
|
||||
logger = get_logger("A_Memorix.GraphStore")
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
基于Faiss的高效向量存储与检索,支持SQ8量化、Append-Only磁盘存储和内存映射。
|
||||
"""
|
||||
|
||||
import os
|
||||
import pickle
|
||||
import hashlib
|
||||
import shutil
|
||||
@@ -191,7 +190,7 @@ class VectorStore:
|
||||
self._update_reservoir(batch_vecs)
|
||||
# 这里的 TRAIN_SIZE 取默认 10k,或者根据当前数据量动态判断
|
||||
if len(self._reservoir_buffer) >= 10000:
|
||||
logger.info(f"训练样本达到上限,开始训练...")
|
||||
logger.info("训练样本达到上限,开始训练...")
|
||||
self._train_and_replay_unlocked()
|
||||
|
||||
self._total_added += len(batch_ids)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List, Dict, Any, Optional, Union
|
||||
from typing import List, Dict, Any
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
import hashlib
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import re
|
||||
from typing import List, Dict, Any
|
||||
from typing import List
|
||||
from .base import BaseStrategy, ProcessedChunk, KnowledgeType, SourceInfo, ChunkContext
|
||||
|
||||
class FactualStrategy(BaseStrategy):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import re
|
||||
from typing import List, Dict, Any
|
||||
from typing import List
|
||||
from .base import BaseStrategy, ProcessedChunk, KnowledgeType, SourceInfo, ChunkContext
|
||||
|
||||
class NarrativeStrategy(BaseStrategy):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import List, Dict, Any
|
||||
from typing import List
|
||||
from .base import BaseStrategy, ProcessedChunk, KnowledgeType, SourceInfo, ChunkContext, ChunkFlags
|
||||
|
||||
class QuoteStrategy(BaseStrategy):
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
import hashlib
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
|
||||
def compute_hash(text: str, hash_type: str = "sha256") -> str:
|
||||
|
||||
@@ -5,7 +5,6 @@ IO Utilities
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import contextlib
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
实现 Aho-Corasick 算法用于多模式匹配。
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Tuple, Set, Any
|
||||
from typing import List, Dict, Tuple, Set
|
||||
from collections import deque
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
from typing import Any, Dict, List, Sequence, Tuple
|
||||
|
||||
from ..retrieval.dual_path import RetrievalResult
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ async def ensure_runtime_self_check(
|
||||
sample_text=sample_text,
|
||||
)
|
||||
try:
|
||||
setattr(plugin_or_config, "_runtime_self_check_report", report)
|
||||
plugin_or_config._runtime_self_check_report = report
|
||||
except Exception:
|
||||
pass
|
||||
return report
|
||||
|
||||
@@ -287,7 +287,7 @@ class SearchExecutionService:
|
||||
|
||||
async def _executor() -> Dict[str, Any]:
|
||||
original_ppr = bool(getattr(retriever.config, "enable_ppr", True))
|
||||
setattr(retriever.config, "enable_ppr", bool(request.enable_ppr))
|
||||
retriever.config.enable_ppr = bool(request.enable_ppr)
|
||||
started_at = time.time()
|
||||
try:
|
||||
retrieved = await retriever.retrieve(
|
||||
@@ -380,7 +380,7 @@ class SearchExecutionService:
|
||||
elapsed_ms = (time.time() - started_at) * 1000.0
|
||||
return {"results": retrieved, "elapsed_ms": elapsed_ms}
|
||||
finally:
|
||||
setattr(retriever.config, "enable_ppr", original_ppr)
|
||||
retriever.config.enable_ppr = original_ppr
|
||||
|
||||
dedup_hit = False
|
||||
try:
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
导入到 A_memorix 的存储组件中。
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import json
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
_runtime_kernel: Any = None
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ for _path in (SRC_ROOT, PROJECT_ROOT, PLUGIN_ROOT):
|
||||
if _path_str not in sys.path:
|
||||
sys.path.insert(0, _path_str)
|
||||
|
||||
from A_memorix.paths import config_path, default_data_dir, resolve_repo_path
|
||||
from A_memorix.paths import config_path, default_data_dir
|
||||
|
||||
DEFAULT_CONFIG_PATH = config_path()
|
||||
DEFAULT_DATA_DIR = default_data_dir()
|
||||
|
||||
@@ -10,14 +10,12 @@ LPMM 到 A_memorix 存储转换器
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import asyncio
|
||||
import pickle
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, List, Tuple
|
||||
from typing import Dict, Any, Tuple
|
||||
import numpy as np
|
||||
import tomlkit
|
||||
|
||||
|
||||
@@ -12,17 +12,14 @@
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from rich.console import Console
|
||||
from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
|
||||
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
|
||||
import argparse
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import time
|
||||
import tomlkit
|
||||
|
||||
@@ -17,7 +17,7 @@ import sqlite3
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
|
||||
import tomlkit
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ from src.chat.message_receive.message import SessionMessage
|
||||
from src.common.data_models.message_component_data_model import EmojiComponent, ImageComponent, MessageSequence
|
||||
from src.common.logger import get_logger
|
||||
from src.common.prompt_i18n import load_prompt
|
||||
from src.config.config import global_config
|
||||
from src.core.tooling import ToolExecutionContext, ToolExecutionResult, ToolInvocation, ToolSpec
|
||||
from src.llm_models.exceptions import ReqAbortException
|
||||
from src.llm_models.payload_content.tool_option import ToolCall
|
||||
|
||||
Reference in New Issue
Block a user