Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
fix: fix chatgpt function
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazyokd committed Apr 12, 2023
1 parent f2ddf12 commit ef0d929
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Binary file added public/avatar/openai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions src/components/MessageArea/MessageBottomInputArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ export default {
}
this.buildAndPushMessage(this.user.id, this.toId, this.user.avatarPath,
this.user.username, contentType, this.content, url, size, this.messageKey, false);
const replay = await this.$api.generateResponse(this.content);
this.buildAndPushMessage(0, this.user.id, this.user.avatarPath, 'ChatGPT', 0,
replay, '', '', 'user503', false)
this.user.username, contentType, this.content, url, size, this.messageKey, this.messageKey != "ChatGPT");
if (this.messageKey === "ChatGPT") {
const replay = await this.$api.generateResponse(this.content);
this.buildAndPushMessage(0, this.user.id, 'avatar/openai.png', 'ChatGPT', contentType,
replay, '', '', this.messageKey, false);
}
},
buildAndPushMessage(fromId, toId, avatarPath, name, contentType, content, url, size, mk, isSendToBackend) {
let new_message = {
Expand Down
13 changes: 11 additions & 2 deletions src/components/ToolBar/ToolBarTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</el-button>
</el-tooltip>
<el-tooltip effect="dark" content="ChatGPT" placement="left">
<el-button class="tool-button"
<el-button class="tool-button" @click="openRightPanel"
><i class="el-icon-s-platform"></i
></el-button>
</el-tooltip>
Expand All @@ -22,7 +22,12 @@
export default {
name: "ToolBarTop",
data() {
return {};
return {
ChatGPT: {
id: 0,
name: "ChatGPT",
},
};
},
methods: {
loadContact() {
Expand All @@ -31,6 +36,10 @@ export default {
loadVerification() {
this.$bus.$emit("loadVerification");
},
openRightPanel() {
this.$store.state.toId = "ChatGPT";
this.$bus.$emit("openRightPanel", true, this.ChatGPT, true);
},
},
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/config/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*/

export const OPENAI_API_KEY =
"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";
"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";
export const OPENAI_MAKING_REQUEST =
"https://api.openai.com/v1/chat/completions";
3 changes: 2 additions & 1 deletion src/pages/ChattingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ export default {
};
},
methods: {
openRightPanel(isChatPanel = true, chatObject) {
openRightPanel(isChatPanel = true, chatObject, isChatGPT = false) {
this.isChatPanel = isChatPanel;
this.chatObject = chatObject;
this.$store.state.isChatGPT = isChatGPT;
this.$refs.app.style.width = 900 + "px";
this.$bus.$emit("scrollToBottom");
},
Expand Down
7 changes: 5 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import actions from "@/store/actions"
import mutations from "@/store/mutations";

const state = {
messages: {},
messages: {
"ChatGPT": [],
},
friends: [],
createGroups: [],
joinGroups: [],
Expand All @@ -19,11 +21,12 @@ const state = {
socket: socket,
toId: -1,
isGroup: false,
isChatGPT: false,
};

const getters = {
messageKey(state) {
return (state.isGroup ? "group" : "user") + state.toId;
return state.isChatGPT ? "ChatGPT" : ((state.isGroup ? "group" : "user") + state.toId);
},
getApplications: (state) => (isGroup, isRequest) => {
if (isGroup) {
Expand Down

0 comments on commit ef0d929

Please sign in to comment.