IMPORTANT: Don't miss our expanded TechEd conference, October 23-24, 2024 in Las Vegas. Gain more in-depth technical knowledge, and take a deeper dive into the nuts and bolts of AI, automation, and the UiPath platform. Register now.
从 Wikipedia 检索需要自动化的用户界面元素。转到“对象存储库”选项卡,然后创建一个名为 Wikipedia 的应用程序。
为 Wikipedia 应用程序创建两个界面:
WikiMainScreen – 您执行搜索的登陆页面。为此界面创建两个元素:
搜索栏
搜索按钮
UiPathWikiPage – 生成的有关 UiPath 的 Wikipedia 文章。在此界面中,创建“UiPath 描述”元素,该元素指示文章中的第一段。
通过以下代码,使用 UIAutomation 服务和 Open API 打开 Wikipedia 登录页面:
var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);var wikiScreen= uiAutomation.Open(ObjectRepository.Descriptors.WikiMainScreen);
使用 Attach 和 Get TextAPI 从 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;