From 6d321caad1b9ead33377cc96a54510715ea725de Mon Sep 17 00:00:00 2001
From: Dogtiti <499960698@qq.com>
Date: Wed, 19 Apr 2023 23:21:34 +0800
Subject: [PATCH 5/6] fix: types error
---
public/locales/en/common.json | 5 +++--
public/locales/zh/common.json | 4 +++-
src/components/ChatWindow.tsx | 4 ++--
src/pages/agent/index.tsx | 24 +++++++++++++++++++-----
4 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 34acde9a..b458bd9c 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -23,6 +23,7 @@
"current-tasks": "Current tasks",
"coming-soon": " Coming Soon!",
"back": "Back",
- "image":"Image"
-
+ "image": "Image",
+ "delete": "Delete",
+ "share": "Share"
}
diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json
index d49b2aa7..7400ab2c 100644
--- a/public/locales/zh/common.json
+++ b/public/locales/zh/common.json
@@ -23,5 +23,7 @@
"current-tasks": "当前任务",
"coming-soon": "即将到来!",
"back": "返回",
- "image":"图片"
+ "image": "图片",
+ "delete": "删除",
+ "share": "分享"
}
diff --git a/src/components/ChatWindow.tsx b/src/components/ChatWindow.tsx
index f1037faa..42b94461 100644
--- a/src/components/ChatWindow.tsx
+++ b/src/components/ChatWindow.tsx
@@ -33,7 +33,7 @@ interface ChatWindowProps extends HeaderProps {
showDonation: boolean;
fullscreen?: boolean;
scrollToBottom?: boolean;
- showWeChatPay: () => void;
+ showWeChatPay?: () => void;
}
const messageListId = "chat-window-message-list";
@@ -282,7 +282,7 @@ const ChatMessage = ({ message }: { message: Message }) => {
);
};
-const DonationMessage = ({ showWeChatPay }: { showWeChatPay: () => void }) => {
+const DonationMessage = ({ showWeChatPay }: { showWeChatPay?: () => void }) => {
const { t } = useTranslation(["chat", "common"]);
return (
diff --git a/src/pages/agent/index.tsx b/src/pages/agent/index.tsx
index 91a39bf0..86fefa06 100644
--- a/src/pages/agent/index.tsx
+++ b/src/pages/agent/index.tsx
@@ -1,4 +1,4 @@
-import { type NextPage } from "next";
+import { type NextPage, type GetStaticProps } from "next";
import DefaultLayout from "../../layout/default";
import Button from "../../components/Button";
@@ -10,10 +10,13 @@ import type { Message } from "../../types/agentTypes";
import Toast from "../../components/toast";
import { FaTrash, FaShare, FaBackspace } from "react-icons/fa";
import { env } from "../../env/client.mjs";
+import { useTranslation } from "next-i18next";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
const AgentPage: NextPage = () => {
const [showCopied, setShowCopied] = useState(false);
const router = useRouter();
+ const { t } = useTranslation();
const agentId = typeof router.query.id === "string" ? router.query.id : "";
@@ -55,7 +58,7 @@ const AgentPage: NextPage = () => {
}}
enabledClassName={"bg-green-600 hover:bg-green-400"}
>
- Share
+ {t("share")}
}
@@ -64,15 +67,15 @@ const AgentPage: NextPage = () => {
}}
enabledClassName={"bg-red-600 hover:bg-red-400"}
>
- Delete
+ {t("delete")}
} onClick={() => void router.push("/")}>
- Back
+ {t("back")}
@@ -80,3 +83,14 @@ const AgentPage: NextPage = () => {
};
export default AgentPage;
+
+export const getStaticProps: GetStaticProps = async ({ locale }) => ({
+ props: {
+ ...(await serverSideTranslations(locale ?? "zh", [
+ "common",
+ "help",
+ "settings",
+ "chat",
+ ])),
+ },
+});
From a9955db3bfc74c55498bd547f6e7771073e966e0 Mon Sep 17 00:00:00 2001
From: Dogtiti <499960698@qq.com>
Date: Wed, 19 Apr 2023 23:54:13 +0800
Subject: [PATCH 6/6] chore: remove some useless file
---
package-lock.json | 29 +++++++++++++----------------
package.json | 6 ++++--
src/pages/api/chain.ts | 20 --------------------
src/server/api/routers/chain.ts | 16 ----------------
4 files changed, 17 insertions(+), 54 deletions(-)
delete mode 100644 src/pages/api/chain.ts
delete mode 100644 src/server/api/routers/chain.ts
diff --git a/package-lock.json b/package-lock.json
index 1fdfca87..5557021d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -28,6 +28,8 @@
"html-to-image": "^1.11.11",
"i18next": "^22.4.14",
"langchain": "^0.0.53",
+ "micro": "^10.0.1",
+ "micro-cors": "^0.1.1",
"next": "13.1.6",
"next-auth": "^4.19.0",
"next-i18next": "^13.2.2",
@@ -4090,7 +4092,6 @@
"version": "3.1.0",
"resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==",
- "dev": true,
"engines": {
"node": ">= 0.8"
}
@@ -4477,7 +4478,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
- "dev": true,
"engines": {
"node": ">= 0.6"
}
@@ -4890,7 +4890,6 @@
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/depd/-/depd-1.1.2.tgz",
"integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==",
- "dev": true,
"engines": {
"node": ">= 0.6"
}
@@ -6559,7 +6558,6 @@
"version": "1.7.3",
"resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-1.7.3.tgz",
"integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==",
- "dev": true,
"dependencies": {
"depd": "~1.1.2",
"inherits": "2.0.4",
@@ -9389,7 +9387,6 @@
"version": "10.0.1",
"resolved": "https://registry.npmmirror.com/micro/-/micro-10.0.1.tgz",
"integrity": "sha512-9uwZSsUrqf6+4FLLpiPj5TRWQv5w5uJrJwsx1LR/TjqvQmKC1XnGQ9OHrFwR3cbZ46YqPqxO/XJCOpWnqMPw2Q==",
- "dev": true,
"dependencies": {
"arg": "4.1.0",
"content-type": "1.0.4",
@@ -9402,11 +9399,18 @@
"node": ">= 16.0.0"
}
},
+ "node_modules/micro-cors": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmmirror.com/micro-cors/-/micro-cors-0.1.1.tgz",
+ "integrity": "sha512-6WqIahA5sbQR1Gjexp1VuWGFDKbZZleJb/gy1khNGk18a6iN1FdTcr3Q8twaxkV5H94RjxIBjirYbWCehpMBFw==",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/micro/node_modules/arg": {
"version": "4.1.0",
"resolved": "https://registry.npmmirror.com/arg/-/arg-4.1.0.tgz",
- "integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==",
- "dev": true
+ "integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg=="
},
"node_modules/micromark": {
"version": "3.1.0",
@@ -11232,7 +11236,6 @@
"version": "2.4.1",
"resolved": "https://registry.npmmirror.com/raw-body/-/raw-body-2.4.1.tgz",
"integrity": "sha512-9WmIKF6mkvA0SLmA2Knm9+qj89e+j1zqgyn8aXGd7+nAduPoqgI9lO57SAZNn/Byzo5P7JhXTyg9PzaJbH73bA==",
- "dev": true,
"dependencies": {
"bytes": "3.1.0",
"http-errors": "1.7.3",
@@ -11247,7 +11250,6 @@
"version": "0.4.24",
"resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
- "dev": true,
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
@@ -11846,8 +11848,7 @@
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
- "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
- "dev": true
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/saxes": {
"version": "6.0.0",
@@ -11887,8 +11888,7 @@
"node_modules/setprototypeof": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.1.1.tgz",
- "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==",
- "dev": true
+ "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"node_modules/shebang-command": {
"version": "2.0.0",
@@ -12094,7 +12094,6 @@
"version": "1.5.0",
"resolved": "https://registry.npmmirror.com/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==",
- "dev": true,
"engines": {
"node": ">= 0.6"
}
@@ -12651,7 +12650,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==",
- "dev": true,
"engines": {
"node": ">=0.6"
}
@@ -12961,7 +12959,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
- "dev": true,
"engines": {
"node": ">= 0.8"
}
diff --git a/package.json b/package.json
index 7b244fe1..9abf653e 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,8 @@
"html-to-image": "^1.11.11",
"i18next": "^22.4.14",
"langchain": "^0.0.53",
+ "micro": "^10.0.1",
+ "micro-cors": "^0.1.1",
"next": "13.1.6",
"next-auth": "^4.19.0",
"next-i18next": "^13.2.2",
@@ -53,10 +55,10 @@
"@commitlint/config-conventional": "^17.6.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
- "@types/node": "^18.11.18",
- "@types/prettier": "^2.7.2",
"@types/micro": "^10.0.0",
"@types/micro-cors": "^0.1.2",
+ "@types/node": "^18.11.18",
+ "@types/prettier": "^2.7.2",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.47.1",
diff --git a/src/pages/api/chain.ts b/src/pages/api/chain.ts
deleted file mode 100644
index de4f6101..00000000
--- a/src/pages/api/chain.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { NextRequest } from "next/server";
-import { NextResponse } from "next/server";
-import type { RequestBody } from "../../utils/interfaces";
-import { startAgent } from "../../services/agent-service";
-
-export const config = {
- runtime: "edge",
-};
-
-const handler = async (request: NextRequest) => {
- try {
- const { modelSettings, goal } = (await request.json()) as RequestBody;
- const newTasks = await startAgent(modelSettings, goal);
- return NextResponse.json({ newTasks });
- } catch (e) {}
-
- return NextResponse.error();
-};
-
-export default handler;
diff --git a/src/server/api/routers/chain.ts b/src/server/api/routers/chain.ts
deleted file mode 100644
index 5a17078d..00000000
--- a/src/server/api/routers/chain.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { z } from "zod";
-
-import { createTRPCRouter, publicProcedure } from "../trpc";
-import { startGoalAgent } from "../../../utils/chain";
-
-export const chainRouter = createTRPCRouter({
- startAgent: publicProcedure
- .input(z.object({ prompt: z.string() }))
- .mutation(async ({ input }) => {
- // const completion = (await startGoalAgent(input.prompt)) as {
- // text: string;
- // };
- //
- // return { tasks: JSON.parse(completion.text) as string[] };
- }),
-});