#React App
59 messages · Page 1 of 1 (latest)
Nah, it would need to be wherever your node code is hosted. It doesn't seem to be there. Do you have something along the lines of:
app.post('/endpoint1', async (req, res) => {
res.set('Content-Type', 'application/json');
res.send(outputString);
in your code?
ah so that's all together with your code for the website? sorry I don't know how to make that work
I've usually split out that index file into it's own project and then used that as the backend
but they're both up on netlify
Dunno if it'd be helpful, but the project I've been working on automatically builds a proxy in next.js apps so you don't have to ship your OpenAI API key to the browser. 9 min coding screencast that shows it off here: https://www.loom.com/share/b367f4863fe843998270121131ae04d9
This coding screencast shows how we can use Imaginary Programming to easily add delightful, intelligent features to an existing web app by just defining function prototypes for the new features we want, without any implementation.
Find a live version of the site we describe here: https://blog-demo.imaginary.dev/
Find the code for the demo site ...
ill have a look
does not seem to load
is this post the same as that you mentioned...
that's the idea but only if that address goes to your node endpoint - which I'm not sure about
how can I confirm
The video isn't loading? That's very strange; it loads perfectly fine for me. There's also info at imaginary.dev and install info at imaginary.dev/docs
Ok so I watched it but I am not advanced enough to know how to use it with my app
its cool tho
I think this looks like client-side code that is calling a backend API, which presumably is calling GPT
Did you make a backend API?
Want to build your own ChatGPT or learn the advanced ways to use Chat GPT? This video will be a more advance tutorial about OpenAI and its AI models, how to do prompts, generate content, and finally build an application based on its API.
⭐ Try the OpenAI Template - Starter Kit I've made ⭐
https://enhanceui.gumroad.com/l/chatgpt-starter-template...
that is the tutorial I followed if u want to take a look
all I can say is that I made this index.js file
yep, that's a backend API!
it looks like you are calling the backend API on a server out on the internet called promptenhancer.xyz. Have you deployed your backend API there?
I used npm run build. then I moved the build file to my webhosting service which is netlify
thanks for the continued help by the way
is that the right way to do it
So, you should try POSTing something to that URL and seeing if you get a response to verify if it is working. You do have to set netlify up to use Netlify Functions if you want dynamic code to work
Though if it's a node.js project, that should work without much config
I'm a little confused if you are doing this locally or not. If you are developing locally, it makes more sense to go against the backend api running on your local machine so you can change the code and see the changes without redeploying
should I rather tell you what I wanted it to do as an end goal?
what I wanted to happen was, a user would open the website, type their prompt in and click a submit button. Then a output would pop up on the screen which has a longer version of their prompt(this being done with openai davinci-003.
im sorry I could probably explain/understand better on a call or something
I guess I dont want it to be local, I want users to open the website and talk to davinci without me having to run it
if that makes sense
So usually we develop and test websites locally so that we can rapidly change the code and see the differences that we make. Then when the code is in a state we like, we deploy it out to the world
So eventually, yes, you don't want the code to be running locally on your laptop, because no one can point a browser at your laptop
But while you are working on it, usually you want it to be on your machine. Then, when you like what you've built, you put it out into the world.
But you definitely need both a frontend and backend because of how OpenAI API keys work
ok so I like what ive built and I want it in the world
How do I do this please
this is what I want, to get it off of my local and on the webhost where it is deployed
Well, you have to test to see if what you did worked. If it worked, you should be able to POST information to the backend API endpoint that you deployed
Look up "how to POST json to an API endpoint" to see how to test if what you've deployed works
this is what I found const data = { message: 'Hello World!' };
fetch('https://example.com/api/endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Do I deploy that alone?
I deployed it and it says error404
chat gpt says if I want to change my endpoint I should use url instead of port
To change the endpoint to https://www.promptenhancer.xyz/, you just need to replace port with url in the app.listen() method, like this:
javascript
Copy code
app.listen(url, () => {
console.log(Example app listening)
});
Make sure that url variable is properly defined and holds the correct URL value.
Do you think we could get on a call to solve it. I believe that would be much quicker and I can explain better
I'm sorry, I can't really spend more time on this, gotta do my job 🙂 . I'd recommend reading up on deploying node backends; I suspect that something about your config is wrong