更改必应和chatgpt的图片模式web模板,临时处理切换模式后会话失效问题 (#163)

* 修复引用转发,默认bing模式并发

* 开启stream增加稳定性

* fix: remove queue element only in non-bing mode

* 使用chatgpt-api自带的超时逻辑,文字过多时启动切换到图片输出防止被吞

* Update chat.js

* 添加Bing专用的图片输出样式

* 添加chatgpt的新图片模式,临时处理切换api导致的对话异常

---------

Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
HalcyonAlcedo 2023-02-17 19:55:23 +08:00 committed by GitHub
parent 37f75a64fa
commit 4d53f378f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
183 changed files with 6684 additions and 113 deletions

View file

@ -328,26 +328,28 @@ export class chatgpt extends plugin {
// logger.info(response)
// markdown转为html
// todo部分数学公式可能还有问题
let converted = converter.makeHtml(response)
let converted = response //converter.makeHtml(response)
/** 最后回复消息 */
await e.runtime.render('chatgpt-plugin', 'content/index', { content: converted, prompt, senderName: e.sender.nickname })
await e.runtime.render('chatgpt-plugin', use != 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname })
} else {
if (response.length > 1000) {
// 文字过多时自动切换到图片模式输出
let converted = converter.makeHtml(response)
await e.runtime.render('chatgpt-plugin', 'content/index', { content: converted, prompt, quote: chatMessage.quote, senderName: e.sender.nickname })
} else
await this.reply(`${response}`, e.isGroup)
let quotemessage = []
if (chatMessage?.quote) {
let quotemessage = []
chatMessage.quote.forEach(function (item, index) {
if (item.trim() != '') {
quotemessage.push(`${item}\n`)
quotemessage.push(item)
}
})
if (quotemessage.length > 0)
}
if (response.length > 1000 ) {
// 文字过多时自动切换到图片模式输出
let converted = response
await e.runtime.render('chatgpt-plugin', use != 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, quote: quotemessage, senderName: e.sender.nickname })
} else {
await this.reply(`${response}`, e.isGroup)
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage))
}
}
}
if (use !== 'bing') {
@ -360,6 +362,10 @@ export class chatgpt extends plugin {
// 异常了也要腾地方todo 大概率后面的也会异常,要不要一口气全杀了)
await redis.lPop('CHATGPT:CHAT_QUEUE', 0)
}
if ( e === 'Error: {"detail":"Conversation not found"}') {
destroyConversations (e)
await this.reply(`当前对话异常,已经清除,请重试`, true, { recallMsg: e.isGroup ? 10 : 0 })
} else
await this.reply(`通信异常,请稍后重试:${e}`, true, { recallMsg: e.isGroup ? 10 : 0 })
}
}

View file

@ -0,0 +1,114 @@
<!doctype html>
<html class="no-js" lang="zxx">
<head>
<!--========= Required meta tags =========-->
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!--====== CSS Here ======-->
<link rel="stylesheet" href="{{pluResPath}}content/Bing/static/css/bootstrap.min.css">
<link rel="stylesheet" href="{{pluResPath}}content/Bing/static/css/font-awesome.min.css">
<link rel="stylesheet" href="{{pluResPath}}content/Bing/static/css/hljs.css">
<link rel="stylesheet" href="{{pluResPath}}content/Bing/static/css/style.css">
</head>
<body>
<header class="site-header">
<div class="container">
<div class="row">
<div class="col-lg-3 col-4 my-auto">
<a href="index.html" class="site-logo">
<img src="{{pluResPath}}content/Bing/static/picture/bing.png" alt="LOGO">
</a>
</div>
</div>
</div>
</header>
<section class="about-area pt-232">
<div class="container">
<div class="row justify-content-end">
<div class="col-xl-5 col-lg-5 text-right">
<div class="section-heading">
<h2>New Bing</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="hero-content">
<h4>{{senderName}}</h4>
</div>
<div class="about-content">
<h2>{{@ prompt}}</h2>
<span class="height-50"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="hero-content">
<h4>必应</h4>
</div>
<div class="about-content">
<p class="markdown">{{@ content}}</p>
<span class="height-50"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="hero-content">
<h4>引用</h4>
</div>
<div class="about-content">
{{each quote item}}
<p class="markdown">{{item}}</p>
{{/each}}
<span class="height-50"></span>
</div>
</div>
</div>
</div>
</section>
<!-- footer start -->
<footer class="site-footer mt-175">
<div class="container">
<div class="row">
<div class="col-md-12 my-auto text-right">
<div class="copyright-text">
<p>Response to {{senderName}} Created By Yunzai-Bot and ChatGPT-Plugin</a></p>
</div>
</div>
</div>
</div>
</footer>
<!-- footer end -->
<!--========= JS Here =========-->
<script src="{{pluResPath}}content/Bing/static/js/jquery-2.2.4.min.js"></script>
<script src="{{pluResPath}}content/Bing/static/js/highlight.min.js"></script>
<script src="{{pluResPath}}content/Bing/static/js/marked.min.js"></script>
<script src="{{pluResPath}}content/Bing/static/js/main.js"></script>
<script>
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false,
highlight: function (code,lang) {
return hljs.highlightAuto(code,[lang]).value;
}
});
let text = marked.parse($(".markdown").text());
$(".markdown").html(text);
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,12 @@
(function ($) {
'use strict';
/*------------- preloader js --------------*/
function loader() {
$(window).on('load', function () {
});
}
loader();
})(jQuery);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,103 @@
<!doctype html>
<html class="no-js" lang="zxx">
<head>
<!--========= Required meta tags =========-->
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!--====== CSS Here ======-->
<link rel="stylesheet" href="{{pluResPath}}content/ChatGPT/static/css/bootstrap.min.css">
<link rel="stylesheet" href="{{pluResPath}}content/ChatGPT/static/css/font-awesome.min.css">
<link rel="stylesheet" href="{{pluResPath}}content/ChatGPT/static/css/hljs.css">
<link rel="stylesheet" href="{{pluResPath}}content/ChatGPT/static/css/style.css">
</head>
<body>
<header class="site-header">
<div class="container">
<div class="row">
<div class="col-lg-3 col-4 my-auto">
<a href="index.html" class="site-logo">
<img src="{{pluResPath}}content/ChatGPT/static/picture/openai.png" alt="LOGO">
</a>
</div>
</div>
</div>
</header>
<section class="about-area pt-232">
<div class="container">
<div class="row justify-content-end">
<div class="col-xl-5 col-lg-5 text-right">
<div class="section-heading">
<h2>Open AI</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="hero-content">
<h4>{{senderName}}</h4>
</div>
<div class="about-content">
<h2>{{@ prompt}}</h2>
<span class="height-50"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="hero-content">
<h4>ChatGPT</h4>
</div>
<div class="about-content">
<p class="markdown">{{@ content}}</p>
<span class="height-50"></span>
</div>
</div>
</div>
</div>
</section>
<!-- footer start -->
<footer class="site-footer mt-175">
<div class="container">
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-9 my-auto text-right">
<div class="copyright-text">
<p>Response to {{senderName}} Created By Yunzai-Bot and ChatGPT-Plugin</a></p>
</div>
</div>
</div>
</div>
</footer>
<!-- footer end -->
<!--========= JS Here =========-->
<script src="{{pluResPath}}content/ChatGPT/static/js/jquery-2.2.4.min.js"></script>
<script src="{{pluResPath}}content/ChatGPT/static/js/highlight.min.js"></script>
<script src="{{pluResPath}}content/ChatGPT/static/js/marked.min.js"></script>
<script src="{{pluResPath}}content/ChatGPT/static/js/main.js"></script>
<script>
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false,
highlight: function (code,lang) {
return hljs.highlightAuto(code,[lang]).value;
}
});
let text = marked.parse($(".markdown").text());
$(".markdown").html(text);
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
.fa{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}@keyframes fa-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@font-face{font-family:"Font Awesome 5 Brands";font-style:normal;font-weight:normal;font-display:auto;src:url(../fonts/fa-brands-400.eot);src:url(../fonts/fa-brands-400.eot) format("embedded-opentype"),url(../fonts/fa-brands-400.woff2) format("woff2"),url(../fonts/fa-brands-400.woff) format("woff"),url(../fonts/fa-brands-400.ttf) format("truetype"),url(../fonts/fa-brands-400.svg#fontawesome) format("svg")}@font-face{font-family:"Font Awesome 5 Pro";font-style:normal;font-weight:300;font-display:auto;src:url(../fonts/fa-light-300.eot);src:url(../fonts/fa-light-300.eot) format("embedded-opentype"),url(../fonts/fa-light-300.woff2) format("woff2"),url(../fonts/fa-light-300.woff) format("woff"),url(../fonts/fa-light-300.ttf) format("truetype"),url(../fonts/fa-light-300.svg#fontawesome) format("svg")}@font-face{font-family:"Font Awesome 5 Pro";font-style:normal;font-weight:400;font-display:auto;src:url(../fonts/fa-regular-400.eot);src:url(../fonts/fa-regular-400.eot) format("embedded-opentype"),url(../fonts/fa-regular-400.woff2) format("woff2"),url(../fonts/fa-regular-400.woff) format("woff"),url(../fonts/fa-regular-400.ttf) format("truetype"),url(../fonts/fa-regular-400.svg#fontawesome) format("svg")}@font-face{font-family:"Font Awesome 5 Pro";font-style:normal;font-weight:900;font-display:auto;src:url(../fonts/fa-solid-900.eot);src:url(../fonts/fa-solid-900.eot) format("embedded-opentype"),url(../fonts/fa-solid-900.woff2) format("woff2"),url(../fonts/fa-solid-900.woff) format("woff"),url(../fonts/fa-solid-900.ttf) format("truetype"),url(../fonts/fa-solid-900.svg#fontawesome) format("svg")}.fa{font-family:"Font Awesome 5 Pro";font-weight:900}

View file

@ -0,0 +1,9 @@
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}

View file

@ -0,0 +1,429 @@
@charset "UTF-8";
/*-----------------------------------------------------------------------------------
Template Name: Aiden - Creative Portfolio HTML5 Template
Template URI: site.com
Description: Aiden - Creative Portfolio HTML5 Template
Author: Rs_Theme
Version: 1.0
-----------------------------------------------------------------------------------
CSS INDEX
===================
01. Theme default css
02. header css
03. Navigation css
04. hero css
05. about css
06. service css
07. work CSS
08. testimonial css
09. brand css
10. blog css
11. contact css
12. breadcrumb css
13. cta css
14. contact-page css
15. blog-page css
16. footer css
-----------------------------------------------------------------------------------*/
/* reset css start */
@import url("644b614f82934cd2a7833c108ceb941b.css");
@import url("a0020bf6401d4e99884e2be5f5402f24.css");
html {
scroll-behavior: smooth;
}
body {
font-family: "Josefin Sans", sans-serif;
font-size: 18px;
padding: 0;
margin: 0;
font-weight: 400;
position: relative;
line-height: 26px;
background: #f5feff;
}
img {
max-width: 100%;
height: auto;
}
ul, ol {
padding: 0;
margin: 0;
list-style: none;
}
button {
cursor: pointer;
}
*:focus {
outline: none;
}
button {
border: none;
-webkit-transition: 0.3s;
-o-transition: 0.3s;
transition: 0.3s;
}
button:focus {
outline: none;
}
a {
-webkit-transition: 0.3s;
-o-transition: 0.3s;
transition: 0.3s;
}
a:hover {
text-decoration: none;
color: #242B58;
}
table {
width: 100%;
}
p, li, span {
color: #242B58;
margin-bottom: 0;
}
/* reset css end */
/* global css start */
/* global css end */
.height-50 {
height: 40px;
display: block;
}
.pt-232 {
padding-top: 232px;
}
.section-heading {
position: relative;
}
.section-heading h2 {
font-size: 42px;
line-height: 51px;
display: inline-block;
position: relative;
padding-right: 15px;
color: rgb(255 115 0 / 25%);
text-transform: uppercase;
}
@media (max-width: 767px) {
.section-heading h2 {
font-size: 36px;
line-height: 45px;
}
}
@media only screen and (min-width: 576px) and (max-width: 767px) {
.section-heading h2 {
font-size: 42px;
line-height: 51px;
}
}
.section-heading h2::after {
width: 160px;
height: 100px;
right: 0px;
content: "";
position: absolute;
bottom: 0px;
background: #b8dee094;
z-index: -1;
}
/*--
- Margin & Padding
-----------------------------------------*/
/*-- Margin Top --*/
/*-- Margin Top --*/
.mt-175 {
margin-top: 175px;
}
/*-- Margin Bottom --*/
/*-- Margin Left --*/
/*-- Margin Right --*/
/*-- Padding Top --*/
/*-- Padding Bottom --*/
/*-- Padding Left --*/
/*-- Padding Right --*/
/* typography css start */
h1, h2, h3, h4, h5, h6 {
font-weight: 700;
color: #242B58;
margin: 0;
line-height: 1.4;
font-family: "Josefin Sans", sans-serif;
}
h2 {
font-size: 32px;
}
h3 {
font-size: 22px;
}
h4 {
font-size: 20px;
}
h5 {
font-size: 18px;
}
h6 {
font-size: 16px;
}
/* typography css end */
/*--
- Overlay
------------------------------------------*/
/*-- Overlay Color --*/
/*-- Overlay Opacity --*/
/* Heder css start*/
.site-header {
margin-top: 15px;
padding: 25px 0px;
position: absolute;
width: 100%;
z-index: 2;
}
/* Navigation css */
/* form css start */
label {
font-size: fsize("14px");
}
input:not([type=radio]),
textarea {
padding: 10px 20px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
background-color: transparent;
font-size: fsize("14px") !important;
}
input:not([type=radio])::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
color: #c9c9c9 !important;
opacity: 1;
}
input:not([type=radio])::-moz-placeholder,
textarea::-moz-placeholder {
color: #c9c9c9 !important;
opacity: 1;
}
input:not([type=radio]):-ms-input-placeholder,
textarea:-ms-input-placeholder {
color: #c9c9c9 !important;
opacity: 1;
}
input:not([type=radio]):-moz-placeholder,
textarea:-moz-placeholder {
color: #c9c9c9 !important;
opacity: 1;
}
select {
padding: 8px 10px;
cursor: pointer;
color: #242B58;
background-color: transparent;
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
-ms-border-radius: 0;
-o-border-radius: 0;
}
textarea {
min-height: 100px;
width: 100%;
}
input[type=radio],
input[type=range],
input[type=checkbox] {
height: auto !important;
padding: 0;
}
/* form css end */
/* hero area css*/
.hero-content {
position: relative;
margin-top: 30px;
margin-bottom: 25px;
}
.hero-content h4 {
position: relative;
font-size: 24px;
font-weight: 600;
color: #12152f;
padding-left: 65px;
line-height: 29px;
}
@media (max-width: 1199px) {
.hero-content h4 {
font-size: 18px;
line-height: 23px;
}
}
@media (max-width: 767px) {
.hero-content h4 {
font-size: 16px;
line-height: 21px;
}
}
.hero-content h4::after {
width: 50px;
height: 2px;
background: #5beeb1;
left: 0px;
top: 50%;
-webkit-transition: translateY(-50%);
-o-transition: translateY(-50%);
transition: translateY(-50%);
content: "";
position: absolute;
}
.hero-content h1 {
margin-top: 20px;
font-size: 82px;
line-height: 99px;
font-weight: 700;
color: #ffffff;
margin-bottom: 30px;
position: relative;
z-index: 2;
}
@media (max-width: 1650px) {
.hero-content h1 {
font-size: 70px;
line-height: 87px;
}
}
@media (max-width: 1199px) {
.hero-content h1 {
font-size: 45px;
line-height: 62px;
}
}
@media (max-width: 767px) {
.hero-content h1 {
font-size: 30px;
line-height: 47px;
}
}
@media only screen and (min-width: 576px) and (max-width: 767px) {
.hero-content h1 {
font-size: 45px;
line-height: 62px;
}
}
.hero-content h1 span {
font-weight: 300;
display: block;
color: #ffffff;
}
.hero-content p {
color: #B0B0B2;
line-height: 24px;
}
/* About css */
.about-area {
position: relative;
padding-top: 40px;
}
.about-content h6 {
color: #12152f;
font-size: 14px;
font-weight: 400;
line-height: 24px;
margin-bottom: 10px;
}
.about-content h2 {
color: #12152f;
font-size: 28px;
}
.about-content p {
color: #12152f;
line-height: 24px;
}
/* skill cass */
/* service css*/
/* work css */
/* testimonial css */
/* brand css */
/* blog css */
/* contact css */
/* breadcrumb css */
/* cta css */
/* contact page css */
/* blog page css */
/* single blog page css */
/* comment css */
/*Footer css*/
.site-footer {
border-top: 1px solid #00ff8c;
padding: 30px 0px;
}
@media (max-width: 767px) {
.copyright-text {
text-align: center;
margin-top: 20px;
}
}
.copyright-text p {
color: #17b874;
}

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more