Skip to content

Commit

Permalink
Merge pull request #47 from near/develop
Browse files Browse the repository at this point in the history
Release global tags
  • Loading branch information
gabehamilton committed Apr 22, 2024
2 parents 463b812 + abbd913 commit 061f52e
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 30 deletions.
68 changes: 68 additions & 0 deletions nexus/components/src/AI/Agent/AgentCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,45 @@ const Actions = styled.div`
align-items: center;
gap: 2px;
`;
const sharedButtonStyles = `
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 8px;
height: 32px;
border-radius: 50px;
font-weight: 600;
font-size: 12px;
line-height: 15px;
text-align: center;
cursor: pointer;
&:hover,
&:focus {
text-decoration: none;
outline: none;
}
i {
color: #7E868C;
}
.bi-16 {
font-size: 16px;
}
`;
const Button = styled.button`
${sharedButtonStyles}
color: ${(p) => (p.primary ? "#09342E" : "#11181C")} !important;
background: ${(p) => (p.primary ? "#59E692" : "#FBFCFD")};
border: ${(p) => "none"};
&:hover,
&:focus {
background: ${(p) => (p.primary ? "rgb(112 242 164)" : "#ECEDEE")};
}
`;

const AgentCard = ({ item, editFunction }) => {
const { accountId, name, displayName, prompt, logoUrl, tags } = item;
const agentComponent = item.component
Expand Down Expand Up @@ -145,6 +184,35 @@ const AgentCard = ({ item, editFunction }) => {
),
}}
/>
<Widget
src="${REPL_ACCOUNT}/widget/SocialIndexActionButton"
props={{
actionName: "star",
actionUndoName: "unstar",
item: {
type: "social",
path: `${accountId}/entities/${namespace}/${entityType}/${name}`,
},
notifyAccountId: accountId,
button: (starCount, starIsActive, starOnClick) => (
<Button
type="button"
onClick={starOnClick}
aria-label="Star this"
>
{starIsActive ? (
<i
className="bi bi-star-fill"
style={{ color: "var(--amber10)" }}
/>
) : (
<i className="bi bi-star" />
)}{" "}
{item.stars}
</Button>
),
}}
/>{" "}
<Widget
src="${REPL_ACCOUNT}/widget/CopyUrlButton"
props={{
Expand Down
3 changes: 2 additions & 1 deletion nexus/components/src/AI/Agent/AgentDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let { src, tab, schemaFile, namespace, returnTo } = props;
let { src, tab, schemaFile, namespace, entityType, returnTo } = props;

const summaryComponent = "${REPL_ACCOUNT}/widget/AI.Agent.AgentSummary";
const customComponentLabel = (component) => {
Expand Down Expand Up @@ -37,6 +37,7 @@ return (
tab,
schemaFile,
namespace,
entityType,
summaryComponent,
additionalTabs,
returnTo,
Expand Down
8 changes: 4 additions & 4 deletions nexus/components/src/AI/Agent/AgentSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (!href) {
return <></>;
}

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

Expand Down Expand Up @@ -229,14 +229,14 @@ return (
actionUndoName: "unstar",
item: {
type: "social",
path: `${accountId}/agent/${name}`,
path: `${accountId}/entities/${namespace}/${entityType}/${name}`,
},
notifyAccountId: accountId,
button: (starCount, starIsActive, starOnClick) => (
<Button
type="button"
onClick={starOnClick}
aria-label="Star this agent"
aria-label="Star this"
>
{starIsActive ? (
<i
Expand All @@ -246,7 +246,7 @@ return (
) : (
<i className="bi bi-star" />
)}{" "}
{starCount}
{entity.stars}
</Button>
),
}}
Expand Down
49 changes: 45 additions & 4 deletions nexus/components/src/AI/Nexus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ useEffect(() => {

const [activeTabs, setActiveTabs] = useState(
storedTabs || {
datasets: "alignment",
models: "providers",
agents: "agents",
datasets: "alignmentDataset",
models: "modelProvider",
agents: "agent",
agentTools: "contractTool",
dataSources: "dataSource",
verifications: "dataReputation",
},
);

Expand All @@ -52,6 +55,8 @@ if (!paramsHandled && props.group && props.group !== activeGroup) {
}
}

const [globalTagFilter, setGlobalTagFilter] = useState(null);

const content = {
overview: () => {
return (
Expand Down Expand Up @@ -98,7 +103,11 @@ const renderContent = () => {
case "dashboard":
return content.dashboard();
default:
return content.subGroups(activeGroup, schema[activeGroup]);
return content.subGroups(
activeGroup,
schema[activeGroup],
globalTagFilter, // forces re-render, gets passed through Storage
);
}
};

Expand All @@ -119,6 +128,32 @@ const sidebarItems = (schema) => {
});
};

const findEntityInSchema = (schema, entityType) => {
for (const [category, group] of Object.entries(schema)) {
if (!group.items) continue;
for (const item of group.items) {
if (item.value === entityType) {
return [category, item.value];
}
}
}
return [null, null];
};

const handleTagClick = (tag) => {
const entityType = tag.entityType ?? tag.entity_type;
const [category, subType] = findEntityInSchema(schema, entityType);
if (!category || !subType) {
console.error(`Entity type ${entityType} not found in schema`);
return;
}
Storage.set("global-tag-filter", [tag.tag]);
setGlobalTagFilter([tag.tag]);
setActiveTabs((prev) => {
return { ...prev, [category]: subType };
});
handleMenuClick(category);
};
return (
<div className="gateway-page-container">
<div className="d-flex flex-column gap-5">
Expand All @@ -129,6 +164,12 @@ return (
title: "NEAR AI",
activeTab: activeGroup,
items: sidebarItems(schema),
additionalContent: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.Forms.TagCloud"
props={{ namespace: "near", onSelect: handleTagClick }}
/>
),
}}
/>
{renderContent()}
Expand Down
42 changes: 21 additions & 21 deletions nexus/components/src/AI/Schema/Nexus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const schema = {
datasets: {
title: "Datasets",
icon: "ph ph-list-checks",
defaultValue: "alignment",
defaultValue: "alignmentDataset",
items: [
{
name: "Crowdsourcing",
value: "crowdsourcing",
value: "crowdsourcedDataset",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand Down Expand Up @@ -55,7 +55,7 @@ const schema = {
},
{
name: "Foundation",
value: "foundation",
value: "foundationDataset",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -70,7 +70,7 @@ const schema = {
},
{
name: "Supervised Fine Tuning",
value: "fineTuning",
value: "fineTuningDataset",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -86,7 +86,7 @@ const schema = {
},
{
name: "Alignment",
value: "alignment",
value: "alignmentDataset",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -106,11 +106,11 @@ const schema = {
models: {
title: "Models & Providers",
icon: "ph ph-list-checks",
defaultValue: "providers",
defaultValue: "modelProvider",
items: [
{
name: "Providers",
value: "providers",
value: "modelProvider",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -126,7 +126,7 @@ const schema = {
},
{
name: "Standard Model Names",
value: "modelNames",
value: "modelName",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -143,7 +143,7 @@ const schema = {
},
{
name: "Model Weights",
value: "models",
value: "model",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -162,19 +162,19 @@ const schema = {
agents: {
title: "Agents",
icon: "ph ph-list-checks",
defaultValue: "agents",
defaultValue: "agent",
items: [
{
name: "Agents",
value: "agents",
value: "agent",
content: (
<Widget src="${REPL_ACCOUNT}/widget/AI.Agent.AgentEntityConfig" />
),
icon: "ph ph-address-book",
},
{
name: "Frameworks",
value: "frameworks",
value: "agentFramework",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -189,7 +189,7 @@ const schema = {
},
{
name: "Modules",
value: "modules",
value: "agentModule",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -200,14 +200,14 @@ const schema = {
},
{
name: "User Interfaces",
value: "uis",
value: "agentUserInterface",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
props={{
namespace: "near",
homeLink,
entityType: "customUI",
entityType: "agentUserInterface",
title: "Custom User Interfaces",
}}
/>
Expand All @@ -219,11 +219,11 @@ const schema = {
agentTools: {
title: "Tools for Agents",
icon: "ph ph-list-checks",
defaultValue: "contracts",
defaultValue: "contractTool",
items: [
{
name: "On-chain Contracts",
value: "contracts",
value: "contractTool",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -239,7 +239,7 @@ const schema = {
},
{
name: "APIs",
value: "apis",
value: "apiTool",
content: (
<Widget
src="${REPL_ACCOUNT}/widget/Entities.Template.GenericEntityConfig"
Expand All @@ -258,7 +258,7 @@ const schema = {
datasources: {
title: "Data Sources",
icon: "ph ph-list-checks",
defaultValue: "privateDataSource",
defaultValue: "dataSource",
items: [
{
name: "Data Sources",
Expand Down Expand Up @@ -304,10 +304,10 @@ const schema = {
},
],
},
verification: {
verifications: {
title: "Verifications",
icon: "ph ph-list-checks",
defaultValue: "privateDataSource",
defaultValue: "dataReputation",
items: [
{
name: "Data Reputation",
Expand Down

0 comments on commit 061f52e

Please sign in to comment.