Hi Plasmic team, I have a question. Excuse me I’m a complete novice trying to figure things out.
I want to have a input box on a webpage, that is effectively the prompt for a ChatGPT assistant I have set up. In other words the text that the user inputs is simply sent to the CGPT assistant. I then want the response from the assistant to be passed back and displayed in a text box.
What steps are necessary to set up this integration?
Obviously there isn’t a native OpenAI integration but I see there is a Zapier integration. However when I go to the Zapier website to set up a ‘catch hook’ webhook, and I create the integration in Plasmic, it isn’t available to select as an integration.
Hi Yasir, the Zapier integration is currently considered a “write only” so you can’t invoke it in the data queries, but if you go the button on click you should be able to call zapier from there, maybe a simpler way to set it up the assistant would be through the HTTP Api with the Open AI Assistant docs https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages , this may require some initial work to set up the knowledge base file outside of the studio, so that you can programmatically use the assistants api
SO many questions!
• Have i set it up the integration correctly?
• The ‘message’ parameter in OpenAI looks like an array (with ‘role’ and ‘content’ as items in the array). How do I set that up correctly as parameters in the data query?
• I need to see the response from OpenAI - how do I display the response in a text box?
I’m thinking the the response from OpenAI needs to be sent to an input box rather than a text box - is that correct?
If so, I think it would make sense to create a second Data Query for the response, and the content should be displayed in the input box. Also the input box should be disabled to prevent user entry in the response box. On the right track?
• Have i set it up the integration correctly?
Yes, it looks mostly right, I think you are still setting up from the Data Queries section, which I don’t it’s the expected, Data Queries are expected to be read operations but per OpenAI docs https://platform.openai.com/docs/api-reference/threads/createThread you need to do a POST request, it’s exposed in Plasmic through some in the interactions section.
I am sending some screenshots that may help. Also we have an app tutorial available in the dashboard that may be helpful to understand a bit of those concepts.
• The ‘message’ parameter in OpenAI looks like an array (with ‘role’ and ‘content’ as items in the array). How do I set that up correctly as parameters in the data query?
By using the green bold icon on top right of the body, you can pass an arbitrary content, you also can just write JSON in the input and should still work out.
• I need to see the response from OpenAI - how do I display the response in a text box?
If you are doing the POST request once it’s finished you can use another interaction to pass the result into a state. Then display the state in the UI with dynamic binding.
I’m thinking the the response from OpenAI needs to be sent to an input box rather than a text box - is that correct?
This is actually independent, you can send the response to anyplace in the UI.
I will be looking into building a basic GPT example this week, that will make more clear this things.
If you are doing the POST request once it’s finished you can use another interaction to pass the result into a state. Then display the state in the UI with dynamic binding.
Is there a worked example that you can direct me to or a tutorial that would help me understand this?