代理程式

用量

agent: agent_name {
  advanced_analytics: yes | no
  description: "string"
  instructions: "string"
  is_dashboard_agent: yes | no
  show_debuginfo: yes | no
  show_thinking: yes | no
}
階層
模型檔案或 LookML 檔案
agent
預設值

接受
  • advanced_analyticsyes | no (預設為 no)。
  • description:描述代理程式的字串。
  • instructions:指定自訂提示和行為規則的字串。支援 LookML 常數 (@{CONSTANT_NAME})。
  • is_dashboard_agentyes | no (資訊主頁代理程式需要yes此項目)。
  • show_debuginfoyes | no (預設為 no)。
  • show_thinkingyes | no (預設為 no)。

定義

agent 參數會在 LookML 中宣告資料代理。開發人員可以透過資訊主頁代理,在版本管控的 LookML 中定義自訂代理指令、分析行為和顯示偏好設定,並使用 default_dashboard_agentdashboard_agents 參數,將代理與 LookML 資訊主頁建立關聯。

如要進一步瞭解如何設定及使用 LookML 資訊主頁代理,請參閱「建立及管理 LookML 資訊主頁資料代理」說明文件頁面。

子參數

資訊主頁代理程式定義支援下列子參數:

advanced_analytics

advanced_analytics 子參數可控制代理程式是否能使用進階分析,生成及執行 Python 程式碼,進行複雜的運算和自訂視覺化作業。

接受 yesno。預設值為 no

description

description 子參數提供代理程式用途的選用文字說明。

agent: sales_agent {
  description: "Executive sales overview dashboard agent"
  is_dashboard_agent: yes
}

instructions

instructions 子參數可接受任意形式的字串,在處理對話式問題時,為代理程式提供業務背景、偏好的欄位、篩選規則或語氣。

agent: sales_agent {
  instructions: "Focus on net revenue and filter by current quarter by default."
  is_dashboard_agent: yes
}

您可以使用 @{<var>CONSTANT_NAME</var>} 語法,在 instructions 中參照 LookML 常數

agent: sales_agent {
  instructions: "Focus on net revenue. @{FISCAL_YEAR_RULE}"
  is_dashboard_agent: yes
}

如果省略,代理程式會在沒有自訂指令內容的情況下運作。

is_dashboard_agent

is_dashboard_agent 子參數會指定代理程式是否設定為資訊主頁代理程式。

接受 yesno。如要將代理程式與 LookML 資訊主頁搭配使用,請將這個參數設為 yes

show_debuginfo

show_debuginfo 子參數會決定代理程式是否在對話回覆中顯示執行記錄和診斷資訊。

接受 yesno。預設值為 no

show_thinking

show_thinking 子參數會決定代理程式是否要在對話回覆中顯示推論步驟和中繼查詢規劃。

接受 yesno。預設值為 no

範例

定義 LookML 資訊主頁代理

以下範例定義了 LookML 資訊主頁代理,其中包含自訂指令、已啟用進階數據分析,以及已開啟思考過程顯示功能:

agent: customer_insights_agent {
  instructions: "Address the user politely. Prioritize active subscriber metrics and churn analysis."
  description: "Dashboard agent for Customer Insights dashboard."
  is_dashboard_agent: yes
  advanced_analytics: yes
  show_thinking: yes
  show_debuginfo: no
}

如要在 LookML 資訊主頁上使用這個代理,請在 .dashboard.lookml 檔案中對應:

- dashboard: customer_insights
  title: "Customer Insights"
  layout: newspaper
  enable_dashboard_agent: true
  default_dashboard_agent: customer_insights_agent
  dashboard_agents: [customer_insights_agent]

  elements:
  - name: active_subscribers
    type: single_value
    model: subscriptions
    explore: customers
    measures: [customers.count]