与图表 Chat
您可以使用对话式分析提出有关图的问题。智能体可以编写 SQL 查询,并提供输出的可视化图表。智能体还可以使用图中定义的说明、同义词、扩展程序和度量来提高结果质量。根据图表架构和您提出的问题,代理会使用 Graph Query Language (GQL) 或 SQL 中的 GRAPH_EXPAND 表值函数来查询图表。GQL 查询需要 BigQuery 企业版或企业 Plus 版预留。在采用按需价格的项目中,GQL 查询会失败并显示错误。包含 GRAPH_EXPAND 函数的查询可以使用按需价格运行,但该函数不支持所有类型的图。如需了解要求和限制,请参阅 GRAPH_EXPAND。
图表会对表之间的关系进行编码。为智能体提供图表可以消除表之间关系的不确定性。这种清晰度可以减少幻觉,并提高对话效率。
例如,如需尝试向代理询问公开提供的 Look Ecommerce 图,请执行以下操作:
在 Google Cloud 控制台中,前往 BigQuery 代理页面。
选择智能体目录标签页。
在 Sample agents by Google(Google 提供的示例代理)部分,点击 The Look Graph。
系统会打开一个对话。您可以输入有关
bigquery-public-data.thelook_ecommerce.graph图表的问题。
与图表 Chat
如需与图表对话,您可以创建数据智能体,并将其数据源设置为您的图表,也可以创建与图表的直接对话。如果您不确定要问什么,请尝试询问 What questions can I ask about this data?。例如,如果您询问有关 Look Ecommerce 图的问题,回答会包含图架构概览和建议的问题。回答中可能会出现以下问题:
业务绩效
What is the total revenue for each product category, sorted from highest to lowest?What are the top 5 brands by total revenue among users from 'Brasil'?Rank the product categories based on their total revenue for each product department (Men/Women).
用户和物流数据分析
How many users do we have in each country?What is the distribution of user ages in the United States?Which distribution centers handle the most orders with a 'Complete' status?
关系分析
Show the connection between users and the distribution centers their products are shipped from.Find all products that have been ordered by users who came from a 'Search' traffic source.
创建图查询和可视化图表
对话式分析可以编写 GQL 查询来回答有关图的问题,并以可视化图表的形式显示输出。例如,您可以在对话中输入 Show the connection between Tina Fletcher's orders and distribution centers。智能体可能会运行类似于以下内容的 GQL 查询:
GRAPH `bigquery-public-data.thelook_ecommerce.graph`
MATCH p = (u:User {id: 32})
<-[:placed_order]-(o:`Order`)
<-[:belongs_to_order]-(oi:OrderItem)
-[:includes_product]->(pr:Product)
-[:product_stocked_at]->(dc:DistributionCenter)
RETURN TO_JSON(p) AS path;
智能体可能还会提供交互式可视化图表。

使用图表度量
对话式分析可以使用图上定义的测量来帮助准确回答涉及聚合的问题。例如,您可以向 Look Graph 代理提出以下问题:Which distribution centers process orders from the largest number of distinct customers?
智能体使用 User 节点上的 user_count 测量,以避免重复计算客户数量。用于计算回答的查询可能类似于以下内容:
SELECT
DistributionCenter_id,
DistributionCenter_name,
AGG(User_user_count) AS distinct_customer_count
FROM
GRAPH_EXPAND("bigquery-public-data.thelook_ecommerce.graph")
GROUP BY
DistributionCenter_id,
DistributionCenter_name
ORDER BY
distinct_customer_count DESC;
代理可能还会提供图表可视化。
