new features

This commit is contained in:
Mark Gregory
2026-11-18 08:32:12 +00:00
parent 8061981ccb
commit 8467977403
6 changed files with 383 additions and 16 deletions
+24
View File
@@ -40,6 +40,30 @@ class Handler(BaseHTTPRequestHandler):
payload = ''.join(f'data: {json.dumps(frame)}\n\n' for frame in frames)
self.reply(200, (payload + 'data: [DONE]\n\n').encode(), 'text/event-stream')
return
if self.path == '/compatible/api/v1/chat':
valid = (self.headers.get('Authorization') == 'Bearer fixture-token'
and message.get('integrations') == ['mcp/fixture']
and message.get('system_prompt') == 'Silent instruction'
and message.get('input') == 'Previous conversation for reference:\nuser: Earlier question\n\nassistant: Earlier answer\n\nLatest message:\nUse the fixture'
and message.get('stream') is True and message.get('store') is False)
if not valid:
self.reply(400)
return
frames = [
{'type': 'tool_call.start'},
{'type': 'reasoning.delta', 'content': 'Checking'},
{'type': 'message.delta', 'content': 'Plugin response'},
{'type': 'chat.end', 'result': {'stats': {'total_output_tokens': 2}}},
]
payload = ''.join(f"event: {frame['type']}\ndata: {json.dumps(frame)}\n\n" for frame in frames)
self.reply(200, payload.encode(), 'text/event-stream')
return
if self.path == '/chat-rag-off/api/chat':
if any('Cobalt river trail' in item['content'] for item in message['messages']):
self.reply(400)
return
self.reply(200, b'{"message":{"content":"RAG is off."},"done":true}\n', 'application/x-ndjson')
return
if self.path == '/chat-web/api/chat':
system, user = message['messages']
if system['role'] != 'system' or 'Test passage.' not in system['content'] or '/article' not in user['content']: