remove chat debug log

This commit is contained in:
RockYang 2024-07-28 18:55:17 +08:00
parent 088a614160
commit 6a9de72c78
4 changed files with 16 additions and 21 deletions

View File

@ -65,7 +65,6 @@ func (h *ChatHandler) sendOpenAiMessage(
if !strings.Contains(line, "data:") || len(line) < 30 { if !strings.Contains(line, "data:") || len(line) < 30 {
continue continue
} }
logger.Info(line)
var responseBody = types.ApiResponse{} var responseBody = types.ApiResponse{}
err = json.Unmarshal([]byte(line[6:]), &responseBody) err = json.Unmarshal([]byte(line[6:]), &responseBody)
if err != nil { // 数据解析出错 if err != nil { // 数据解析出错

View File

@ -23,7 +23,9 @@ CREATE TABLE `chatgpt_suno_jobs` (
`power` smallint NOT NULL DEFAULT '0' COMMENT '消耗算力', `power` smallint NOT NULL DEFAULT '0' COMMENT '消耗算力',
`play_times` int DEFAULT NULL COMMENT '播放次数', `play_times` int DEFAULT NULL COMMENT '播放次数',
`created_at` datetime NOT NULL `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='MidJourney 任务表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Suno 任务表';
ALTER TABLE `chatgpt_suno_jobs` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `chatgpt_suno_jobs` ADD PRIMARY KEY (`id`); ALTER TABLE `chatgpt_suno_jobs` ADD PRIMARY KEY (`id`);
ALTER TABLE `chatgpt_suno_jobs` ADD UNIQUE(`song_id`); ALTER TABLE `chatgpt_api_keys` DROP `platform`;
ALTER TABLE `chatgpt_chat_models` DROP `platform`;

View File

@ -94,7 +94,7 @@
</template> </template>
<script setup> <script setup>
import {nextTick, onMounted, onUnmounted, ref} from 'vue'; import {nextTick, onUnmounted, ref} from 'vue';
import {Markmap} from 'markmap-view'; import {Markmap} from 'markmap-view';
import {Transformer} from 'markmap-lib'; import {Transformer} from 'markmap-lib';
import {checkSession} from "@/action/session"; import {checkSession} from "@/action/session";
@ -209,7 +209,6 @@ window.onresize = () => {
} }
const socket = ref(null) const socket = ref(null)
const heartbeatHandle = ref(0)
const connect = (userId) => { const connect = (userId) => {
if (socket.value !== null) { if (socket.value !== null) {
socket.value.close() socket.value.close()
@ -224,24 +223,9 @@ const connect = (userId) => {
} }
} }
//
const sendHeartbeat = () => {
clearTimeout(heartbeatHandle.value)
new Promise((resolve, reject) => {
if (socket.value !== null) {
socket.value.send(JSON.stringify({type: "heartbeat", content: "ping"}))
}
resolve("success")
}).then(() => {
heartbeatHandle.value = setTimeout(() => sendHeartbeat(), 5000)
});
}
const _socket = new WebSocket(host + `/api/markMap/client?user_id=${userId}&model_id=${modelID.value}`); const _socket = new WebSocket(host + `/api/markMap/client?user_id=${userId}&model_id=${modelID.value}`);
_socket.addEventListener('open', () => { _socket.addEventListener('open', () => {
socket.value = _socket; socket.value = _socket;
//
sendHeartbeat()
}); });
_socket.addEventListener('message', event => { _socket.addEventListener('message', event => {

View File

@ -283,6 +283,7 @@ import {formatTime} from "@/utils/libs";
import Clipboard from "clipboard"; import Clipboard from "clipboard";
import BlackDialog from "@/components/ui/BlackDialog.vue"; import BlackDialog from "@/components/ui/BlackDialog.vue";
import Compressor from "compressorjs"; import Compressor from "compressorjs";
import {useSharedStore} from "@/store/sharedata";
const winHeight = ref(window.innerHeight - 50) const winHeight = ref(window.innerHeight - 50)
const custom = ref(false) const custom = ref(false)
@ -329,6 +330,8 @@ const btnText = ref("开始创作")
const refSong = ref(null) const refSong = ref(null)
const showDialog = ref(false) const showDialog = ref(false)
const editData = ref({title:"",cover:"",id:0}) const editData = ref({title:"",cover:"",id:0})
const isLogin = ref(false)
const store = useSharedStore();
const socket = ref(null) const socket = ref(null)
const userId = ref(0) const userId = ref(0)
@ -381,9 +384,10 @@ onMounted(() => {
checkSession().then(user => { checkSession().then(user => {
userId.value = user.id userId.value = user.id
fetchData(1) isLogin.value = true
connect() connect()
}) })
fetchData(1)
}) })
onUnmounted(() => { onUnmounted(() => {
@ -411,6 +415,8 @@ const fetchData = (_page) => {
noData.value = list.value.length === 0 noData.value = list.value.length === 0
}).catch(e => { }).catch(e => {
showMessageError("获取作品列表失败:"+e.message) showMessageError("获取作品列表失败:"+e.message)
loading.value = false
noData.value = true
}) })
} }
@ -436,6 +442,10 @@ const create = () => {
return showMessageError("续写开始时间不能超过原歌曲长度") return showMessageError("续写开始时间不能超过原歌曲长度")
} }
if (!isLogin.value) {
store.setShowLoginDialog(true)
return
}
httpPost("/api/suno/create", data.value).then(() => { httpPost("/api/suno/create", data.value).then(() => {
fetchData(1) fetchData(1)
showMessageOK("创建任务成功") showMessageOK("创建任务成功")