fix garak config paths

This commit is contained in:
Adam Wilson
2025-05-28 05:57:23 -06:00
parent 5bf67d7432
commit 6d6082cf00
4 changed files with 52 additions and 51 deletions
@@ -14,6 +14,7 @@ class HttpApiController:
def register_routes(self):
"""Register all API routes"""
self.routes[('GET', '/')] = self.health_check
self.routes[('POST', '/api/conversations')] = self.handle_conversations
self.routes[('POST', '/api/rag_conversations')] = self.handle_conversations_with_rag
@@ -40,6 +41,12 @@ class HttpApiController:
response_body = json.dumps({'response': str(data)}).encode('utf-8')
return response_body
def health_check(self, env, start_response):
response_body = self.format_response({ "success": True })
response_headers = [('Content-Type', 'application/json'), ('Content-Length', str(len(response_body)))]
start_response('200 OK', response_headers)
return [response_body]
def handle_conversations(self, env, start_response):
"""Handle POST requests to /api/conversations"""
try:
@@ -110,9 +117,6 @@ class HttpApiController:
method = env.get('REQUEST_METHOD').upper()
path = env.get('PATH_INFO')
if method != 'POST':
return self.__http_415_notsupported(env, start_response)
try:
handler = self.routes.get((method, path), self.__http_200_ok)
return handler(env, start_response)