new features

This commit is contained in:
Mark Gregory
2026-11-16 13:41:54 +00:00
parent 87cdc990c3
commit 5338ae5751
16 changed files with 546 additions and 55 deletions
+17
View File
@@ -24,6 +24,14 @@ class Handler(BaseHTTPRequestHandler):
message = self.body()
method = message.get('method')
args = message.get('params', {})
if self.path == '/gateway/api/chat':
if self.headers.get('Authorization') != 'Bearer fixture-token':
self.reply(401)
return
assert message['model'] == 'fixture:latest' and message['stream']
payload = b'{"message":{"content":"fixture answer"},"done":false}\n{"done":true}\n'
self.reply(200, payload, 'application/x-ndjson')
return
if self.path == '/ollama/api/pull':
assert message['model'] == 'fixture:latest'
self.server.models.add(message['model'])
@@ -72,6 +80,15 @@ class Handler(BaseHTTPRequestHandler):
self.reply(200, envelope, headers=headers)
def do_GET(self):
if self.path == '/gateway/api/tags':
if self.headers.get('Authorization') != 'Bearer fixture-token':
self.reply(401)
return
self.reply(200, {'models': [{'name': 'fixture:latest'}]})
return
if self.path == '/redirect/api/tags':
self.reply(302, headers=[('Location', '/gateway/api/tags')])
return
assert self.path == '/ollama/api/tags'
self.reply(200, {'models': [{'name': model, 'size': 100} for model in self.server.models]})