new features
This commit is contained in:
@@ -47,11 +47,21 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return
|
||||
self.reply(200, b'{"message":{"content":"Page received."},"done":true}\n', 'application/x-ndjson')
|
||||
return
|
||||
if self.path == '/chat-document/api/chat':
|
||||
user = message['messages'][-1]
|
||||
valid = (user['role'] == 'user' and
|
||||
user['content'].startswith('Tell me about this\n\n') and
|
||||
'brief.txt' in user['content'] and 'Cobalt river trail' in user['content'])
|
||||
if not valid:
|
||||
self.reply(400)
|
||||
return
|
||||
self.reply(200, b'{"message":{"content":"Document received."},"done":true}\n', 'application/x-ndjson')
|
||||
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'})
|
||||
and user == {'role': 'user', 'content': 'can you see my git repos and search the knowledge base for guidance'})
|
||||
if not valid:
|
||||
self.reply(400)
|
||||
return
|
||||
@@ -132,6 +142,27 @@ class Handler(BaseHTTPRequestHandler):
|
||||
{'url': 'file:///etc/hosts', 'title': 'Invalid'},
|
||||
{'url': page, 'title': 'Duplicate'}]})
|
||||
return
|
||||
if self.path.startswith('/search-relevance?'):
|
||||
assert 'teh' not in self.path
|
||||
base = f'http://127.0.0.1:{self.server.server_port}'
|
||||
self.reply(200, {'results': [
|
||||
{'url': base + '/typo-page', 'title': 'Urban Dictionary: teh', 'content': 'A spelling entry.'},
|
||||
{'url': base + '/prompt-page', 'title': 'Prompt engineering examples', 'content': 'Examples of using prompts.'}
|
||||
]})
|
||||
return
|
||||
if self.path == '/typo-page':
|
||||
self.reply(500)
|
||||
return
|
||||
if self.path == '/prompt-page':
|
||||
self.reply(200, b'<title>Prompt examples</title><p>Describe the desired task and output.</p>', 'text/html')
|
||||
return
|
||||
if self.path.startswith('/search-blocked?'):
|
||||
page = f'http://127.0.0.1:{self.server.server_port}/blocked-article'
|
||||
self.reply(200, {'results': [{'url': page, 'title': 'Fusion facts', 'content': 'Fusion combines nuclei.'}]})
|
||||
return
|
||||
if self.path == '/blocked-article':
|
||||
self.reply(403)
|
||||
return
|
||||
if self.path == '/follow-root':
|
||||
self.reply(200, b'<h1>Index</h1><a href="/follow-detail">Tides documentation</a>', 'text/html')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user