mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-26 15:24:48 +08:00
feat: add context compress (#590)
* feat:Add context compress * feat: Add unit test * feat: add unit test for context manager * feat: add postprocessor param && code format * feat: add configuration guide * fix: fix the configuration_guide * fix: fix the unit test * fix: fix the default value * feat: add test and log for context_manager
This commit is contained in:
@@ -11,6 +11,14 @@ from langchain_tavily._utilities import TAVILY_API_URL
|
||||
from langchain_tavily.tavily_search import (
|
||||
TavilySearchAPIWrapper as OriginalTavilySearchAPIWrapper,
|
||||
)
|
||||
from src.tools.search_postprocessor import SearchResultPostProcessor
|
||||
from src.config import load_yaml_config
|
||||
|
||||
|
||||
def get_search_config():
|
||||
config = load_yaml_config("conf.yaml")
|
||||
search_config = config.get("SEARCH_ENGINE", {})
|
||||
return search_config
|
||||
|
||||
|
||||
class EnhancedTavilySearchAPIWrapper(OriginalTavilySearchAPIWrapper):
|
||||
@@ -110,4 +118,13 @@ class EnhancedTavilySearchAPIWrapper(OriginalTavilySearchAPIWrapper):
|
||||
"image_description": image["description"],
|
||||
}
|
||||
clean_results.append(clean_result)
|
||||
|
||||
search_config = get_search_config()
|
||||
clean_results = SearchResultPostProcessor(
|
||||
min_score_threshold=search_config.get("min_score_threshold"),
|
||||
max_content_length_per_page=search_config.get(
|
||||
"max_content_length_per_page"
|
||||
),
|
||||
).process_results(clean_results)
|
||||
|
||||
return clean_results
|
||||
|
||||
Reference in New Issue
Block a user