Skip to content

Commit

Permalink
Merge pull request #477 from theClassLight/GG/pr
Browse files Browse the repository at this point in the history
refactor(lightrag): 优化hashing_kv初始化逻辑
  • Loading branch information
LarFii authored Dec 17, 2024
2 parents a3bf3a5 + 9893e93 commit c840a05
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lightrag/lightrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ def __post_init__(self):
self.llm_model_func = limit_async_func_call(self.llm_model_max_async)(
partial(
self.llm_model_func,
hashing_kv=self.llm_response_cache,
hashing_kv=self.llm_response_cache
if self.llm_response_cache
and hasattr(self.llm_response_cache, "global_config")
else self.key_string_value_json_storage_cls(
global_config=asdict(self),
),
**self.llm_model_kwargs,
)
)
Expand Down Expand Up @@ -515,7 +520,12 @@ async def aquery(self, query: str, param: QueryParam = QueryParam()):
self.text_chunks,
param,
asdict(self),
hashing_kv=self.llm_response_cache,
hashing_kv=self.llm_response_cache
if self.llm_response_cache
and hasattr(self.llm_response_cache, "global_config")
else self.key_string_value_json_storage_cls(
global_config=asdict(self),
),
)
elif param.mode == "naive":
response = await naive_query(
Expand All @@ -524,7 +534,12 @@ async def aquery(self, query: str, param: QueryParam = QueryParam()):
self.text_chunks,
param,
asdict(self),
hashing_kv=self.llm_response_cache,
hashing_kv=self.llm_response_cache
if self.llm_response_cache
and hasattr(self.llm_response_cache, "global_config")
else self.key_string_value_json_storage_cls(
global_config=asdict(self),
),
)
else:
raise ValueError(f"Unknown mode {param.mode}")
Expand Down

0 comments on commit c840a05

Please sign in to comment.