-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from kreneskyp/agent_reference
Nested agents.
- Loading branch information
Showing
13 changed files
with
171 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
import { ChainSelect } from "chains/ChainSelect"; | ||
|
||
export const AgentSelect = ({ onChange, value }) => { | ||
return <ChainSelect onChange={onChange} value={value} is_agent={true} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,15 @@ | ||
import React from "react"; | ||
import { Box } from "@chakra-ui/react"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faChain } from "@fortawesome/free-solid-svg-icons"; | ||
import { DraggableNode } from "chains/editor/DraggableNode"; | ||
import { useEditorColorMode } from "chains/editor/useColorMode"; | ||
import { DraggableButton } from "chains/DraggableButton"; | ||
|
||
export const ChainDraggable = ({ chain }) => { | ||
const { isLight } = useEditorColorMode(); | ||
const style = isLight | ||
? { | ||
bg: "gray.100", | ||
_hover: { bg: "gray.300" }, | ||
} | ||
: { | ||
bg: "whiteAlpha.200", | ||
_hover: { bg: "whiteAlpha.300" }, | ||
}; | ||
|
||
return ( | ||
<DraggableNode | ||
<DraggableButton | ||
name={chain.name} | ||
description={chain.description} | ||
config={{ chain_id: chain.id }} | ||
class_path="ix.runnable.flow.load_chain_id" | ||
> | ||
<Box | ||
p={2} | ||
h={8} | ||
borderRadius={5} | ||
borderLeft={"6px solid"} | ||
borderColor={"blue.300"} | ||
fontSize={"sm"} | ||
display={"flex"} | ||
alignItems={"center"} | ||
{...style} | ||
> | ||
<FontAwesomeIcon icon={faChain} style={{ marginRight: "5px" }} />{" "} | ||
Reference | ||
</Box> | ||
</DraggableNode> | ||
label="Reference" | ||
highlight={"blue.400"} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import { Box } from "@chakra-ui/react"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faChain } from "@fortawesome/free-solid-svg-icons"; | ||
import { DraggableNode } from "chains/editor/DraggableNode"; | ||
import { useEditorColorMode } from "chains/editor/useColorMode"; | ||
|
||
export const DraggableButton = ({ | ||
name, | ||
description, | ||
config, | ||
class_path, | ||
highlight = "blue.300", | ||
label = "Reference", | ||
}) => { | ||
const { isLight } = useEditorColorMode(); | ||
const style = isLight | ||
? { | ||
bg: "gray.100", | ||
_hover: { bg: "gray.300" }, | ||
} | ||
: { | ||
bg: "whiteAlpha.200", | ||
_hover: { bg: "whiteAlpha.300" }, | ||
}; | ||
|
||
return ( | ||
<DraggableNode | ||
name={name} | ||
description={description} | ||
config={config} | ||
class_path={class_path} | ||
> | ||
<Box | ||
p={2} | ||
h={8} | ||
borderRadius={5} | ||
borderLeft={"6px solid"} | ||
borderColor={highlight} | ||
fontSize={"sm"} | ||
display={"flex"} | ||
alignItems={"center"} | ||
{...style} | ||
> | ||
<FontAwesomeIcon icon={faChain} style={{ marginRight: "5px" }} />{" "} | ||
{label} | ||
</Box> | ||
</DraggableNode> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import React from "react"; | ||
|
||
import { HStack } from "@chakra-ui/react"; | ||
import { AgentCard } from "agents/AgentCard"; | ||
import { ModalClose } from "components/Modal"; | ||
import { AgentEditButton } from "agents/AgentEditButton"; | ||
import { DraggableButton } from "chains/DraggableButton"; | ||
|
||
export const EditorAgentCard = ({ agent, ...props }) => { | ||
const close = React.useContext(ModalClose); | ||
|
||
return ( | ||
<AgentCard agent={agent} {...props}> | ||
<AgentEditButton agent={agent} onClick={close} /> | ||
<HStack spacing={2} pt={4} display="flex" justifyContent="flex-end"> | ||
<DraggableButton | ||
name={agent.name} | ||
description={agent.description} | ||
config={{ chain_id: agent.chain_id }} | ||
class_path="ix.runnable.flow.load_agent_id" | ||
label="Reference" | ||
highlight={"green.400"} | ||
/> | ||
<AgentEditButton agent={agent} onClick={close} /> | ||
</HStack> | ||
</AgentCard> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test_data/snapshots/components/ix.runnable.flow.load_agent_id.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"child_field": null, | ||
"class_path": "ix.runnable.flow.load_agent_id", | ||
"config_schema": { | ||
"display_groups": null, | ||
"properties": { | ||
"chain_id": { | ||
"description": "The agent to embed.", | ||
"input_type": "IX:agent", | ||
"label": "Agent", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"chain_id" | ||
], | ||
"title": "load_agent_id", | ||
"type": "object" | ||
}, | ||
"connectors": null, | ||
"description": "Embed an agent in another flow. The agent is called as if it were a component in the local flow.", | ||
"display_type": "node", | ||
"fields": [ | ||
{ | ||
"choices": null, | ||
"default": null, | ||
"description": "The agent to embed.", | ||
"init_type": "init", | ||
"input_type": "IX:agent", | ||
"label": "Agent", | ||
"max": null, | ||
"min": null, | ||
"name": "chain_id", | ||
"parent": null, | ||
"required": true, | ||
"secret_key": null, | ||
"step": null, | ||
"style": null, | ||
"type": "string" | ||
} | ||
], | ||
"name": "Agent Reference", | ||
"type": "agent" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters