Skip to content

Commit f806b98

Browse files
refactor: add dynamic interaction_settings property to wdoc class
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4.5) <aider@aider.chat>
1 parent a94a889 commit f806b98

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

wdoc/wdoc.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,40 @@ def print_exception(exc_type, exc_value, exc_traceback):
651651
self.interaction_settings
652652
)
653653

654+
@property
655+
def interaction_settings(self) -> dict:
656+
"""
657+
Returns current interaction settings as a dict.
658+
659+
This property dynamically builds the settings dict from the current
660+
attribute values, ensuring it's always up to date.
661+
"""
662+
return {
663+
"top_k": self.top_k,
664+
"multiline": False,
665+
"retriever": self.query_retrievers,
666+
"task": self.task,
667+
"relevancy": self.query_relevancy,
668+
}
669+
670+
@interaction_settings.setter
671+
def interaction_settings(self, value: dict) -> None:
672+
"""
673+
Updates interaction settings from a dict.
674+
675+
This setter updates the underlying attributes based on the dict values,
676+
allowing ask_user() to modify the settings.
677+
"""
678+
if "top_k" in value:
679+
self.top_k = value["top_k"]
680+
if "retriever" in value:
681+
self.query_retrievers = value["retriever"]
682+
if "task" in value:
683+
self.task = value["task"]
684+
if "relevancy" in value:
685+
self.query_relevancy = value["relevancy"]
686+
# Note: "multiline" is not stored as an attribute
687+
654688
def summary_task(self) -> "wdoc.utils.tasks.summarize.wdocSummary":
655689
from wdoc.utils.tasks.summarize import summarize_documents
656690

@@ -784,15 +818,6 @@ def _query_or_search_task(self, query: str) -> dict:
784818
private=self.private,
785819
)
786820

787-
# set default ask_user argument
788-
self.interaction_settings = {
789-
"top_k": self.top_k,
790-
"multiline": False,
791-
"retriever": self.query_retrievers,
792-
"task": self.task,
793-
"relevancy": self.query_relevancy,
794-
}
795-
796821
# parse filters as callable for faiss filtering
797822
if not self._is_vectorstore_filtered:
798823
if (

0 commit comments

Comments
 (0)