This commit is contained in:
sunxpx 2023-04-21 18:45:36 +08:00
parent fe7fc59d0b
commit 4b470b0497
2 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import { isMobileScreen, trimTopic } from "../utils";
import Locale from "../locales"; import Locale from "../locales";
import { showToast } from "../components/ui-lib"; import { showToast } from "../components/ui-lib";
import { url } from "inspector";
export type Message = ChatCompletionResponseMessage & { export type Message = ChatCompletionResponseMessage & {
date: string; date: string;
@ -378,6 +379,18 @@ export const useChatStore = create<ChatStore>()(
}, },
async onUserInput(content) { async onUserInput(content) {
// Shopper
if (content.startsWith("page:")) {
const url = content.replace("page:", "");
const response = await fetch("http://localhost:5000/page", {
method: "post",
body: JSON.stringify({ url: url }),
headers: { "Content-Type": "application/json" },
});
const data = await response.json();
const prompt = data["result"];
content = prompt;
}
const userMessage: Message = createMessage({ const userMessage: Message = createMessage({
role: "user", role: "user",
content, content,

View File

@ -150,6 +150,13 @@ export const usePromptStore = create<PromptStore>()(
}, },
); );
// shopper
builtinPrompts[0].push({
id: Math.random(),
title: "Shopper",
content: "page:https://item.jd.com/6039832.html",
} as Prompt);
const userPrompts = const userPrompts =
usePromptStore.getState().getUserPrompts() ?? []; usePromptStore.getState().getUserPrompts() ?? [];