Skip to content

Commit

Permalink
Query against rlsrag (#75)
Browse files Browse the repository at this point in the history
* Update query to use RLSAPI instead of RCS

* Update query code to rlsrag backend
  • Loading branch information
r0x0d authored Dec 23, 2024
1 parent 4e17eb6 commit 10fdcbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions command_line_assistant/daemon/http/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand All @@ -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
12 changes: 7 additions & 5 deletions tests/daemon/http/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
)

Expand All @@ -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):
Expand All @@ -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(
Expand Down

0 comments on commit 10fdcbc

Please sign in to comment.