从 Wikipedia 检索需要自动化的用户界面元素。转到“对象存储库”选项卡,然后创建一个名为 Wikipedia 的应用程序。
为 Wikipedia 应用程序创建两个界面:
WikiMainScreen – 您执行搜索的登陆页面。为此界面创建两个元素:
搜索栏
搜索按钮
UiPathWikiPage – 生成的有关 UiPath 的 Wikipedia 文章。在此界面中,创建“UiPath 描述”元素,该元素指示文章中的第一段。
Use the UiAutomation service, along with the Open coded automation API, to open the Wikipedia landing page using the following code:
var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);
Get the description about UiPath from the Wikipedia article, using the Attach and Get Text coded automation APIs. The Attach coded automation API behaves similarly to the Use Application/Browser activity, allowing you to focus on an already open Application/Browser and automate it. Use the following code:
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;