new features
This commit is contained in:
@@ -47,6 +47,27 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return
|
||||
self.reply(200, b'{"message":{"content":"Page received."},"done":true}\n', 'application/x-ndjson')
|
||||
return
|
||||
if self.path == '/agent-prompt/api/chat':
|
||||
messages = message['messages']
|
||||
system, latest = messages[0]['content'], messages[-1]['content']
|
||||
if 'You are the Planning' in system:
|
||||
valid = (messages[1:-1] == [
|
||||
{'role': 'user', 'content': 'Translate red'},
|
||||
{'role': 'assistant', 'content': 'rouge'}
|
||||
] and latest == 'Translate Translate the word blue' and
|
||||
message.get('options', {}).get('num_predict') == 32)
|
||||
answer = 'Draft translation.'
|
||||
else:
|
||||
valid = ('You are the Reviewer' in system and len(messages) == 2 and
|
||||
latest.startswith('Translate the word blue') and 'Draft translation.' in latest and
|
||||
'[D1] Glossary' in latest and 'blue means bleu' in latest)
|
||||
answer = 'Bleu [D1].'
|
||||
if not valid:
|
||||
self.reply(400)
|
||||
return
|
||||
payload = json.dumps({'message': {'content': answer}, 'done': True}) + '\n'
|
||||
self.reply(200, payload.encode(), 'application/x-ndjson')
|
||||
return
|
||||
if self.path == '/chat-document/api/chat':
|
||||
user = message['messages'][-1]
|
||||
valid = (user['role'] == 'user' and
|
||||
|
||||
Reference in New Issue
Block a user