Skip to content

Commit

Permalink
Merge pull request #20 from near/develop
Browse files Browse the repository at this point in the history
Current resource planning
  • Loading branch information
gabehamilton authored Apr 4, 2024
2 parents ecaa37d + 30bd127 commit b33da02
Show file tree
Hide file tree
Showing 9 changed files with 611 additions and 224 deletions.
6 changes: 4 additions & 2 deletions nexus/components/src/Agent/AgentCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if (!href) {
return <></>;
}

const {namespace, entityType, schemaFile} = props;

const Card = styled.div`
cursor: pointer;
background-color: white;
Expand Down Expand Up @@ -70,8 +72,8 @@ const AgentCard = ({ item, editFunction }) => {
params: { src: `${accountId}/agent/${name}` },
});
const detailsLink = href({
widgetSrc: `${REPL_AGIGUILD}/widget/Agent.AgentDetails`,
params: { src: `${accountId}/agent/${name}` },
widgetSrc: `${REPL_ACCOUNT}/widget/Agent.AgentDetails`,
params: { src: `${accountId}/agent/${name}`, schemaFile, namespace, entityType },
});

const actionUrl = `https://${REPL_NEAR_URL}/${agentComponent}?src=${accountId}/agent/${item.name}`;
Expand Down
154 changes: 14 additions & 140 deletions nexus/components/src/Agent/AgentDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,150 +1,24 @@
const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url");
const { schema } = VM.require(`${REPL_AGIGUILD}/widget/Schema.Agent`);
if (!href || !schema ) {
return <></>;
}


let { src, tab, highlightComment } = props;
const [accountId, entityType, agentName] = src.split("/") ?? [null, null, null];

let agent = Social.get(`${accountId}/agent/${agentName}/**`);
const exists = !existsData || Object.keys(existsData).length > 0;

if (!exists) {
return (
<div className="alert alert-danger mx-3" role="alert">
<div>Error</div>
<div>Could not find: {src}</div>
</div>
);
}

agent = { accountId, name: agentName, ...agent };
const { prompt } = agent;
const agentComponent = agent.component ? agent.component : `${REPL_AGIGUILD}/widget/Agent.AgentChat`;
const editType = accountId === context.accountId ? "edit" : "fork";
const editLabel = editType === "edit" ? "Edit" : "Fork";
const editIcon = editType === "edit" ? "ph-bold ph-pencil-simple" : "ph-bold ph-git-fork";
const listLink = href({
widgetSrc: `${REPL_AGIGUILD}/widget/Nexus`,
});

const Wrapper = styled.div`
display: flex;
flex-direction: column;
gap: 32px;
padding-bottom: 48px;
`;

const ContentWrapper = styled.div`
display: grid;
grid-template-columns: minmax(0, 1fr) 260px;
gap: 32px;
@media (max-width: 1200px) {
grid-template-columns: minmax(0, 1fr);
gap: 24px;
}
`;

const Header = styled.h1`
font-size: 24px;
line-height: 39px;
color: #11181c;
margin: 0;
font-weight: 600;
`;

const Text = styled.p`
margin: 0;
font-size: 14px;
line-height: 20px;
color: ${(p) => (p.bold ? "#11181C" : "#687076")};
font-weight: ${(p) => (p.bold ? "600" : "400")};
font-size: ${(p) => (p.small ? "12px" : "14px")};
i {
margin-right: 4px;
}
`;
const PropValue = styled.p`
margin: 0;
font-size: 14px;
line-height: 20px;
padding-bottom: 10px;
`;
const agentProperties = (obj) => {
const { accountId, name, displayName, logoUrl, ...displayProps } = obj;
return (
<>
{Object.keys(displayProps).map((k) => (
<>
<Text bold key={k}>
{k}:
</Text>
<PropValue>{obj[k]}</PropValue>
</>
))}
</>
);
};
let { src, tab, schemaFile, namespace } = props;

const summaryComponent = "${REPL_AGIGUILD}/widget/Agent.AgentSummary";
const customComponentLabel = (component) => {
if (component === `agiguild.near/widget/Agent.AgentChat`) {
return "Chat";
}
return <Widget src="${REPL_ACCOUNT}/widget/DIG.Tooltip" props={{ content: <p>{component}</p>, trigger: "Chat (Custom component)"}} />;
}

return (
<Wrapper>
<Link to={listLink}>
<Header>
<i className="ph ph-arrow-left" />
Agent List
</Header>
</Link>
<Widget
src="${REPL_AGIGUILD}/widget/Agent.AgentSummary"
props={{
size: "small",
showTags: true,
agent: agent,
showActions: true,
}}
/>
<ContentWrapper>
<Widget
src="${REPL_ACCOUNT}/widget/DIG.Tabs"
props={{
variant: "line",
size: "large",
defaultValue: "prompt",
items: [
{
name: "Properties",
value: "prompt",
content: agentProperties(agent),
icon: "ph ph-code",
},
{
name: editLabel,
value: "edit",
content: <Widget src={"${REPL_ACCOUNT}/widget/Entities.Template.EntityCreate"} props={{entityType, schema, data: agent, cancelLabel: 'Clear changes' }} />,
icon: editIcon,
},
{
name: customComponentLabel(agentComponent),
value: "chat",
content: <Widget src={agentComponent} props={{ src, embedded: true }} />,
icon: "ph ph-code",
},
],
}}
/>
const additionalTabs = (entity) => {
const agentComponent = entity.component ? entity.component : `${REPL_AGIGUILD}/widget/Agent.AgentChat`;

<Widget src="${REPL_ACCOUNT}/widget/ComponentDetails.Sidebar" props={{ src }} />
</ContentWrapper>
</Wrapper>
return {
name: customComponentLabel(agentComponent),
value: "chat",
content: <Widget src={agentComponent} props={{ src, embedded: true }} />,
icon: "ph ph-code",
}};

return (
<Widget src="${REPL_ACCOUNT}/widget/Entities.Template.EntityDetails"
props={{ src, tab, schemaFile, namespace, summaryComponent, additionalTabs }} />
);
3 changes: 3 additions & 0 deletions nexus/components/src/Agent/AgentEntityConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const renderItem = (item, editFunction) => {
props={{
item: convertSnakeToPascal(flatItem),
editFunction,
namespace: 'agiguild',
entityType: 'agent',
schemaFile: "${REPL_AGIGUILD}/widget/Schema.Agent",
}}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions nexus/components/src/Agent/AgentSummary.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
if (!props.agent) return "";
if (!props.entity) return "";
const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url");
if (!href) {
return <></>;
}

const { agent, showActions } = props;
const { accountId, name, displayName, prompt, logoUrl, tags, component } = agent;
const { entity, showActions } = props;
const { accountId, name, displayName, prompt, logoUrl, tags, component } = entity;

const agentComponent = item.component ? item.component : `${REPL_AGIGUILD}/widget/Agent.AgentChat`;
const chatLink = href({
Expand Down
File renamed without changes.
29 changes: 25 additions & 4 deletions nexus/components/src/Nexus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const content = {
overview: () => {
return (
<div>
<Widget src="${REPL_AGIGUILD}/widget/Agent.AgentHeader" props={{text: "AGI Guild", color: "#11181c"}}/>
<Widget src="${REPL_AGIGUILD}/widget/HeaderText" props={{text: "AGI Guild", color: "#11181c"}}/>
<Instructions>
<p>Welcome to the AGI Guild</p>

Expand All @@ -58,6 +58,7 @@ const content = {
<Link href={'https://github.com/agiguild/agiguild/blob/master/README.md'} target="_blank">https://github.com/agiguild/agiguild/</Link>
</p>
</div>
<Widget src="${REPL_AGIGUILD}/widget/Overview" props={{}}/>
</Instructions>
</div>
);
Expand All @@ -83,13 +84,33 @@ const content = {
/>
</div>
);
}
},
dashboard: () => {
return (
<div>
<Instructions>
<p>This is your personal Dashboard</p>

<div style={{paddingLeft: "2em"}}>
<p>
Usage of Agents, Datasets, etc that you have contributed.
</p>
<p>
Your favorite Agents.
</p>
</div>
</Instructions>
</div>
);
},
}

const renderContent = () => {
switch (activeGroup) {
case "overview":
switch (activeGroup) {
case "overview":
return content.overview();
case "dashboard":
return content.dashboard();
default:
return content.subGroups(activeGroup, schema[activeGroup]);
}
Expand Down
Loading

0 comments on commit b33da02

Please sign in to comment.