This tutorial guides you through the process of automating the retrieval of the description of UiPath's Wikipedia article and then sending it to OpenAI’s Chat GPT to make it longer.
UiPathWikiPage – UiPath に関する Wikipedia の記事に表示される内容です。この画面では、記事の最初の段落を示す UiPathDescription 要素を作成します。
UI Automation サービスと Open API を使用し、以下のコードを使用して Wikipedia のランディング ページを開きます。
var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);
Attach および Get Text API を使用して、Wikipedia の記事から UiPath の説明を取得します。Attach API は [アプリケーション/ブラウザーを使用] アクティビティと同様に動作するため、既に開いているアプリケーション/ブラウザーにフォーカスして自動化できます。次のコードを使用します。
var uipathWikiPage = uiAutomation.Attach(ObjectRepository.Descriptors.UiPathWikiPage);var uipathWikiDescription = uipathWikiPage.GetText(ObjectRepository.Descriptors.UiPathWikiPage.UiPathDescription);Log("This is the UiPath's wikipedia description: "+ uipathWikiDescription);var uipathWikiPage = uiAutomation.Attach(ObjectRepository.Descriptors.UiPathWikiPage);
var uipathWikiDescription = uipathWikiPage.GetText(ObjectRepository.Descriptors.UiPathWikiPage.UiPathDescription);
Log("This is the UiPath's wikipedia description: " + uipathWikiDescription);
OpenAI のアカウントを使用して ChatGPT に説明を送信します
api という名前の変数を作成し、提供された API キーを使用してアクセスできる OpenAI アカウントを初期化します。以下の変数を使用します。
var api =newOpenAIAPI(OpenAiApiKey);var api = new OpenAIAPI(OpenAiApiKey);
var chatResult = api.Chat.CreateChatCompletionAsync("Please rewrite the following description about UiPath: '"+ uipathWikiDescription +"', and make it longer").Result;var chatResult = api.Chat.CreateChatCompletionAsync("Please rewrite the following description about UiPath: '" + uipathWikiDescription + "', and make it longer").Result;