From 78dba3b911e69c29883d126ffa96c7572098977d Mon Sep 17 00:00:00 2001 From: "jinli.yl" Date: Tue, 10 Jun 2025 12:29:28 +0800 Subject: [PATCH] format fix --- .../module/agent_wrapper/agent_wrapper_mixin.py | 2 -- .../module/context_generator/base_context_generator.py | 6 +++--- .../module/context_generator/step_context_generator.py | 5 +++-- experiencemaker/module/prompt/prompt_mixin.py | 1 - experiencemaker/module/runner/base_runner.py | 2 +- .../module/summarizer/simple_summarizer_prompt.yaml | 2 +- experiencemaker/module/summarizer/step_summarizer.py | 7 ++++--- experiencemaker/service/experience_maker_service.py | 3 ++- experiencemaker/storage/base_vector_store.py | 2 -- experiencemaker/tool/dashscope_search_tool.py | 1 + experiencemaker/tool/mcp_tool.py | 1 - experiencemaker/utils/http_client.py | 1 - experiencemaker/utils/registry.py | 2 +- experiencemaker/utils/util_function.py | 4 +++- 14 files changed, 19 insertions(+), 20 deletions(-) diff --git a/experiencemaker/module/agent_wrapper/agent_wrapper_mixin.py b/experiencemaker/module/agent_wrapper/agent_wrapper_mixin.py index 58e4b078..a432834f 100644 --- a/experiencemaker/module/agent_wrapper/agent_wrapper_mixin.py +++ b/experiencemaker/module/agent_wrapper/agent_wrapper_mixin.py @@ -14,5 +14,3 @@ class AgentWrapperMixin(BaseModel, ABC): def execute(self, query: str, **kwargs) -> Trajectory: raise NotImplementedError - - diff --git a/experiencemaker/module/context_generator/base_context_generator.py b/experiencemaker/module/context_generator/base_context_generator.py index 8c49cb0d..c22b6509 100644 --- a/experiencemaker/module/context_generator/base_context_generator.py +++ b/experiencemaker/module/context_generator/base_context_generator.py @@ -21,9 +21,9 @@ class BaseContextGenerator(BaseModel, ABC): raise NotImplementedError def _generate_context_message(self, - trajectory: Trajectory, - nodes: List[VectorStoreNode], - **kwargs) -> ContextMessage: + trajectory: Trajectory, + nodes: List[VectorStoreNode], + **kwargs) -> ContextMessage: raise NotImplementedError def execute(self, trajectory: Trajectory, **kwargs) -> ContextMessage: diff --git a/experiencemaker/module/context_generator/step_context_generator.py b/experiencemaker/module/context_generator/step_context_generator.py index 2313dbbb..9223493c 100644 --- a/experiencemaker/module/context_generator/step_context_generator.py +++ b/experiencemaker/module/context_generator/step_context_generator.py @@ -1,6 +1,7 @@ import json import re -from typing import List, Dict, Any, Optional +from typing import List + from loguru import logger from pydantic import Field, model_validator @@ -390,4 +391,4 @@ class StepContextGenerator(BaseContextGenerator): except json.JSONDecodeError: logger.warning(f"Failed to parse JSON response for key '{key}'") - return "" \ No newline at end of file + return "" diff --git a/experiencemaker/module/prompt/prompt_mixin.py b/experiencemaker/module/prompt/prompt_mixin.py index eab0cec4..e1e8aba3 100644 --- a/experiencemaker/module/prompt/prompt_mixin.py +++ b/experiencemaker/module/prompt/prompt_mixin.py @@ -1,7 +1,6 @@ from pathlib import Path import yaml -from langchain_core.prompts import load_prompt from loguru import logger from pydantic import BaseModel, Field, model_validator diff --git a/experiencemaker/module/runner/base_runner.py b/experiencemaker/module/runner/base_runner.py index e0db5abc..cb90519f 100644 --- a/experiencemaker/module/runner/base_runner.py +++ b/experiencemaker/module/runner/base_runner.py @@ -24,4 +24,4 @@ class BaseRunner(BaseModel): raise NotImplementedError def summary(self, **kwargs): - raise NotImplementedError \ No newline at end of file + raise NotImplementedError diff --git a/experiencemaker/module/summarizer/simple_summarizer_prompt.yaml b/experiencemaker/module/summarizer/simple_summarizer_prompt.yaml index 3a0f7283..6ca36914 100644 --- a/experiencemaker/module/summarizer/simple_summarizer_prompt.yaml +++ b/experiencemaker/module/summarizer/simple_summarizer_prompt.yaml @@ -16,7 +16,7 @@ summary_prompt: | Finally, summarize generalized experience from handling such problems to accumulate experience for future similar tasks. The experience should be broadly applicable, such as how to use tools effectively or approaches to solving certain types of problems. Also, specify the conditions or scenarios in which these experience are applicable. - + # Output Format Output the scenarios or conditions in which applying this experience would be particularly effective... Output generalized experience, concise content is required... \ No newline at end of file diff --git a/experiencemaker/module/summarizer/step_summarizer.py b/experiencemaker/module/summarizer/step_summarizer.py index 991ca68a..9caa2e3d 100644 --- a/experiencemaker/module/summarizer/step_summarizer.py +++ b/experiencemaker/module/summarizer/step_summarizer.py @@ -1,8 +1,9 @@ +import json import re import uuid -import json -from typing import List, Dict, Any, Optional, Tuple from datetime import datetime +from typing import List, Dict, Any, Optional, Tuple + from loguru import logger from pydantic import Field, model_validator @@ -577,4 +578,4 @@ class StepSummarizer(BaseSummarizer): all_experiences.extend(sample.steps) if all_experiences: - self.store_experiences(all_experiences, **kwargs) \ No newline at end of file + self.store_experiences(all_experiences, **kwargs) diff --git a/experiencemaker/service/experience_maker_service.py b/experiencemaker/service/experience_maker_service.py index bfdc9dc3..90711da4 100644 --- a/experiencemaker/service/experience_maker_service.py +++ b/experiencemaker/service/experience_maker_service.py @@ -159,7 +159,8 @@ class ExperienceMakerService(BaseModel): data["embedding_model"] = cls.init_embedding_model(data["embedding_model"]) if "vector_store" in data: - data["vector_store"] = cls.init_vector_store(data["vector_store"], embedding_model=data["embedding_model"]) + data["vector_store"] = cls.init_vector_store(data["vector_store"], + embedding_model=data["embedding_model"]) if "context_generator" in data: data["context_generator"] = cls.init_context_generator(data["context_generator"], data) diff --git a/experiencemaker/storage/base_vector_store.py b/experiencemaker/storage/base_vector_store.py index d858be73..9674c6cb 100644 --- a/experiencemaker/storage/base_vector_store.py +++ b/experiencemaker/storage/base_vector_store.py @@ -24,5 +24,3 @@ class BaseVectorStore(BaseModel, ABC): def retrieve_by_query(self, query: str, top_k: int = 3, **kwargs) -> List[VectorStoreNode]: raise NotImplementedError - - diff --git a/experiencemaker/tool/dashscope_search_tool.py b/experiencemaker/tool/dashscope_search_tool.py index 8048411e..46e5a320 100644 --- a/experiencemaker/tool/dashscope_search_tool.py +++ b/experiencemaker/tool/dashscope_search_tool.py @@ -140,6 +140,7 @@ Extract the original content related to the user's question directly from the co else: return result + def main(): from experiencemaker.utils.util_function import load_env_keys load_env_keys() diff --git a/experiencemaker/tool/mcp_tool.py b/experiencemaker/tool/mcp_tool.py index 1ffdbd43..21315da4 100644 --- a/experiencemaker/tool/mcp_tool.py +++ b/experiencemaker/tool/mcp_tool.py @@ -1,4 +1,3 @@ - import asyncio from typing import List diff --git a/experiencemaker/utils/http_client.py b/experiencemaker/utils/http_client.py index feadb053..245781df 100644 --- a/experiencemaker/utils/http_client.py +++ b/experiencemaker/utils/http_client.py @@ -24,7 +24,6 @@ class HttpClient(BaseModel): _client: Any = PrivateAttr() - def __init__(self, **kwargs): super().__init__(**kwargs) self._client = requests.Session() if self.keep_alive else requests diff --git a/experiencemaker/utils/registry.py b/experiencemaker/utils/registry.py index 909102fa..1fedf0cb 100644 --- a/experiencemaker/utils/registry.py +++ b/experiencemaker/utils/registry.py @@ -40,4 +40,4 @@ class Registry(Generic[T]): return self.module_dict[module_name] def __contains__(self, module_name: str): - return module_name in self.module_dict \ No newline at end of file + return module_name in self.module_dict diff --git a/experiencemaker/utils/util_function.py b/experiencemaker/utils/util_function.py index e699d3ef..08fde209 100644 --- a/experiencemaker/utils/util_function.py +++ b/experiencemaker/utils/util_function.py @@ -1,8 +1,10 @@ import json import os import re + from loguru import logger + def get_html_match_content(content: str, key: str): pattern = rf"<{key}>(.*?)" match = re.search(pattern, content, re.DOTALL) @@ -18,4 +20,4 @@ def load_env_keys(): for k, v in config.items(): os.environ[k] = v else: - logger.warning(".env file not found~") \ No newline at end of file + logger.warning(".env file not found~")