From 72b5f19033a78a181e0e0378e571d993d1a632cb Mon Sep 17 00:00:00 2001 From: Onelevenvy Date: Tue, 24 Sep 2024 16:11:07 +0800 Subject: [PATCH 1/3] feat:add panel iconbutton display --- .../components/WorkFlow/FlowVisualizer.tsx | 6 +-- .../WorkFlow/nodes/Base/BaseNode.tsx | 1 - .../WorkFlow/nodes/Base/Properties.tsx | 43 +++++++++++++++---- .../WorkFlow/nodes/End/Properties.tsx | 18 +++++--- .../components/WorkFlow/nodes/LLM/LLMNode.tsx | 6 +-- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/web/src/components/WorkFlow/FlowVisualizer.tsx b/web/src/components/WorkFlow/FlowVisualizer.tsx index daf6e4ab..6b5e9201 100644 --- a/web/src/components/WorkFlow/FlowVisualizer.tsx +++ b/web/src/components/WorkFlow/FlowVisualizer.tsx @@ -88,9 +88,9 @@ const FlowVisualizer: React.FC = ({ const nodeType = node.type as NodeType; const PropertiesComponent = nodeConfig[nodeType]?.properties; - + const { icon: Icon, colorScheme } = nodeConfig[nodeType]; return ( - } colorScheme={colorScheme} nodeName={node.data.label} onNameChange={(newName: string) => onNodeDataChange(node.id, "label", newName) @@ -402,7 +402,7 @@ const FlowVisualizer: React.FC = ({ border={"1px solid #d1d5db"} onClick={() => setShowDebugPreview(true)} _hover={{ backgroundColor: "#eff4ff" }} - rightIcon={} + rightIcon={} size={"sm"} > Debug diff --git a/web/src/components/WorkFlow/nodes/Base/BaseNode.tsx b/web/src/components/WorkFlow/nodes/Base/BaseNode.tsx index 222717d8..b134b617 100644 --- a/web/src/components/WorkFlow/nodes/Base/BaseNode.tsx +++ b/web/src/components/WorkFlow/nodes/Base/BaseNode.tsx @@ -23,7 +23,6 @@ export const BaseNode: React.FC = ({ textAlign="center" position="relative" boxShadow="md" - > void; nameError: string | null; + icon: React.ReactElement; + colorScheme: string; } -const BaseProperties: React.FC = ({ children, nodeName, onNameChange, nameError }) => { +const BaseProperties: React.FC = ({ + children, + nodeName, + onNameChange, + nameError, + icon, + colorScheme, +}) => { return ( - Node Name: - onNameChange(e.target.value)} - /> + + + onNameChange(e.target.value)} + border={"1px solid white"} + size={"sm"} + fontWeight={"bold"} + w={"50%"} + /> + {nameError} {children} @@ -24,4 +51,4 @@ const BaseProperties: React.FC = ({ children, nodeName, onN ); }; -export default BaseProperties; \ No newline at end of file +export default BaseProperties; diff --git a/web/src/components/WorkFlow/nodes/End/Properties.tsx b/web/src/components/WorkFlow/nodes/End/Properties.tsx index 465cf76b..5c7d123c 100644 --- a/web/src/components/WorkFlow/nodes/End/Properties.tsx +++ b/web/src/components/WorkFlow/nodes/End/Properties.tsx @@ -1,5 +1,11 @@ import React from "react"; -import { Text, Input, VStack, FormControl, FormErrorMessage } from "@chakra-ui/react"; +import { + Text, + Input, + VStack, + FormControl, + FormErrorMessage, +} from "@chakra-ui/react"; interface BasePropertiesProps { children: React.ReactNode; @@ -8,15 +14,13 @@ interface BasePropertiesProps { nameError: string | null; } -const BaseProperties: React.FC = ({ children, nodeName, onNameChange, nameError }) => { +const BaseProperties: React.FC = ({ + children, + nameError, +}) => { return ( - Node Name: - onNameChange(e.target.value)} - /> {nameError} {children} diff --git a/web/src/components/WorkFlow/nodes/LLM/LLMNode.tsx b/web/src/components/WorkFlow/nodes/LLM/LLMNode.tsx index 85b8f0f4..ef8da663 100644 --- a/web/src/components/WorkFlow/nodes/LLM/LLMNode.tsx +++ b/web/src/components/WorkFlow/nodes/LLM/LLMNode.tsx @@ -1,12 +1,12 @@ import React from "react"; import { Handle, Position, NodeProps } from "reactflow"; import { Box, VStack, Text } from "@chakra-ui/react"; -import { FaRobot } from "react-icons/fa"; import { BaseNode } from "../Base/BaseNode"; import ModelProviderIcon from "@/components/Icons/models"; - +import { nodeConfig } from "../nodeConfig"; +const { icon: Icon, colorScheme } = nodeConfig.llm; const LLMNode: React.FC = (props) => ( - } colorScheme="blue"> + } colorScheme={colorScheme}> From 4f807ef8d24cfecd494b740f293434bd7095b9f0 Mon Sep 17 00:00:00 2001 From: Onelevenvy Date: Tue, 24 Sep 2024 16:57:51 +0800 Subject: [PATCH 2/3] feat: add agent name --- backend/app/core/workflow/init_graph.py | 3 ++- backend/app/core/workflow/node.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/core/workflow/init_graph.py b/backend/app/core/workflow/init_graph.py index 3efabb9e..916f7cec 100644 --- a/backend/app/core/workflow/init_graph.py +++ b/backend/app/core/workflow/init_graph.py @@ -180,7 +180,8 @@ def initialize_graph( openai_api_key=model_info["api_key"], openai_api_base=model_info["base_url"], temperature=node_data["temperature"], - system_prompt=node_data["systemMessage"], + system_prompt=node_data.get("systemMessage", None), + agent_name=node_data.get("label", node_id), ).work ), ) diff --git a/backend/app/core/workflow/node.py b/backend/app/core/workflow/node.py index 9d98734c..f8a27e0c 100644 --- a/backend/app/core/workflow/node.py +++ b/backend/app/core/workflow/node.py @@ -163,8 +163,10 @@ def __init__( openai_api_base: str, temperature: float, system_prompt: str, + agent_name: str, ): self.system_prompt = system_prompt + self.agent_name = agent_name if provider in ["zhipuai", "Siliconflow"]: self.model = ChatOpenAI( model=model, @@ -250,6 +252,7 @@ async def work(self, state: TeamState, config: RunnableConfig) -> ReturnTeamStat "If you are unable to perform the task, that's OK, you can ask human for help, or just say that you are unable to perform the task." "Execute what you can to make progress. " "And your role is:" + self.system_prompt + "\n" + "And your name is:" + self.agent_name + "\n" "Stay true to your role and use your tools if necessary.\n\n", ), ( From 9812bfea546216d4dde6c5af0fb6af6847873ce9 Mon Sep 17 00:00:00 2001 From: Onelevenvy Date: Tue, 24 Sep 2024 18:22:06 +0800 Subject: [PATCH 3/3] fix:useSkillsQuery --- web/src/app/(applayout)/skills/page.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/web/src/app/(applayout)/skills/page.tsx b/web/src/app/(applayout)/skills/page.tsx index cd47c95d..cd3255f0 100644 --- a/web/src/app/(applayout)/skills/page.tsx +++ b/web/src/app/(applayout)/skills/page.tsx @@ -23,17 +23,13 @@ import { import { useTabSearchParams } from "@/hooks/useTabSearchparams"; import TabSlider from "@/components/Common/TabSlider"; import { useTranslation } from "react-i18next"; +import { useSkillsQuery } from "@/hooks/useSkillsQuery"; function Skills() { const showToast = useCustomToast(); const { t } = useTranslation(); - const { - data: skills, - isLoading, - isError, - error, - } = useQuery("skills", () => SkillsService.readSkills({})); + const { data: skills, isLoading, isError, error } = useSkillsQuery(); if (isError) { const errDetail = (error as ApiError).body?.detail; showToast("Something went wrong.", `${errDetail}`, "error");