AIClassify、AIExtract、AIReply、AISentiment、AISummarize 和 AITranslate

適用於:畫布應用程式

描述

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

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

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

    注意

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

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

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

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

  • AITranslate 可翻譯另一種語言的文字。 例如,此函式會翻譯客戶電子郵件或產品評論。 不需要指定來源語言,系統會自動偵測。

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

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

在畫布應用程式中使用

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

  1. 您需要新增環境資料來源。
  2. AI 函式是環境命名空間中的函式。 例如,在本文件描述呼叫 AISummarize( ... ) 的地方,您需要使用 Environment.AISummarize( ... )
  3. 函式的引數必須是記錄中的命名資料行,作為唯一的參數傳遞。 資料行的名稱在語法區段中給出,與參數的名稱相符。
  4. 這些函式的傳回值都是包含一筆資料行的記錄。 資料行的名稱列在語法區段中。
  5. 這些函式是行為函式,不能在畫布資料流程中使用,例如作為 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 )

  • Text - 必要項目。 文字句子。 要分類的文字。
  • 類別 - 必填。 單一資料行文字類別表。
  • 對於畫布應用程式,傳回值位於 Classification 資料行中。

AIExtract( Text, Entity )

  • Text - 必要項目。 文字句子。 要從中提取資料的文字。
  • 實體 - 必填。 要提取的實體。 要提取之實體的名稱。
  • 對於畫布應用程式,傳回值位於 ExtractedData 資料行,該表包含與所提供實體相符的零行或多列資料。

AIReply( Text )

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

AISentiment( Text )

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

AISummarize( Text )

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

AITranslate(Text, TargetLanguage)

  • 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.
    

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, Language: "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é.