Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetting rules and memory upon deactivation #139

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* delete rules and memory from discourse_answerer

* This is wrong - from wafl_ll
<|end|><|assistant|><|user|> Hi!<|end|><|assistant|>
The user is sandwiched between the assistant. It should be:
Expand Down
3 changes: 0 additions & 3 deletions wafl/answerer/base_answerer.py

This file was deleted.

7 changes: 5 additions & 2 deletions wafl/answerer/dialogue_answerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
create_memory_from_fact_list,
select_best_rules_using_entailer,
)
from wafl.answerer.base_answerer import BaseAnswerer
from wafl.answerer.rule_maker import RuleMaker
from wafl.connectors.clients.llm_chat_client import LLMChatClient
from wafl.data_objects.dataclasses import Query, Answer
from wafl.interface.conversation import Conversation, Utterance
from wafl.simple_text_processing.questions import is_question


class DialogueAnswerer(BaseAnswerer):
class DialogueAnswerer:
def __init__(self, config, knowledge, interface, code_path, logger):
self._threshold_for_facts = 0.85
self._client = LLMChatClient(config)
Expand All @@ -43,6 +42,10 @@ def __init__(self, config, knowledge, interface, code_path, logger):
max_num_rules=1,
)

def reset(self):
self._prior_facts = []
self._prior_rules = []

async def answer(self, query_text: str) -> Answer:
if self._logger:
self._logger.write(f"Dialogue Answerer: the query is {query_text}")
Expand Down
3 changes: 3 additions & 0 deletions wafl/events/conversation_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def __init__(
if logger:
self._logger.set_depth(0)

def reset(self):
self._answerer.reset()

async def output(self, text: str):
await self._interface.output(text)

Expand Down
1 change: 1 addition & 0 deletions wafl/handlers/conversation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ async def _main_loop(self):
and interactions == 1
):
self._interface.deactivate()
self._conversation_events.reset()
num_misses = 0

if (
Expand Down
Loading