Use connected knowledge and Gitea from chat

This commit is contained in:
Mark Gregory
2026-11-16 16:03:22 +00:00
parent f7b1083f39
commit 00ea78671b
7 changed files with 187 additions and 66 deletions
+11
View File
@@ -40,6 +40,17 @@ 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 == '/chat-tools/api/chat':
system, user = message['messages']
valid = (system['role'] == 'system' and 'fixture/visible-repo' in system['content']
and 'source: knowledge.md' in system['content']
and user == {'role': 'user', 'content': 'can you see my git repos'})
if not valid:
self.reply(400)
return
self.reply(200, b'{"message":{"content":"Repository and knowledge received."},"done":true}\n',
'application/x-ndjson')
return
if self.path == '/gateway/api/chat':
if self.headers.get('Authorization') != 'Bearer fixture-token':
self.reply(401)