index.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <head>
  2. <meta charset="UTF-8">
  3. <script type="text/javascript" src="/js/jquery.min.js" crossorigin="anonymous"></script>
  4. <link rel="stylesheet" href="/css/bootstrap.min.css" crossorigin="anonymous">
  5. <script type="text/javascript" src="/js/bootstrap.min.js" crossorigin="anonymous"></script>
  6. <link rel="preconnect" href="https://fonts.gstatic.com">
  7. <link href="https://fonts.loli.net/css2?family=Anonymous+Pro:ital,wght@0,400;0,700;1,400;1,700
  8. &family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  9. <link rel="stylesheet" href="/css/style.css">
  10. <title>chat</title>
  11. <script>
  12. var running = 0, inputText;
  13. function input() {
  14. inputText = $('#chatInput').val()
  15. }
  16. function chat() {
  17. input()
  18. if (running);
  19. $('#chatBtn').text('Send...')
  20. $('#chatBtn').addClass('disabled')
  21. $('.frame').addClass('text-muted')
  22. running = 1;
  23. return $.get('/chat?' + ((inputText == '') ? case1 : inputText), function (e) {
  24. $('.frame')[0].innerHTML = (e.charAt(0) == '!') ? ('<pre class="text-danger bg-danger">' + e.slice(1, e.length) + '</pre>') : e;
  25. if (e.charAt(0) != '!') balText = e
  26. $('#chatBtn').text('Send')
  27. $('#chatBtn').removeClass('disabled')
  28. $('.frame').removeClass('text-muted')
  29. running = 0;
  30. })
  31. }
  32. $(function () {
  33. $("#chatInput").keydown(function (e) {
  34. if (e.keyCode == 13) {
  35. $("#chatBtn")[0].click();
  36. }
  37. })
  38. });
  39. </script>
  40. <style>
  41. .well {
  42. padding: 10px;
  43. border: 1px solid rgb(173, 173, 173);
  44. background-color: #f5f5f5;
  45. margin-top: 5px;
  46. min-height: 160px;
  47. border-radius: 5px;
  48. width: 100%;
  49. overflow-x: auto;
  50. overflow-y: auto;
  51. }
  52. pre {
  53. overflow-x: auto;
  54. overflow-y: auto;
  55. white-space: pre-wrap;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <div class="row">
  61. <div class="col-lg-2 col-md-2 col-xs-12">
  62. <a class="btn btn-info" href="/fun"><i class="glyphicon glyphicon-home" aria-hidden="true"></i>&nbsp;返回</a>
  63. <hr>
  64. </div>
  65. <div class="col-lg-8 col-md-10 col-xs-12">
  66. 输入英语句子与 ChatGPT 对话。不要滥用接口,是直接在服务器上跑的 python。
  67. <div class="input-group">
  68. <input id="chatInput" type="text" class="form-control" oninput="input()" autocomplete="off">
  69. <span class="input-group-btn">
  70. <button type="button" class="btn btn-default" onclick="chat()" id="chatBtn">Send</button>
  71. </span>
  72. </div>
  73. <hr>
  74. <div class="well frame">
  75. </div>
  76. </div>
  77. <div class="col-lg-2 col-md-2 col-xs-12">
  78. <a class="btn btn-info" id="chat" href="ai-game/"><span
  79. class="glyphicon glyphicon-comment"></span>&nbsp;&nbsp;AI 设计的小游戏</a>
  80. </div>
  81. </div>
  82. </body>