How to integrate ChatGPT in UiPath using the HTTP Request activity?

The zip file is in the tutorial at the bottom.
In the API_KEY assign activity add your created OpenAI API key.

Hi Marian, I ran into a problem when trying to use the Advanced tweet classifier. I used Postman for the code but the problem is in the retrieving part (see screenshot and error code). Could you help me?

Double-check my tutorial from start.

In the model I set empty.

image

You should have the same error in Postman, as this is an API call response from the OpenAI endpoint.

It does not give an error in Postman. But in UiPath I Keep getting the error: Assign: Object reference not set to an instance of an object.
At the last assign activity.

If you are using a different endpoint it is very possible that also the payload response to be different.

Compare my example with yours and adapt the last Assign activity based on your JsonObject value response that you need to extract.

That could definitely be the problem! I am not really familiar with these kind of adaptations, do you have any tips or a places where I can learn more about it?

Hi Marian - thanks for this detailed description - it took me 5 minutes to make this work in my workflow - this was an enormous timesaver and THANKS for SHARING!

1 Like

Hey all! Was playing with this solution, and found a way to overcome the problems that might happen when writing the Body on the HTTP request, using vb.net (Not C#):

Steps:

  1. Create a variable of type Dictionary (Of String,Object) and initialize it
  1. Fill the dictionary with all the values from the body

image

  1. Using the same config as the demo exercise (just changing to vb.net) serialize the dictionary as json with the following:
Newtonsoft.Json.JsonConvert.SerializeObject(dict_Body,Newtonsoft.Json.Formatting.Indented)

image

This provides a correct response, while having the same values written as string (with double quotes, or with Chr(34) was giving trouble.

Hope it helps!

1 Like

What did you do to solve the problem?

@Beere_Plays @marian.platonov

Hello, i downloaded the project its on C#, Windows, everything is the same but i face the same error. May I know how did you guys make it work?

Check the links from the start of the tutorial, especially the OpenAI API


Error Code 429 - You exceeded your current quota, please check your plan and billing details.

  • Check your current quota in your account settings here. You can see how many tokens your requests have consumed here.

  • If you are using a free plan, consider upgrading to a pay-as-you-go plan that offers a higher quota.

  • If you need a quota increase, you can apply for one here. We will review your request and get back to you as soon as possible.

1 Like

Hello,
I tried this solution but extracting the result only in one line but if we search manually the result is displaying in detailed.

Regards,
Shesherao Patil

Cannot understand your issue. Provide more details (screenshots, examples).

Hello

  • I asked question like What is UiPath on ChatGPT portal answer is long
  • In second SS using integration method see the msg box giving solution in one line only.

Thanks,
Shesherao Patil

Modify your payload, in the stop value, leave it empty, and increase the max_tokens value to let’s say 1000.

Example:

1 Like

That great, how can we increase it through UiPath HTTP request ?

Read the tutorial from the beginning and you will see that in step 5.

1 Like

This is one of the greatest articles written with regard activity based on your JsonObject value response that you need to extract.

1 Like