Compare commits
2 Commits
6f3df5fc51
...
be2bb856b0
Author | SHA1 | Date | |
---|---|---|---|
be2bb856b0 | |||
489f6b223c |
@ -4,9 +4,12 @@ from .models import User, Conversation
|
||||
from . import db
|
||||
from datetime import datetime, timedelta
|
||||
import openai
|
||||
import logging
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
logger = logging.getLogger('waitress')
|
||||
|
||||
|
||||
@main.route('/')
|
||||
def index():
|
||||
@ -99,8 +102,10 @@ def chat_post():
|
||||
messages=messages
|
||||
)
|
||||
msg_resp = openai_resp['choices'][0]['message']['content']
|
||||
except:
|
||||
except Exception as e:
|
||||
logger.error("OpenAI API request failed: %s", repr(e))
|
||||
msg_resp = "请求错误,请尝试重发。如果持续错误,请联系管理员检查。"
|
||||
|
||||
if msg_resp:
|
||||
response = {"message": msg_resp, "status": "success"}
|
||||
else:
|
||||
|
@ -7,11 +7,16 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="fixed-bottom form-inline">
|
||||
<textarea id="msgbox" class="form-control" style="width:85%; float: left; margin-bottom: 20px;" placeholder="说点什么吧"></textarea>
|
||||
<textarea id="msgbox"
|
||||
class="form-control"
|
||||
style="width:85%;
|
||||
float: left;
|
||||
margin-bottom: 20px"
|
||||
placeholder="说点什么吧"></textarea>
|
||||
<button id="btn-send"
|
||||
class="btn btn-info"
|
||||
type="button"
|
||||
style="width: 10%;"
|
||||
style="width: 10%"
|
||||
onclick="send_message()"
|
||||
disabled>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
@ -37,8 +42,14 @@
|
||||
btn_send.disabled = true;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
var textarea = document.getElementById("msgbox")
|
||||
textarea.addEventListener('keydown', function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
send_message()
|
||||
}
|
||||
});
|
||||
|
||||
function get_history() {
|
||||
var msgs
|
||||
$.ajax({
|
||||
|
Reference in New Issue
Block a user