Skip to content

Commit

Permalink
fix: 🐞 修复chat部分错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocyss committed Jul 28, 2024
1 parent b0c3be2 commit 27e99cb
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 101 deletions.
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ ElMessage("BoosHelper挂载成功!");
const { storeInit } = useStore();
const confBox = ref(false);
const confs = {
store: { name: "存储配置", component: storeVue },
user: { name: "账号配置", component: userVue },
log: { name: "日志配置", component: logVue },
store: { name: "存储配置", component: storeVue, disabled: false },
user: { name: "账号配置", component: userVue, disabled: true },
log: { name: "日志配置", component: logVue, disabled: false },
};
const confKey = ref<keyof typeof confs>("store");
const dark = ref(GM_getValue("theme-dark", false));
Expand Down Expand Up @@ -86,6 +86,7 @@ onMounted(async () => {
confKey = k;
confBox = true;
"
:disabled="v.disabled"
>
{{ v.name }}
</el-dropdown-item>
Expand Down
8 changes: 5 additions & 3 deletions src/components/conf/user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { FormData, Statistics } from "@/types/formData";
import { useStatistics } from "@/hooks/useStatistics";
import { computed, reactive, ref, toRaw } from "vue";
import { useStore } from "@/hooks/useStore";
import { useStore, useUserId } from "@/hooks/useStore";
import { logger } from "@/utils/logger";
const confUserKey = "conf-user";
const { formData } = useConfFormData();
Expand Down Expand Up @@ -46,6 +46,7 @@ const handleCurrentChange = (val: Data | undefined) => {
};
async function create(flag = true) {
logger.debug("开始创建账户");
try {
const list = await new Promise<any[]>((resolve, reject) => {
GM_cookie.list({}, (cookies, error) => {
Expand All @@ -56,10 +57,11 @@ async function create(flag = true) {
}
});
});
logger.debug(list);
let uid: string | number | undefined = userInfo.value?.userId;
let uid: number | string = useUserId();
if (!uid) {
return;
throw new Error("找不到uid");
}
uid = String(uid);
data[uid] = {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useApplying/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ElMessage } from "element-plus";
import { unsafeWindow } from "$";

const { userInfo } = useStore();

export function requestCard(params: { securityId: string; lid: string }) {
return axios.get<{
code: number;
Expand Down
22 changes: 7 additions & 15 deletions src/hooks/useApplying/handles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { useConfFormData } from "../useConfForm";
import { ElMessage } from "element-plus";
import { Message } from "../useWebSocket";
import { miTem } from "mitem";
import { llmsIcons, useModel } from "../useModel";
import { useModel } from "../useModel";
import { requestBossData } from "./api";
import {
RepeatError,
JobTitleError,
CompanyNameError,
SalaryError,
Expand All @@ -20,20 +19,19 @@ import {
FriendStatusError,
} from "@/types/deliverError";

import { useStore } from "../useStore";
import { unsafeWindow } from "$";
import { useUserId } from "../useStore";

import { logData } from "../useLog";
import { logger } from "@/utils/logger";

import { parseGptJson } from "@/utils/parse";
import { rangeMatch } from "./utils";
import { useChat } from "../useChat";
import { ChatMessage } from "../useChat/type";

import { getCurDay, getCurTime } from "@/utils";
const { chatInputInit, chatMessages } = useChat();
const { modelData, getGpt } = useModel();
const { formData } = useConfFormData();
const { todayData } = useStatistics();
const { userInfo } = useStore();

export const communicated: handleCFn = (h) => {
// h.push(async ({ data }) => {
Expand Down Expand Up @@ -224,10 +222,7 @@ export const activityFilter: handleCFn = (h) =>

export const customGreeting: handleCFn = (h) => {
const template = miTem.compile(formData.customGreeting.value);
const uid =
userInfo.value?.userId ||
unsafeWindow?._PAGE?.uid ||
unsafeWindow?._PAGE?.userId;
const uid = useUserId();
if (!uid) {
ElMessage.error("没有获取到uid,请刷新重试");
throw new GreetError("没有获取到uid");
Expand Down Expand Up @@ -272,10 +267,7 @@ export const aiGreeting: handleCFn = (h) => {
return;
}
const gpt = getGpt(model, formData.aiGreeting.prompt);
const uid =
userInfo.value?.userId ||
unsafeWindow?._PAGE?.uid ||
unsafeWindow?._PAGE?.userId;
const uid = useUserId();
if (!uid) {
ElMessage.error("没有获取到uid,请刷新重试");
throw new GreetError("没有获取到uid");
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useModel/llms/aliyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const info: llmInfo<aliyunLLMConf> = {
mode: {
mode: "aliyun",
label: "通义千问",
disabled: true,
icon: `<svg t="1713627186974" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15358" width="200" height="200"><path d="M918.60992 591.872l-104.67328-183.1936 44.8512-85.99552a23.92064 23.92064 0 0 0 5.24288-29.9008L806.44096 188.8256a24.6784 24.6784 0 0 0-20.1728-11.22304H572.416l-47.86176-83.74272a22.44608 22.44608 0 0 0-17.2032-11.96032h-112.88576a23.92064 23.92064 0 0 0-20.19328 11.96032v4.5056l-106.9056 183.17312H164.88448a23.94112 23.94112 0 0 0-20.93056 11.22304l-59.06432 104.6528a26.9312 26.9312 0 0 0 0 23.9616l106.16832 184.66816-47.84128 83.7632a26.9312 26.9312 0 0 0 0 23.90016l54.5792 95.72352a24.6784 24.6784 0 0 0 20.93056 11.96032h213.85216l51.58912 89.7024a24.6784 24.6784 0 0 0 18.69824 11.9808h121.11872a23.92064 23.92064 0 0 0 20.19328-11.96032l105.43104-184.68864h94.208a26.19392 26.19392 0 0 0 20.19328-12.6976l54.5792-96.4608a23.18336 23.18336 0 0 0 0-25.43616z m-132.34176 11.96032l-54.5792-100.9664-224.31744 395.55072-61.31712-100.92544H221.73696l53.84192-97.95584h114.40128L165.66272 305.50016h117.39136l111.4112-198.90176 56.07424 97.95584-57.56928 100.92544h448.6144L784.7936 405.7088l112.90624 198.12352h-111.4112z" fill="#605BEC" p-id="15359"></path><path d="M502.12864 641.9456l139.83744-224.29696H361.55392l140.57472 224.29696z" fill="#605BEC" p-id="15360"></path></svg>`,
desc: `阿里巴巴旗下的大模型,开通就送价值千元的tokens,可用去尝试尝试 <a href="https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key" target="_blank">开通文档</a>`,
desc: `阿里巴巴旗下的大模型,开通就送价值千元的tokens,可用去尝试尝试 <a href="https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key" target="_blank">开通文档</a><br/>效果一般般,推荐还是gpt吧,未知的问题也多,如没开stream没返回值等等~`,
},
model: {
required: true,
Expand Down Expand Up @@ -64,6 +65,7 @@ const info: llmInfo<aliyunLLMConf> = {
},
stream: {
type: "switch",
value: true,
},
temperature: {
type: "slider",
Expand Down Expand Up @@ -230,7 +232,6 @@ class gpt extends llm<aliyunLLMConf> {
responseType: this.conf.advanced.stream ? "stream" : "json",
onStream,
});

return res;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useModel/llms/baidu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const info: llmInfo<baiduLLMConf> = {
mode: {
mode: "baidu",
label: "文心一言",
desc: `为什么排最后自己知道,臭名昭著无需介绍 <a href="https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application" target="_blank">开通应用</a> <a href="https://console.bce.baidu.com/tools/?u=qfdc#/api?product=QIANFAN&project=%E5%8D%83%E5%B8%86%E5%A4%A7%E6%A8%A1%E5%9E%8B%E5%B9%B3%E5%8F%B0&parent=%E9%89%B4%E6%9D%83%E8%AE%A4%E8%AF%81%E6%9C%BA%E5%88%B6&api=oauth/2.0/token&method=post" target="_blank">获取token</a>`,
disabled: true,
desc: `为什么排最后自己知道,臭名昭著无需介绍, 不推荐使用,问题较多 <a href="https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application" target="_blank">开通应用</a> <a href="https://console.bce.baidu.com/tools/?u=qfdc#/api?product=QIANFAN&project=%E5%8D%83%E5%B8%86%E5%A4%A7%E6%A8%A1%E5%9E%8B%E5%B9%B3%E5%8F%B0&parent=%E9%89%B4%E6%9D%83%E8%AE%A4%E8%AF%81%E6%9C%BA%E5%88%B6&api=oauth/2.0/token&method=post" target="_blank">获取token</a>`,
icon: `<svg t="1713626816913" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7655" width="200" height="200"><path d="M96.20121136 636.3124965c-0.1472897-113.41305959-0.29457937-226.8261192-0.29457937-340.23917879 0-14.87625845 7.65906378-26.51214381 20.4732666-34.02391789 45.51251353-26.65943349 91.02502705-53.31886698 136.83211997-79.53643141 71.1409192-40.94653321 142.42912809-81.59848704 213.71733698-122.39773055 7.36448439-4.12411126 14.58167909-8.3955122 21.50429441-13.2560719 19.44223878-13.40336159 39.03176725-16.05457598 60.09419263-3.53495252 27.39588193 16.34915535 54.93905355 32.25644163 82.48222516 48.16372793 88.0792333 50.96223197 176.30575629 101.77717426 264.38498958 152.59211653 9.86840908 5.74429781 19.88410785 11.19401627 29.60522725 17.0856038 14.13981003 8.54280189 21.50429441 21.06242535 21.50429443 37.70616007 0 147.73155685 0.29457937 295.46311371-0.1472897 443.19467057 0 15.46541722-7.2171947 28.57419943-21.7988738 36.96971163-34.7603663 20.17868721-70.55176044 38.88447758-104.57567833 59.94690293-48.90017634 30.19438599-100.00969801 56.11737105-148.76258466 86.60633642-29.01606849 18.11663161-59.50503387 34.02391789-89.11026112 50.96223197-13.10878221 7.51177407-26.07027474 15.17083783-39.03176726 22.9771913-13.84523065 8.3955122-27.83775099 8.83738127-41.97756102 0.73644843-56.41195043-32.55102101-112.82390085-65.10204201-169.38314098-97.653063-61.86166887-35.64410444-123.72333775-71.1409192-185.4377169-106.78502365-11.19401627-6.48074626-22.24074286-12.81420285-32.99289009-19.88410785-11.48859565-7.65906378-17.08560379-19.14765941-17.08560378-32.69831069-0.1472897-34.7603663 0.1472897-69.52073264 0.29457938-104.28109895 1.62018657-0.58915875 1.62018657-1.62018657-0.29457938-2.65121438z m356.58833414-225.500512c2.20934532-1.76747625 4.41869063-3.68224221 6.77532565-5.15513907 68.93157389-39.62092601 137.86314777-79.24185204 206.94201135-118.86277807 2.79850407-1.62018657 6.48074626-1.62018657 6.62803594-6.18616688 0.1472897-4.8605597-4.12411126-4.71327001-6.77532564-6.18616688-40.65195383-23.56635005-81.59848704-46.83812071-122.10315117-70.84633984-16.79102442-10.01569877-32.84560039-8.54280189-48.45830728 0.58915876-45.9543826 26.51214381-91.46689612 53.61344636-137.27398903 80.42016953-31.96186226 18.70579035-64.21830387 37.11700133-96.32745581 55.67550198-18.41121097 10.60485751-27.54317163 25.33382629-27.24859225 47.72185885 0.88373813 89.55213018 0.58915875 179.10426036 0.14728969 268.65639053-0.1472897 20.17868721 9.27925033 33.58204881 25.33382629 43.15587853 31.3727035 18.70579035 63.18727606 37.11700133 95.14913832 54.93905355 10.89943689 6.03887719 21.06242535 13.99252034 35.79139414 18.41121096V505.51925374c6.48074626 19.58952848 18.55850066 34.02391789 36.67513226 44.6287754 27.83775099 16.20186565 63.18727606 12.51962347 86.31175705-10.45756784 26.95401286-26.65943349 28.72148912-62.89269668 12.81420282-90.14128893-16.34915535-28.42690974-43.59774757-37.55887038-74.38129233-38.73718787z m82.48222517 429.64401928c14.28709972-3.82953187 25.92298506-13.99252034 38.88447758-21.35700473 40.94653321-23.27177067 81.30390766-47.72185885 122.54502023-70.55176046 26.95401286-15.02354815 52.87699792-31.66728287 80.71474891-45.21793415 16.79102442-8.10093283 29.60522723-22.53532223 29.60522726-43.4504579 0.1472897-92.939793 0.29457937-185.73229631 0.14728969-278.6720893 0-11.19401627-5.15513907-13.99252034-13.84523067-7.06990501-26.51214381 20.76784598-57.29568854 34.46578693-86.16446735 51.25681135-54.49718448 31.81457257-109.14165865 63.33456576-163.78613282 95.00184862-8.54280189 4.8605597-11.78317502 10.45756784-11.63588535 20.47326662 0.29457937 96.18016613 0.1472897 192.50762194 0.1472897 288.68778806-0.29457937 3.5349525-1.47289687 7.65906378 3.38766282 10.8994369z" fill="#066AF3" p-id="7656"></path><path d="M96.20121136 636.3124965c1.91476594 1.03102783 1.91476594 2.06205563 0 3.09308345v-3.09308345z" fill="#4372E0" p-id="7657"></path><path d="M391.3697457 505.37196405c-5.44971845-44.33419602 13.84523065-74.08671296 61.4197998-94.55997955 30.93083443 1.17831749 58.03213699 10.31027814 74.38129233 38.5898982 15.75999659 27.39588193 14.13981003 63.48185543-12.81420282 90.14128893-23.27177067 22.97719129-58.47400606 26.65943349-86.31175705 10.45756783-18.11663161-10.60485751-30.34167568-25.03924691-36.67513226-44.62877541z" fill="#002A9A" p-id="7658"></path></svg>`,
},
url: {
Expand Down Expand Up @@ -171,7 +172,6 @@ class gpt extends llm<baiduLLMConf> {
responseType: this.conf.advanced.stream ? "stream" : "json",
onStream,
});

return res;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useModel/llms/moonshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type moonshotLLMConf = llmConf<
stream?: boolean;
temperature?: number;
top_p?: number;
max_tokens?: number;
presence_penalty?: number;
frequency_penalty?: number;
};
Expand All @@ -27,7 +26,7 @@ const info: llmInfo<moonshotLLMConf> = {
mode: {
mode: "moonshot",
label: "Kimi",
disabled: true,
// disabled: true,
icon: `<svg t="1713627008962" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13473" width="200" height="200"><path d="M1024 0m0 186.197333l0 651.605334q0 186.197333-186.197333 186.197333l-651.605334 0q-186.197333 0-186.197333-186.197333l0-651.605334q0-186.197333 186.197333-186.197333l651.605334 0q186.197333 0 186.197333 186.197333Z" fill="#000000" p-id="13474"></path><path d="M580.181333 459.946667c57.173333 1.322667 104.192 52.352 104.192 115.2v232.533333a2.090667 2.090667 0 0 1-2.133333 2.133333h-99.925333a2.090667 2.090667 0 0 1-2.133334-2.133333l-1.706666-294.016c0-1.28-2.218667-1.493333-2.56-0.298667-13.397333 43.946667-52.736 56.32-99.84 56.32H304.384a2.090667 2.090667 0 0 0-2.090667 2.090667v235.946667a2.090667 2.090667 0 0 1-2.090666 2.090666H194.858667a2.090667 2.090667 0 0 1-2.048-2.133333V241.578667c0-1.152 0.896-2.048 2.048-2.048h105.386666c1.109333 0 2.048 0.896 2.048 2.048v216.32c0 1.152 0.938667 2.133333 2.090667 2.133333h135.253333a2.133333 2.133333 0 0 0 1.877334-1.28l96.896-218.026667a2.090667 2.090667 0 0 1 1.92-1.194666h116.778666c1.493333 0 2.517333 1.578667 1.877334 2.944l-66.261334 142.293333c-19.754667 36.224-34.304 61.866667-67.242666 72.789333-1.194667 0.426667-0.938667 2.432 0.298666 2.432h54.4z" fill="#FFFFFF" p-id="13475"></path><path d="M727.338667 227.968c-11.733333 9.856-19.413333 25.941333-19.413334 50.218667 0 22.741333 7.253333 40.405333 18.133334 50.986666-5.674667 9.386667-11.434667 15.957333-15.786667 19.498667-0.725333 0.554667-0.170667 2.218667 0.725333 2.133333l64.426667-4.693333c14.378667-1.066667 26.709333-6.485333 37.034667-15.744 12.373333-10.496 19.498667-28.544 19.498666-52.181333 0-24.277333-7.125333-40.362667-19.498666-50.218667-11.776-9.813333-26.112-14.762667-43.050667-14.762667-16.298667 0-30.293333 4.949333-42.069333 14.762667z" fill="#007AFF" p-id="13476"></path></svg>`,
desc: `注册就送15,国产模型对中文支持应该好一些 <a href="https://platform.moonshot.cn/console/api-keys" target="_blank">开通文档</a>`,
},
Expand Down
Loading

0 comments on commit 27e99cb

Please sign in to comment.