How to integrate ChatGPT into UiPath using HTTP request

How to integrate ChatGPT into UiPath using HTTP request

Hello Folks,

It is probable that you've heard about ChatGPT and have experienced its capabilities. ChatGPT represents a groundbreaking AI technology that facilitates natural communication with an intelligent chatbot

What tasks can ChatGPT perform?

ChatGPT is a large language model that can perform a wide range of natural language processing tasks, such as:

  • Generating human-like text, including writing essays, stories, articles, and more.
  • Answering questions, providing explanations, and summarizing information.
  • Translating text from one language to another.
  • Generating text in response to user input, such as in a chatbot or virtual assistant application.
  • Creating new content based on a given prompt or topic.
  • And many other tasks that involve understanding and generating natural language text.

A fun fact is that I used ChatGPT to generate its own capabilities.??

Steps to integrate ChatGPT into UiPath:

  1. Generate your personal API Key by clicking below. ??

No alt text provided for this image
Generate API Keys

2. Copy the secret key from the website and store it in a strAPIKey variable.

No alt text provided for this image

3. Add an input dialog activity and store the question in the strQuestion variable.

No alt text provided for this image
Input dailog box

4. Take HTTP Request activity (If the HTTP Request activity is not present in the activities panel, install the WEBAPI package from the manage packages.) and set the motioned values below.

End Point: https://api.openai.com/v1/engines/davinci/completions

Request Method: POST

Accept response as: JSON

Increase the timeout.

  • In the properties of HTTP Request activity under the options headers option is available

set this two parameters to it

Authorization: string.Format("Bearer {0}", strAPIkey)

Content-type: "application/json"

No alt text provided for this image
refer this image to set headers
No alt text provided for this image
Build HTTP Request

5. To build a body for our request just take a invoke code activity do the following steps:

  1. Select language CSharp.
  2. Create a body in invoke code.

No alt text provided for this image
Build Json Body Format in Invoke Code
out_JsonBody= @"
" + "\n" +
? ? ? @"""model"": """",
" + "\n" +
? ? ? @"""prompt"": ""Q: "? + in_strQuestion + @"?\nA:"",
" + "\n" +
? ? ? @"""temperature"": 0,
" + "\n" +
? ? ? @"""max_tokens"": 1000,
" + "\n" +
? ? ? @"""top_p"": 1,
" + "\n" +
? ? ? @"""frequency_penalty"": 0.0,
" + "\n" +
? ? ? @"""presence_penalty"": 0.0,
" + "\n" +
? ? ? @"""stop"" :""\n""
" + "\n" +
? ? ? @"}";        

3. Set the arguments for invoke code.

No alt text provided for this image
Invoke Code Arguments

4. Assign JsonBody variable to Body of the HTTP Request.

5. Assign a strResponce variable to Response Content.

6. Desacralize the JSON using Desacralize JSON activity and store the output in strOutputJson variable.

7. Create a string variable strAnswer to store your answer and assign value to it mentioned below:

No alt text provided for this image
value to assigned strAnswer variable

8. Take a message box activity and format your output like mentioned below:

No alt text provided for this image
Format the message box

9. Debug your process.

10. Just ask your question to ChatGPT and it will provide you an answer.

No alt text provided for this image
Ask Question
No alt text provided for this image
Answer Message Box

11. This is how we get the exact answer from ChatGPT using above automation workflow.

This is how it is done, so using this approach RPA Developers can leverage #ChatGPT into their automation workflows.

I hope this this article helped you and readers can input their feedbacks as their is always a scope of improvisation.

Thank You.

Gaurav Pandey

Actively looking for oppurtunities || UiPath SDC'22 || SIH finalist 2022 || Vice-president Rotaract || Open Source || Greed to learn mode is on || JAVA is cool || learning

2 年

It was some nice explanation, would definately try this out ??

Rupesh Sagar Betha

UiPath Technical Architect | Experienced in RPA large scale implementations | AI/ML Engineer | AWS Solution Architect | Power Automate Developer |

2 年

Great Pradeep Wani

Alexej M. Vondra, MBA

★ Strategic-Minded MBA ★ Certified Sales Operations Specialist ★ Business Intelligence Professional ★ Problem-Solving Expert ★ Proven Track Record of Success

2 年

Great Job UniPath! ??

Francou K

Software Engineer- Microsoft Power Platform, Oracle Apex, Robotics Process Automation, AWS, ML

2 年

A great tutorial on calling APIs with UiPath. But what is the application of calling ChatGPT with RPA in real world? I can as well type my question on the web User interface of ChatGPT.

要查看或添加评论,请登录

Pradeep Wani的更多文章

社区洞察

其他会员也浏览了