共用方式為


AIClassify、、AIExtract、AIReply、AISentimentAISummarizeAISummarizeRecord和AITranslate

適用於: 畫布應用程式 Dataverse 函數

描述

Dataverse 提供各種預先設定的即用型 AI 功能,不需要任何資料收集、建置或訓練。 您可以在應用程式和工作流程中使用這些預建 AI 函式來改進功能並簡化流程。 AI 功能可與畫布應用程式:AI Builder和低代碼外掛程式搭配使用,因此可以輕鬆地將它們整合到您的解決方案中。

  • AIClassify 將文字分類為其中一個提供的類別。 例如,以下類別清單可用於對客戶提交的問題進行分類:

    • 問題回報
    • 帳單
    • 作法
    • 授權
  • AIExtract 擷取指定的實體,例如註冊號碼、電話號碼或人員名稱。

    注意

    該 AIExtract 功能仍在開發中,可能無法正常運作。 當備註可供使用時,我們會將其刪除。

  • AIReply 起草您提供的訊息的回覆。 例如,此函式會針對客戶的產品評論草擬回覆。

  • AISentiment 偵測您提供的文字情緒。 例如,此函式彙偵測客戶評論的情緒是正面、負面還是中性。

  • AISummarize 摘要您提供的文字。 例如,此函式可彙總電子郵件訊息或文件中的文字。

    • AISummarizeRecord 摘要記錄中的資訊。 例如,此函式會根據 Customers 資料表中的記錄來摘要客戶的資訊。
  • AITranslate 翻譯另一種語言的文字。 例如,此函式會翻譯客戶電子郵件或產品評論。 不需要指定來源語言,系統會自動偵測。

    如需有關來源語言和目標語言所支援語言的更多資訊,請參閱翻譯工具語言支援 - 翻譯,然後查看自動語言偵測欄下的支援語言清單。

在以下影片中深入了解如何使用 AI 函式。

必要條件

有關先決條件的更多資訊,請參閱 預構建提示的要求和許可。

在畫布應用程式中使用

您可以從畫布應用程式呼叫這些函式。 但是,它比其他 Power Fx 主機所描述的要複雜一些:

  1. 您需要新增環境資料來源。
  2. AI 函式是環境命名空間中的函式。 例如,本文件說明呼叫 AISummarize( ... ) 時,您需要使用 Environment。AISummarize( ... )
  3. 函式的引數必須是記錄中的命名資料行,作為唯一的參數傳遞。 資料行的名稱在語法區段中給出,與參數的名稱相符。
  4. 這些函式的傳回值都是包含一筆資料行的記錄。 資料行的名稱列在語法區段中。
  5. 這些函式是行為函式,無法在 Canvas 資料流程中使用,例如作為 Text 控制項 Text 屬性的輸入。 使用 Set 函式將結果放在全域變數中,然後在應用程式中的其他位置使用該值。

以下是範例:

  1. Power Apps Studio 開啟畫布應用程式以進行編輯。
  2. 從「資料」窗格中,選擇新增資料,然後新增環境資料來源。
  3. 在插入窗格新增 Button 控制項。
  4. 在資料編輯列中,選取 OnSelect 屬性,並輸入以下公式:
    Set( Summary, Environment.AISummarize( {Text: "2, 4, 6, 8, 10, 12, 14, 16"} ).SummarizedText )
    
  5. 在插入窗格新增 Text 控制項。
  6. 在資料編輯列中,選取 Text 屬性,並輸入以下公式:
    Summary
    
  7. 此文字方塊會顯示 AI 產生的摘要,類似於:
    The given text is a sequence of even numbers from 2 to 16, increasing by 2 each time.
    

注意

我們正在新增其他 Power Fx 主機喜歡的相同函式簽章。 新簽名增強而不是取代當前機制;使用當前機制的應用程序將繼續運行,無需修改。

語法

AIClassify正文分類

  • Text - 必填。 文字句子。 要分類的文字。
  • Categories- 必需。 單一資料行文字類別表。
  • 畫布應用程式 - 傳回值位於 [分類] 資料行中。

AIExtract文本實體

  • Text - 必填。 文字句子。 要從中提取資料的文字。
  • Entity - 必需。 要提取的實體。 要提取之實體的名稱。
  • 畫布應用程式 - 傳回值位於 ExtractedData 資料行中,這是符合所提供實體的零或多個資料列的資料表。

AIReply正文

  • Text - 必填。 文字句子。 要回應的文字。
  • 畫布應用程式 - 傳回值位於 PreparedResponse 資料行中。

AISentiment正文

  • Text - 必填。 要分析情感的文字。
  • 畫布應用程式 - 傳回值位於 AnalyzedSentiment 資料行中,且為「正」、「中性」或「負」。

AISummarize正文

  • Text - 必填。 要摘要的文字。
  • 畫布應用程式 - 傳回值位於 SummarizedText 資料行中。

AISummarizeRecord實體

  • Entity - 必需。 要摘要的 Dataverse 記錄。
  • 畫布應用程式 - 傳回值位於 SummarizedText 資料行中。

AITranslate文字目標語言

  • Text - 必填。 要翻譯的文字。
  • TargetLanguage - 要翻譯成的語言標籤,例如法語的“fr”。 請參閱 Language 函式以了解詳細資料。
  • 畫布應用程式 - 傳回值位於 TranslatedText 資料行中。

範例

若要設定下列範例:

  1. 在樹狀結構檢視中,選取應用程式物件並將以下內容新增到 Formulas 屬性:
    Subject = "Washington is a state that offers a variety of food experiences for locals and visitors alike. 
    Whether you are looking for fresh seafood, farm-to-table produce, ethnic specialties, or gourmet treats, 
    you will find something to satisfy your taste buds in Washington. Washington is famous for its seafood, 
    especially salmon, oysters, crab, and clams. The state has a long coastline and numerous rivers and lakes 
    that provide abundant and high-quality seafood.";
    
  2. 建立 Button 控制項。
  3. 建立 Text 控制項,並將其 Text 屬性設為:
    Result
    

AIClassify

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AIClassify( {Text:Subject, Categories: ["Housing", "Food"]} ).Classification )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AIClassify( Subject, ["Housing", "Food"] ) )
    
  2. 請按此按鈕。 Text 控制項顯示結果:
    Food
    

AIExtract

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AIExtract( {Text:Subject, Entity: "State"} ).ExtractedText )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AIExtract( Subject, "State" ) )
    
  2. 請按此按鈕。 Text 控制項顯示結果。

AIReply

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AIReply( {Text:Subject} ).PreparedResponse )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AIReply( Subject ) )
    
  2. 請按此按鈕。 Text 控制項會顯示類似以下的結果:
    Washington state is indeed a culinary delight, offering a diverse range of food experiences
    for both residents and tourists. From fresh seafood to farm-to-table produce, ethnic specialties
    to gourmet treats, there is something to please every palate in Washington. The state is
    particularly renowned for its seafood, with salmon, oysters, crab, and clams being local favorites.
    This is due to Washington's extensive coastline and numerous rivers and lakes, which provide an
    abundance of high-quality seafood. If you have any specific questions or need recommendations
    for dining in Washington, feel free to ask!
    

AISummarize

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AISummarize( {Text:Subject} ).SummarizedText )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AISummarize( Subject ) )
    
  2. 請按此按鈕。 Text 控制項會顯示類似以下的結果:
    Washington state is known for its diverse food experiences, catering to both locals and visitors.
    From fresh seafood to farm-to-table produce, ethnic specialties, and gourmet treats, there is
    something to please everyone's taste buds. Seafood, particularly salmon, oysters, crab, and clams,
    is a highlight in Washington. With its extensive coastline, rivers, and lakes, the state offers
    an abundance of high-quality seafood options.
    

AISummarizeRecord

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AISummarizeRecord( First(Accounts) ).SummarizedText )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AISummarizeRecord( First(Accounts) ) )
    
  2. 請按此按鈕。 Text 控制項會顯示類似以下的結果:
    The record provided was created on July 2, 2024, at 17:24:32 in the selected time zone. 
    The account number for this record is ACC0001, associated with the company
    [USMF](pagetype=entityrecord&etn=cdm_company&id=bdcdb6ff-7[204-4345](tel:2044345)-b46f-9545195385fd).
    The record was last modified on July 2, 2024, at 17:24:32 in the selected time zone.
    
    
    

AISentiment

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AISentiment( {Text:Subject} ).AnalyzedSentiment )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AISentiment( Subject ) )
    
  2. 請按此按鈕。 Text 控制項顯示結果:
    Positive
    

AITranslate

  1. 在畫布應用程式中,將 Button 控制項的 OnSelect 屬性設定為:
    Set( Result, Environment.AITranslate( {Text:Subject, TargetLanguage: "fr"} ).TranslatedText )
    
    對於所有其他產品,請使用以下公式:
    Set( Result, AITranslate( Subject, "fr" ) )
    
  2. 請按此按鈕。 Text 控制項會顯示類似以下的結果:
    Washington est un État qui offre une variété d’expériences culinaires pour les habitants et les visiteurs. 
    Que vous soyez à la recherche de fruits de mer frais, de produits de la ferme à la table,
    de spécialités ethniques ou de friandises gastronomiques, vous trouverez de quoi satisfaire vos
    papilles à Washington. Washington est célèbre pour ses fruits de mer, en particulier le saumon, les huîtres,
    le crabe et les palourdes. L’État possède un long littoral et de nombreuses rivières et lacs 
    qui fournissent des fruits de mer abondants et de haute qualité.