From 4b470b0497874eea0c07cc26a8f0b55999f8db29 Mon Sep 17 00:00:00 2001 From: sunxpx Date: Fri, 21 Apr 2023 18:45:36 +0800 Subject: [PATCH] dev --- app/store/app.ts | 13 +++++++++++++ app/store/prompt.ts | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/app/store/app.ts b/app/store/app.ts index 8a2908a8c..73f882807 100644 --- a/app/store/app.ts +++ b/app/store/app.ts @@ -11,6 +11,7 @@ import { isMobileScreen, trimTopic } from "../utils"; import Locale from "../locales"; import { showToast } from "../components/ui-lib"; +import { url } from "inspector"; export type Message = ChatCompletionResponseMessage & { date: string; @@ -378,6 +379,18 @@ export const useChatStore = create()( }, 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({ role: "user", content, diff --git a/app/store/prompt.ts b/app/store/prompt.ts index 8d754ff5d..b464bff4c 100644 --- a/app/store/prompt.ts +++ b/app/store/prompt.ts @@ -150,6 +150,13 @@ export const usePromptStore = create()( }, ); + // shopper + builtinPrompts[0].push({ + id: Math.random(), + title: "Shopper", + content: "page:https://item.jd.com/6039832.html", + } as Prompt); + const userPrompts = usePromptStore.getState().getUserPrompts() ?? [];