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

The connect_signals was triggered the API request twice #73

Merged
merged 1 commit into from
Dec 19, 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
12 changes: 3 additions & 9 deletions command_line_assistant/dbus/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@
class QueryInterface(InterfaceTemplate):
"""The DBus interface of a query."""

def connect_signals(self) -> None:
"""Connect the signals."""
# Watch for property changes based on the query_changed method.
self.watch_property("RetrieveAnswer", self.implementation.query_changed)

@property
def RetrieveAnswer(self) -> Structure:
"""This method is mainly called by the client to retrieve it's answer."""
output = Message()
llm_response = submit(
self.implementation.query.message, self.implementation.config
)
print("llm_response", llm_response)
output.message = llm_response
return Message.to_structure(output)
message = Message()
message.message = llm_response
return Message.to_structure(message)

@emits_properties_changed
def ProcessQuery(self, query: Structure) -> None:
Expand Down
6 changes: 0 additions & 6 deletions tests/dbus/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ def query_interface(mock_implementation):


class TestQueryInterface:
def test_connect_signals(self, query_interface, mock_implementation):
query_interface.connect_signals()
query_interface.watch_property.assert_called_once_with(
"RetrieveAnswer", mock_implementation.query_changed
)

@patch("command_line_assistant.dbus.interfaces.submit")
def test_retrieve_answer_success(
self, mock_submit, query_interface, mock_implementation
Expand Down
Loading