ESM
import "@arcgis/ai-components/components/arcgis-assistant-knowledge-agent";
Inheritance
ArcgisAssistantKnowledgeAgentHTMLElement
Since
ArcGIS Maps SDK for JavaScript 5.1
beta

The Knowledge Agent enables the end user to explore knowledge graph data in a link chart, a knowledge graph service, or a knowledge graph layer in a map via natural language queries. It also provides additional capabilities when used with a knowledge graph layer or link chart. See the list of capabilities below for more details.

The knowledge agent is designed to answer questions about data in the knowledge graph provided by the knowledge graph layer on map, a link chart or a knowledge graph service url, and does not have access to external data sources or the user's location.

It cannot create visualizations in the form of charts, layer renderers, new maps, or other visual outputs. When provided a link chart as context, it can create new link charts based on queries generated from user prompts.

This agent can add to the knowledge graph data on a map or link chart if a user prompt generates a query that returns entities or relationships from the graph and asks for the returned results to be added to the view. It can also change the layout of a link chart or toggle visibility of non-spatial data on a link chart. However, it cannot change the symbology of features or create new layers or export results of a query to a file or external source.

This is an unrendered component that must be added as a child of the arcgis-assistant component in either HTML or JavaScript.

Link Chart context example:

<arcgis-link-chart id="my-link-chart"></arcgis-link-chart>
<arcgis-assistant>
<arcgis-assistant-knowledge-agent reference-element="my-link-chart"></arcgis-assistant-knowledge-agent>
</arcgis-assistant>

Map context example: Note: the map must contain one knowledge graph layer.

<arcgis-map id="my-map"></arcgis-map>
<arcgis-assistant>
<arcgis-assistant-knowledge-agent reference-element="my-map"></arcgis-assistant-knowledge-agent>
</arcgis-assistant>

Knowledge Graph Service context example:

<arcgis-assistant>
<arcgis-assistant-knowledge-agent
service-url="https://example.com/server/rest/services/Hosted/myKnowledgeGraph/KnowledgeGraphServer"
>
</arcgis-assistant-knowledge-agent>
</arcgis-assistant>

Once added to the assistant, the agent is loaded and ready to receive user messages directed to their knowledge graph related layers or data.

Capabilities

The knowledge agent provides the following capabilities related to a knowledge graph or associated knowledge graph layer or link chart layer:

  • Query - Ask about the entities and relationships in my graph. This includes questions about connections between entities and patterns in the graph, as well as questions about the structure of the graph such as the types of entities and relationships and the number of each type. Returns the results of the query in text form, and can optionally add returned entities or relationships to the map or link chart view if the user prompt requests it.
  • Search - Search for specific entities or relationships in the knowledge graph, or the closest matches based on their properties. Returns the results of the search in text form, and can optionally add returned entities or relationships to the map or link chart view if the user prompt requests it.
  • Generate Cypher Query - Generates and returns a cypher query based on a natural language question and the current knowledge graph data model, which can be run against the knowledge graph service.

Additional capabilities with a map view with a knowledge graph layer or a link chart view

  • Add entities and relationships - Add entities or relationships the the knowledge graph or link chart layer based on results returned from searches or queries generated from user prompts.

Additional capabilities with a link chart view only

  • Change link chart layout - Change the layout of the link chart between different modes such as force directed, radial, or hierarchical.
  • Toggle non-spatial visibility - Show or hide non-spatial entities and relationships on the link chart.
  • Create link chart from query - Recreate the link chart with new entities and relationships based on a query generated from the user prompt.

Example questions

The following are example questions a user can ask within the bounds of the knowledge agent:

  • "What entities are in this graph, and what is the count of each entity type?"
  • "Who are the top 5 entities most connected to Company X?"
  • "Find all employees with the last name Smith."
  • "What is the most influential company in this graph?"
  • "Generate a cypher query to find all employees of Company X that joined the company after 2022 who worked for a competitor before joining Company X."
  • "Add all connections between Company X and Company Y to the link chart"
  • "Change the layout to hierarchical"
  • "Hide non spatial data on the link chart"
  • "Create a new link chart with all employees from Company X that joined the company after 2015 and are located in California"

Due to the non-deterministic nature of generative AI, there may be inaccuracies or unexpected behavior when using the out-of-the-box agents.

See also

Properties

PropertyAttributeType
reference-element
ArcgisLinkChart | ArcgisMap | string | undefined
reflected
service-url

context

Property
Type
ArcgisKnowledgeAssistantContext | undefined

Optional context for the knowledge agent. If the agent does not have a view or kg service url provided via reference element or serviceUrl property a knowledge graph can be provided directly via context to enable Knowledge Service related capabilties.

Depending on the context provided, different capabilities will be available.

referenceElement

Property
Type
ArcgisLinkChart | ArcgisMap | string | undefined

The reference element to the map that provides context for the navigation agent. Currently, this is only scoped to arcgis-map elements. This shows the navigation agent which map on which to perform navigation actions. This is required for the navigation agent to function properly.

Setting this property is not necessary if you set the reference element on the parent arcgis-assistant component.

See also
Attribute
reference-element
Example
<arcgis-link-chart id="my-link-chart"></arcgis-link-chart>
<arcgis-assistant>
<arcgis-assistant-knowledge-agent reference-element="my-link-chart"></arcgis-assistant-knowledge-agent>
</arcgis-assistant>

serviceUrl

reflected Property
Type
null | undefined | string

The URL of a Knowledge Graph Service. This can be set to use the agent without a map or link chart view.

If a map or link chart view reference element are provided, this property will be ignored.

Attribute
service-url
Example
<arcgis-assistant>
<arcgis-assistant-knowledge-agent service-url="https://example.esri.com/server/rest/services/Hosted/KGS_Service_Name/KnowledgeGraphServer"></arcgis-assistant-knowledge-agent>
</arcgis-assistant>

Methods

MethodSignature
inherited
componentOnReady(): Promise<this>

componentOnReady

inherited Method
Signature
componentOnReady (): Promise<this>
Inherited from: this

Creates a promise that resolves once the component is fully loaded.

Returns
Promise<this>
Example
const arcgisAssistantKnowledgeAgent = document.createElement("arcgis-assistant-knowledge-agent");
document.body.append(arcgisAssistantKnowledgeAgent);
await arcgisAssistantKnowledgeAgent.componentOnReady();
console.log("arcgis-assistant-knowledge-agent is ready to go!");

Type definitions

ArcgisKnowledgeAssistantContext

Type definition

Context required by the Knowledge Link Chart agent. Supplied by the application via an agent getContext() provider.

Type
{ view: LinkChartView | MapView; knowledgeGraph?: never; } | { knowledgeGraph: KnowledgeGraph; view?: never; }