Knime + ChatGPT

Hello everyone, I am looking for some applications of Chat GPT with Knime. Does anyone know if there are any features/nodes that use it? Where could I read some about it?

Thank you.
Matteo

There are some GPT3 examples on the hub, but I haven’t seen any detailed articles yet.

5 Likes

Hi @iCFO and @matteobianchi11,

We included a new chapter about GPT-3 and KNIME in the latest version of the “Will They Blend” book. You can download the book for free here: Will They Blend? The Connector Collection | KNIME.

Enjoy!

Roberto

5 Likes

…As of yesterday, OpenAI has also released the API to call the model that powers ChatGPT.

You can very easily adapt the workflow that we created by doing minimal adjustments in the body request and JSON parsing. You also need to chance the URL in the POST Request to: https://api.openai.com/v1/chat/completions (you can find more details on OpenAI API doc).

The “Select Model” component in the workflow already allows you to select the latest models (the gpt-3.5-turbo family) without any workflow edits. :wink:

Happy KNIMEing!

Roberto

5 Likes

I revised the URL, selected the turbo model and got a 400 response. What else do I need to do?

Hi @rfeigel, you also need to edit the JSON request body in the part that in the workflow is called “prompt” and with gpt-3.5-turbo is called “messages”. Please check my screenshot above where I show that too.

For more information, I recommend checking the API documentation.

Best,
Roberto

3 Likes

I’ve tried to figure out the revisions you’ve suggested and read the OpenAI documentation and I’m still stuck. Could you please revise the workflow and repost. Thanks.

Hi @rfeigel, what are you exactly stuck with?

The screenshot and instructions I shared are literally all you need to edit to issue a successful request :slightly_smiling_face:. Maybe if you share your workflow I can point the issue and help better.

Best,
Roberto

1 Like

If its so easy why can’t you just post the correct configuration rather than running me around in circles?

Hi @rfeigel, here you go. The minimal set of nodes to issue a request to gpt-3.5-turbo and parse the JSON response. Easy, uh? :slight_smile:

From this very basic workflow, you can then build on top additional layers of customization, automation and beautification. Check the original workflow above to see how you can customize model selection, automate feeding message prompts, beautify and make the Data App interactive, etc.

Example_ChatGPT_request.knwf (22.2 KB)

Happy KNIMEing,
Roberto

5 Likes

Thanks for the workflow. The gpt-3.5-turbo model seems to work for simple deterministic questions like your example. If I ask it “Where is Tolland CT?” (my hometown) it wouldn’t provide an answer until I increased the temperature to 2. If I ask “Is Python a good language to learn?” it won’t answer at all. The davinci-3 model readily provided a very good answer. There may be other parameters I need to play with, but for now I’ll stick with the davinci model.

3 Likes

Hi @rfeigel - i had a similar problem and it turns out it’s the POST node that is causing the issue. If you play around with the error handling settings (e.g retry every 1 sec etc) you should force it answer any question. It is definitely worth it in my view as gpt 3.5 is one 10th of davinci price and is more powerful. Good luck!

2 Likes

Thanks @Add94. I’ve tried everything I can think of in the Post node and am still getting a “Read Timed Out” error.

Chatgpt showed me how to make a Knime flow with Knime, it is almost correct, but more training is needed.
BR,
Milad

What is your use case for using chat gpt in KNIME? just curious
br

No particular use case at the moment. Just interested in how it works.

Thanks to our KNIME Blog editor (@heather.fyson :star_struck:), we now have also a blog post that describes the workflow for ease of reading/sharing. Enjoy it!

:newspaper: You can read it here:

:pushpin: Workflow here:

Happy KNIMEing,
Roberto

8 Likes

It was a fun article to work on with @roberto_cadili and @aniloezer :grinning:

5 Likes

As a little weekend project, I’ve built a workflow that issues HTTP requests to the model that powers #ChatGPT and allows me to chat with my artificial assistant from KNIME Analytics Platform. :upside_down_face:

:pushpin: The workflow is available for free on the KNIME Community Hub: ChatGPT as a KNIME chat dashboard – KNIME Community Hub

Happy KNIMEing,
Roberto

10 Likes

Thank you Robert. I would not have been able to do that!

I still have a small improvement. The message does not support multi line input at the moment.

To make this possible I added a string manipulation (replace($user-message$, “\n”, “\n”)) in the chat dashboard, between node 1687 and node 1689.

3 Likes