vue实现二次元虚拟人播报交互回答的chatgpt聊天对话程序代码

代码语言:html

所属分类:其他

代码描述:vue实现二次元虚拟人播报交互回答的chatgpt聊天对话程序代码,内包含免费的chatgpt接口调用。

代码标签: vue 二次元 虚拟人 播报 交互 回答 chatgpt 聊天 对话 程序 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

<style>

@import 'https://fonts.googleapis.com/css?family=Roboto+Condensed:300';
* {
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  background-color: #3fc26d;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 16px;
  line-height: 1.875em;
}

.container {
  flex: 1 0 auto;
  margin-top: 50px;
  margin-bottom: 50px;

  box-shadow: 10px 10px 0 #87f4ad;
  background-color: #fff;
}

.small {
  font-size: 0.75em;
  line-height: 1.5em;
}

.disabled {
  color: #c4c4c4;
}

.chat-wrapper {
  display: flex;
  flex-direction: column;
  padding: 30px;
  height: 600px;
  overflow-y: auto;
}
.bubble  pre{
     white-space: pre-wrap;
     color:#ececec;
     background: black;
     padding: 10px;
    margin: 0;
}
.bubble  p{
    margin: 0;
    padding: 2px;
}
.bubble  ol{
    margin: 0;
    padding:0 0 0 18px;
}
.bubble  li{
    margin: 0;
    padding: 2px;
}
.bubble {
        line-height: 22px;
  position: relative;
    white-space: pre-wrap;
  width: auto;
  max-width: 650px;
  margin-bottom: 20px;
  padding: 20px 40px;
  border-radius: 25px;
  box-shadow: 5px 5px 0 #87f4ad;
  font-weight: 300;
  transform: scale(0);
  -webkit-animation-name: scaleAll;
          animation-name: scaleAll;
  -webkit-animation-duration: 0.35s;
          animation-duration: 0.35s;
  -webkit-animation-timing-function: cubic-bezier(0, 0.51, 0.31, 1.51);
          animation-timing-function: cubic-bezier(0, 0.51, 0.31, 1.51);
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}
.bubble-right {
  margin-left: auto;
  border-bottom-right-radius: 3px;
  background-color: #7be5bc;
  transform-origin: bottom right;
}
.bubble-left {
  margin-right: auto;
  border-bottom-left-radius: 3px;
  background-color: #3fc26d;
  color: #fff;
  transform-origin: bottom left;
}
.bubble-left + .bubble-left {
  -webkit-animation-delay: 1s;
          animation-delay: 1s;
}
.bubble-left + .bubble-left + .bubble-left {
  -webkit-animation-delay: 2s;
          animation-delay: 2s;
}
.bubble .dot {
  margin: 0 2px;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: rgba(199, 70, 232, 0.7);
  line-height: 1em;
  display: inline-block;
  -webkit-animation-name: bouncyBlink;
          animation-name: bouncyBlink;
  -webkit-animation-duration: 0.9s;
          animation-duration: 0.9s;
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
          animation-timing-function: ease-in-out;
}
.bubble .dot:nth-child(2) {
  animation-delay: 0.1s;
  -webkit-animation-delay: 0.1s;
}
.bubble .dot:nth-child(3) {
  animation-delay: 0.2s;
  -webkit-animation-delay: 0.2s;
}

.input-control {
  padding: 15px 20px;
  font-family: "Roboto Condensed", sans-serif;
  border-radius: 3px;
  border: none;
  font-size: 1em;
}

.input-button {
  background-color: #87f4ad;
  color: #fff;
  transition: 0.35s;
  cursor: pointer;
}
.input-button:hover {
  background-color: #3fc26d;
}

.chat-input {
  display: flex;
  flex-wrap: wrap;
  padding: 20px;
  background-color: #7be5bc;
}
.chat-input .input-text {
  flex: 1 80%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.chat-input .input-button {
  flex: 1 auto;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

@-webkit-keyframes scaleAll {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes scaleAll {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}
@-webkit-keyframes bouncyBlink {
  0%, 45%, 100% {
    background-color: rgba(199, 70, 232, 0.5);
    transform: translateY(0);
  }
  25% {
    background-color: #87f4ad;
    transform: translateY(-10px);
  }
  35% {
    background-color: rgba(199, 70, 232, 0.75);
    transform: translateY(5px);
  }
}
@keyframes bouncyBlink {
  0%, 45%, 100% {
    background-color: rgba(199, 70, 232, 0.5);
    transform: translateY(0);
  }
  25% {
    background-color: #87f4ad;
    transform: translateY(-10px);
  }
  35% {
    background-color: rgba(199, 70, 232, 0.75);
    transform: translateY(5px);
  }
}
.controlbar{
    font-size: 12px;
    float: right;
    cursor: pointer;
}
#canvas{
    
    position: absolute;
    height: 400px;
    top:10px;
    right: 20px;
    z-index: 1111;
 
}
</style>

  
  
</head>

<body >
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/live2dcubismcore.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/live2d.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pixi.6.5.2.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pixi-live2d-display.index.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pixi-live2d-display.extra.js"></script>
<canvas id="canvas"></canvas>

<div id="app" class="container">

	<div id="wrapper" class="chat-wrapper">
		<bubble 
			v-for="content in contents"
			v-bind:bubbtext="content.text"
				v-bind:oldtext="content.oldtext"
			
				v-bind:ifnew="content.isnew"
			
			v-bind:class="content.isUser ? 'bubble-right' : 'bubble-left'"
		>
		</bubble>
		<div v-show="thinking" class="bubble bubble-left bubble-thinking">
			<span class="dot"></span>
			<span class="dot"></span>
			<span class="dot"></span>
		</div>
		<p v-if="noResponses" class="small disabled">User has left the chat. ☹️</p>
	</div>
	<div  v-on:click="stopoutput" v-if="ifoutping">停止</div>
	<div class="chat-input">
		<input 
			v-on:keyup.enter="addToChat"
			v-model="newMessage"
			type="text" 
			name="chatText" 
			id="chatText" 
			class="input-control input-text" 
			placeholder="Type a message" 
		/>
		<button v-on:click="addToChat" class="input-control input-button">Send</button>
	</div>
</div>


<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/highlight.js"></script>
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/highlight.9.9.css">
<script type="text/javascript" src="https://repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script>
      <script type="text/javascript" src="https://repo.bfw.wiki/bfwrepo/js/axios-0.18.js"></script>
      
      <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue-typed-js.browser.js"></script>
      <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/vue-typed-js.css">
      
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/marked.umd.min.js"></script>
  <script >
 


  marked.setOptions({
    highlight: function(code) {
        return hljs.highlightAuto(code).value
    }
})
marked.setOptions({ sanitize: true })
      const data = [
	{ text: 'Hello! 我是AI小助手' },


];
let	counter = 1;

Vue.component('bubble', {
	props: ['bubbtext','ifnew',"oldtext"],
	templ.........完整代码请登录后点击上方下载按钮下载查看

网友评论0