GPTindex.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="gpt-box">
  3. <div class="dialogue-all dialogueone" style="overflow-y: auto;">
  4. <div v-for="(item,index) in dialogueArr" :key="index" class="dialogue-box">
  5. <div class="user-dialogue">{{ item.userdialogue }}</div>
  6. <!-- <div class="gpt-dialogue">{{ item.GPTdialogue }}</div> -->
  7. <vue-typed-js
  8. class="gpt-dialogue"
  9. :strings="item.GPTdialogue"
  10. :showCursor="true"
  11. :cursorChar="'_'"
  12. :startDelay="300"
  13. :typeSpeed="50"
  14. >
  15. <span class="typing"></span>
  16. </vue-typed-js>
  17. </div>
  18. </div>
  19. <div class="dialogue-all" >
  20. <el-input
  21. type="textarea"
  22. placeholder="请输入内容"
  23. @keyup.enter.native="ChatGptCompletions()"
  24. :autosize="{ minRows: 2, maxRows: 4}"
  25. v-model="textarea">
  26. </el-input>
  27. <el-button @click="ChatGptCompletions()" type="primary" icon="el-icon-search">搜索</el-button>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. typingTexts: [
  36. "翻译机器翻译是另一个GPT的应用领域,它可以将一种语言的文本转换为另一种语言的文本。使用GPT进行机器翻译的一个好处是可以在源语言和目标语言之间进行平滑的转换,从而提高翻译的质量。3、问答系统GPT可以用于构建问答系统,其基本原理是通过学习训练数据中的问题和答案,将问题转换为特定领域的答案。当输入一个问题时,GPT可以预测出最有可能的答案,从而提高问答系统的质量。4、语音识别GPT也可以用于语音识别,其原理与文本生成类似。使用GPT进行语音识别的一个好处是可以进行语音到文本的转化,从而将语音转化为可观看的文本内容。"
  37. ],
  38. textarea: '',
  39. dialogueArr:[
  40. ]
  41. }
  42. },
  43. methods:{
  44. ChatGptCompletions(){
  45. console.log(typeof this.textarea)
  46. var url = "/api/SmallFun/ChatGptCompletions"
  47. var that = this;
  48. this.$axios({
  49. method: 'post',
  50. url: url,
  51. headers: {
  52. Authorization: 'Bearer ' + that.token
  53. },
  54. data: {
  55. prompt:that.textarea
  56. }
  57. }).then(function (res) {
  58. console.log(res);
  59. if (res.data.code == 200) {
  60. that.dialogueArr.push({userdialogue:that.textarea,GPTdialogue:[res.data.data]})
  61. }
  62. that.textarea="";
  63. console.log(that.dialogueArr)
  64. })
  65. },
  66. },
  67. mounted(){
  68. document.querySelector(".dialogue-all").style.height = window.innerHeight-210 + "px";
  69. }
  70. }
  71. </script>
  72. <style>
  73. .dialogue-all{
  74. background-color: #fff;
  75. padding: 10px;
  76. box-shadow: 0 0 5px #0005;
  77. border-radius: 10px;
  78. position: relative;
  79. }
  80. .user-dialogue{
  81. border: 1px solid #DCDFE6;
  82. border-radius: 4px;
  83. padding: 5px 15px;
  84. background-color: #F7F7F9;
  85. font-size: inherit;
  86. color: #606266;
  87. margin-bottom: 20px;
  88. }
  89. .gpt-dialogue{
  90. border: 1px solid #DCDFE6;
  91. border-radius: 4px;
  92. padding: 5px 15px;
  93. font-size: inherit;
  94. color: #FFF;
  95. margin-bottom: 20px;
  96. background-color: #002A76;
  97. }
  98. .dialogue-all:nth-child(1){
  99. margin-bottom: 16px;
  100. }
  101. .dialogue-all:nth-child(2){
  102. display: flex;
  103. justify-content: space-between;
  104. align-items: end;
  105. }
  106. .dialogue-all .el-textarea{
  107. width: 94%;
  108. }
  109. .dialogue-all .el-button{
  110. height: 54px;
  111. }
  112. /*滚动条样式*/
  113. .dialogueone::-webkit-scrollbar {
  114. width: 4px;
  115. /*height: 4px;*/
  116. }
  117. .dialogueone::-webkit-scrollbar-thumb {
  118. border-radius: 10px;
  119. -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
  120. background: rgba(0,0,0,0.2);
  121. }
  122. .dialogueone::-webkit-scrollbar-track {
  123. -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
  124. border-radius: 0;
  125. background: rgba(0,0,0,0.1);
  126. }
  127. .dialogueone .typed-element{
  128. display: inline-block;
  129. text-align: justify;
  130. }
  131. </style>