Feature/config service (#332)

Configuration service provides an API to change configuration. Complete configuration is pushed down a config queue so that users have a complete copy of config object.
This commit is contained in:
cybermaggedon 2025-04-01 19:47:05 +01:00 committed by GitHub
parent 21bda863a7
commit fa09dc319e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1002 additions and 5 deletions

View file

@ -382,3 +382,33 @@ class Api:
if resp.status_code != 200:
raise ProtocolException(f"Status code {resp.status_code}")
def get_config(self):
# The input consists of system and prompt strings
input = {
"operation": "config"
}
url = f"{self.url}config"
# Invoke the API, input is passed as JSON
resp = requests.post(url, json=input)
# Should be a 200 status code
if resp.status_code != 200:
raise ProtocolException(f"Status code {resp.status_code}")
try:
# Parse the response as JSON
object = resp.json()
except:
raise ProtocolException(f"Expected JSON response")
self.check_error(resp)
try:
return object["config"], object["version"]
except:
raise ProtocolException(f"Response not formatted correctly")