mirror of
https://gitee.com/blackfox/geekai.git
synced 2024-12-02 12:17:42 +08:00
feat: gpt-4-all model is ready
This commit is contained in:
parent
a140671aad
commit
59fa21779b
@ -435,7 +435,11 @@ func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, platf
|
|||||||
apiURL = strings.Replace(apiKey.ApiURL, "{model}", req.Model, 1)
|
apiURL = strings.Replace(apiKey.ApiURL, "{model}", req.Model, 1)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
apiURL = apiKey.ApiURL
|
if req.Model == "gpt-4-all" {
|
||||||
|
apiURL = "https://gpt.bemore.lol/v1/chat/completions"
|
||||||
|
} else {
|
||||||
|
apiURL = apiKey.ApiURL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 更新 API KEY 的最后使用时间
|
// 更新 API KEY 的最后使用时间
|
||||||
h.db.Model(apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
h.db.Model(apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
||||||
|
11
web/package-lock.json
generated
11
web/package-lock.json
generated
@ -19,6 +19,7 @@
|
|||||||
"json-bigint": "^1.0.0",
|
"json-bigint": "^1.0.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
|
"markdown-it-emoji": "^3.0.0",
|
||||||
"md-editor-v3": "^2.2.1",
|
"md-editor-v3": "^2.2.1",
|
||||||
"pinia": "^2.1.4",
|
"pinia": "^2.1.4",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
@ -7430,6 +7431,11 @@
|
|||||||
"markdown-it": "bin/markdown-it.js"
|
"markdown-it": "bin/markdown-it.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/markdown-it-emoji": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/markdown-it-emoji/-/markdown-it-emoji-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-+rUD93bXHubA4arpEZO3q80so0qgoFJEKRkRbjKX8RTdca89v2kfyF+xR3i2sQTwql9tpPZPOQN5B+PunspXRg=="
|
||||||
|
},
|
||||||
"node_modules/markdown-it/node_modules/argparse": {
|
"node_modules/markdown-it/node_modules/argparse": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||||
@ -17361,6 +17367,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"markdown-it-emoji": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/markdown-it-emoji/-/markdown-it-emoji-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-+rUD93bXHubA4arpEZO3q80so0qgoFJEKRkRbjKX8RTdca89v2kfyF+xR3i2sQTwql9tpPZPOQN5B+PunspXRg=="
|
||||||
|
},
|
||||||
"md-editor-v3": {
|
"md-editor-v3": {
|
||||||
"version": "2.11.3",
|
"version": "2.11.3",
|
||||||
"resolved": "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-2.11.3.tgz",
|
"resolved": "https://registry.npmjs.org/md-editor-v3/-/md-editor-v3-2.11.3.tgz",
|
||||||
|
@ -102,6 +102,10 @@ export default defineComponent({
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color #20a0ff
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
line-height 1.5
|
line-height 1.5
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,10 @@ export default defineComponent({
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
overflow auto;
|
overflow auto;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color #20a0ff
|
||||||
|
}
|
||||||
|
|
||||||
// control the image size in content
|
// control the image size in content
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@ -166,6 +170,7 @@ export default defineComponent({
|
|||||||
color #00e0e0
|
color #00e0e0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 设置表格边框
|
// 设置表格边框
|
||||||
|
|
||||||
table {
|
table {
|
||||||
@ -190,6 +195,17 @@ export default defineComponent({
|
|||||||
padding 10px
|
padding 10px
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 代码快
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
margin 0
|
||||||
|
background-color: #ebfffe;
|
||||||
|
padding: 0.8rem 1.5rem;
|
||||||
|
border-left: 0.5rem solid;
|
||||||
|
border-color: #026863;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,6 +511,9 @@ const removeChat = function (event, chat) {
|
|||||||
|
|
||||||
const md = require('markdown-it')({
|
const md = require('markdown-it')({
|
||||||
breaks: true,
|
breaks: true,
|
||||||
|
html: true,
|
||||||
|
linkify: true,
|
||||||
|
typographer: true,
|
||||||
highlight: function (str, lang) {
|
highlight: function (str, lang) {
|
||||||
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000)
|
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000)
|
||||||
// 显示复制代码按钮
|
// 显示复制代码按钮
|
||||||
@ -601,36 +604,6 @@ const connect = function (chat_id, role_id) {
|
|||||||
icon: _role['icon'],
|
icon: _role['icon'],
|
||||||
content: ""
|
content: ""
|
||||||
});
|
});
|
||||||
} else if (data.type === "mj") {
|
|
||||||
disableInput(true)
|
|
||||||
const content = data.content;
|
|
||||||
content.html = md.render(content.content)
|
|
||||||
let key = content.key
|
|
||||||
// fixed bug: 执行 Upscale 和 Variation 操作的时候覆盖之前的绘画
|
|
||||||
if (content.status === "Finished") {
|
|
||||||
key = randString(32)
|
|
||||||
enableInput()
|
|
||||||
}
|
|
||||||
// console.log(content)
|
|
||||||
// check if the message is in chatData
|
|
||||||
let flag = false
|
|
||||||
for (let i = 0; i < chatData.value.length; i++) {
|
|
||||||
if (chatData.value[i].id === content.key) {
|
|
||||||
flag = true
|
|
||||||
chatData.value[i].content = content
|
|
||||||
chatData.value[i].id = key
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (flag === false) {
|
|
||||||
chatData.value.push({
|
|
||||||
type: "mj",
|
|
||||||
id: key,
|
|
||||||
icon: "/images/avatar/mid_journey.png",
|
|
||||||
content: content
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (data.type === 'end') { // 消息接收完毕
|
} else if (data.type === 'end') { // 消息接收完毕
|
||||||
// 追加当前会话到会话列表
|
// 追加当前会话到会话列表
|
||||||
if (isNewChat && newChatItem.value !== null) {
|
if (isNewChat && newChatItem.value !== null) {
|
||||||
@ -659,7 +632,7 @@ const connect = function (chat_id, role_id) {
|
|||||||
lineBuffer.value += data.content;
|
lineBuffer.value += data.content;
|
||||||
const reply = chatData.value[chatData.value.length - 1]
|
const reply = chatData.value[chatData.value.length - 1]
|
||||||
reply['orgContent'] = lineBuffer.value;
|
reply['orgContent'] = lineBuffer.value;
|
||||||
reply['content'] = md.render(lineBuffer.value);
|
reply['content'] = md.render(processBlankQuote(lineBuffer.value));
|
||||||
}
|
}
|
||||||
// 将聊天框的滚动条滑动到最底部
|
// 将聊天框的滚动条滑动到最底部
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -800,15 +773,8 @@ const loadChatHistory = function (chatId) {
|
|||||||
}
|
}
|
||||||
showHello.value = false
|
showHello.value = false
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
if (data[i].type === "mj") {
|
|
||||||
data[i].content = JSON.parse(data[i].content)
|
|
||||||
data[i].content.html = md.render(data[i].content?.content)
|
|
||||||
chatData.value.push(data[i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
data[i].orgContent = data[i].content;
|
data[i].orgContent = data[i].content;
|
||||||
data[i].content = md.render(data[i].content);
|
data[i].content = md.render(processBlankQuote(data[i].content))
|
||||||
chatData.value.push(data[i]);
|
chatData.value.push(data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,6 +788,22 @@ const loadChatHistory = function (chatId) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const processBlankQuote = (content) => {
|
||||||
|
if (content.indexOf("\n") === -1) {
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
|
const texts = content.split("\n")
|
||||||
|
const lines = []
|
||||||
|
for (let txt of texts) {
|
||||||
|
lines.push(txt)
|
||||||
|
if (txt.startsWith(">")) {
|
||||||
|
lines.push("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
const stopGenerate = function () {
|
const stopGenerate = function () {
|
||||||
showStopGenerate.value = false;
|
showStopGenerate.value = false;
|
||||||
httpGet("/api/chat/stop?session_id=" + getSessionId()).then(() => {
|
httpGet("/api/chat/stop?session_id=" + getSessionId()).then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user