(
+ i18n.language
+ );
+
+ const router = useRouter();
const agentUtils = useAgent();
@@ -90,7 +93,13 @@ const Home: NextPage = () => {
goalInput,
handleAddMessage,
() => setAgent(null),
- { customApiKey, customModelName, customTemperature, customMaxLoops },
+ {
+ customApiKey,
+ customModelName,
+ customTemperature,
+ customMaxLoops,
+ customLanguage,
+ },
session ?? undefined
);
setAgent(agent);
@@ -110,6 +119,15 @@ const Home: NextPage = () => {
agent?.stopAgent();
};
+ const handleLanguageChange = () => {
+ const { pathname, asPath, query, locale } = router;
+ const lng = locale === "en" ? "zh" : "en";
+ router.push({ pathname, query }, asPath, {
+ locale: lng,
+ });
+ setCustomLanguage(lng);
+ };
+
const proTitle = (
<>
AutoGPT Next WebPro
@@ -162,6 +180,7 @@ const Home: NextPage = () => {
showWeChat={() => setShowWeChatDialog(true)}
showQQ={() => setShowQQDialog(true)}
showKnowledgePlanet={() => setShowKnowlegePlanetDialog(true)}
+ handleLanguageChange={handleLanguageChange}
/>
export const startGoalPrompt = new PromptTemplate({
template:
- "You are an autonomous task creation AI called AgentGPT. You have the following objective `{goal}`. Create a list of zero to three tasks to be completed by your AI system such that your goal is more closely reached or completely reached. Return the response as an array of strings that can be used in JSON.parse()",
- inputVariables: ["goal"],
+ "You are an autonomous task creation AI called AgentGPT. You have the following objective `{goal}`. Create a list of zero to three tasks to be completed by your AI system such that your goal is more closely reached or completely reached. Use the `{customLanguage}` language and respond only with the Array which has the following syntax:`[1...3 tasks on the given language]`",
+ inputVariables: ["goal", "customLanguage"],
});
export const executeTaskPrompt = new PromptTemplate({
template:
- "You are an autonomous task execution AI called AgentGPT. You have the following objective `{goal}`. You have the following tasks `{task}`. Execute the task and return the response as a string.",
- inputVariables: ["goal", "task"],
+ "You are an autonomous task execution AI called AgentGPT. You have the following objective `{goal}`. You have the following tasks `{task}`.You have to use the `{customLanguage}` language. Execute the given task and respond only with a one-line text as solution for the given task on the given language.",
+ inputVariables: ["goal", "task", "customLanguage"],
});
export const createTasksPrompt = new PromptTemplate({
template:
- "You are an AI task creation agent. You have the following objective `{goal}`. You have the following incomplete tasks `{tasks}` and have just executed the following task `{lastTask}` and received the following result `{result}`. Based on this, create a new task to be completed by your AI system ONLY IF NEEDED such that your goal is more closely reached or completely reached. Return the response as an array of strings that can be used in JSON.parse() and NOTHING ELSE",
- inputVariables: ["goal", "tasks", "lastTask", "result"],
+ "You are an AI task creation agent and your objective is to `{goal}`. You have the following incomplete tasks `{tasks}` and have just executed the following task `{lastTask}` and received the following solution `{result}`. Based on this, create a new task to be completed by your AI system ONLY IF NEEDED such that your goal is more closely reached or completely reached. Use the `{customLanguage}` language to create the new task. Respond only with an Array of the new task or tasks which has the following syntax:`[the remaining and appropriate new task or tasks on the language you have to use]`",
+ inputVariables: ["goal", "tasks", "lastTask", "result", "customLanguage"],
});
diff --git a/src/utils/types.ts b/src/utils/types.ts
index c15c5296..6e7b5ae3 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -3,4 +3,5 @@ export type ModelSettings = {
customModelName: string;
customTemperature: number;
customMaxLoops: number;
+ customLanguage: string;
};