diff --git a/command_line_assistant/daemon/http/query.py b/command_line_assistant/daemon/http/query.py index 3776466..acdb406 100644 --- a/command_line_assistant/daemon/http/query.py +++ b/command_line_assistant/daemon/http/query.py @@ -19,8 +19,8 @@ def submit(query: str, config: Config) -> str: query = handle_caret(query, config) # NOTE: Add more query handling here - query_endpoint = f"{config.backend.endpoint}/v1/query" - payload = {"query": query} + query_endpoint = f"{config.backend.endpoint}/infer" + payload = {"question": query} try: logger.info("Waiting for response from AI...") @@ -33,7 +33,8 @@ def submit(query: str, config: Config) -> str: response.raise_for_status() data = response.json() - return data.get("response", "") + data = data.get("data", {}) + return data.get("text", "") except RequestException as e: logger.error("Failed to get response from AI: %s", e) raise diff --git a/tests/daemon/http/test_query.py b/tests/daemon/http/test_query.py index c7e5cfd..002173c 100644 --- a/tests/daemon/http/test_query.py +++ b/tests/daemon/http/test_query.py @@ -10,9 +10,9 @@ @responses.activate def test_handle_query(): responses.post( - url="http://localhost/v1/query", + url="http://localhost/infer", json={ - "response": "test", + "data": {"text": "test"}, }, ) @@ -30,12 +30,12 @@ def test_handle_query(): @responses.activate def test_handle_query_raising_status(): responses.post( - url="http://localhost/v1/query", + url="http://localhost/infer", status=404, ) config = Config( backend=BackendSchema( - endpoint="http://localhost/v1/query", auth=AuthSchema(verify_ssl=False) + endpoint="http://localhost/infer", auth=AuthSchema(verify_ssl=False) ) ) with pytest.raises(requests.exceptions.RequestException): @@ -44,7 +44,9 @@ def test_handle_query_raising_status(): @responses.activate def test_disable_ssl_verification(caplog): - responses.post(url="https://localhost/v1/query", json={"response": "yeah, test!"}) + responses.post( + url="https://localhost/infer", json={"data": {"text": "yeah, test!"}} + ) config = Config( backend=BackendSchema(