mirror of
https://github.com/NovaOSS/LingoSynth.git
synced 2024-11-29 10:03:57 +01:00
22 lines
523 B
Python
22 lines
523 B
Python
import flask
|
|
|
|
from . import ai, prompts
|
|
|
|
def register(app: flask.Flask):
|
|
@app.route('/api/rephrase', methods=['GET', 'POST'])
|
|
@app.rate_limiter.limit('2 per second')
|
|
def api_rephrase():
|
|
text = flask.request.args.get('text') or flask.request.json.get('text')
|
|
|
|
messages = prompts.MESSAGES
|
|
messages.append({
|
|
'role': 'user',
|
|
'content': text
|
|
})
|
|
|
|
return flask.jsonify(
|
|
{
|
|
'text': ai.generate(messages)
|
|
}
|
|
)
|