schnapsterdog / nuxt-chatgpt Goto Github PK
View Code? Open in Web Editor NEWChatGPT integration for Nuxt 3
Home Page: https://www.buymeacoffee.com/schnapsterdog
License: MIT License
ChatGPT integration for Nuxt 3
Home Page: https://www.buymeacoffee.com/schnapsterdog
License: MIT License
While routing all of the requests through the nitro server does a great job of keeping our API keys private, it also has a potentially unintended effect for some users.
If your intended Chat GPT user interface component is behind authentication (because who wants to expose unlimited use of your api key to the public?) the routes that are exposed with this module are always public.
I could be missing some intended configuration for this use-case, but as far as I can tell the routes /api/chat
and /api/chat-completion
are always exposed to the internet. Again, this could be intended functionality, I just wanted to make sure that this was not a bug. For my particular uses, I will have to remove this module for this reason.
Thank you for the great work and contribution nonetheless!
The docs state:
// entirely optional
chatgpt: {
apiKey: 'Your apiKey here goes here'
},
Wouldn't you want to reference the key within the runtimeConfig
property like so?
runtimeConfig: {
OPENAI_API_KEY: "" //<---- would be copied form an `.env` file
},
ChatGPT has the "stream" way to respond to the answer, how to do that?
This looks amazing! A couple of points to mention, in case you find it helpful:
You do not need to stringify the body of $fetch
requests, or set content-type
. This will be done automatically.
Because you set the public
key of runtimeConfig
, the user's API key is exposed to the client.
https://github.com/SchnapsterDog/nuxt-chatgpt/blob/master/src/module.ts#L50C5-L52. (You just need to update that same line to remove public
.)
Hi,
your project is awesome and it works great with almost no effort :)
Nevertheless I would suggest to change the interface of the chatCompletion function:
const chatCompletion = async (message: IMessage, model?: IModel, options?: IOptions)
to
const chatCompletion = async (messages: IMessages, model?: IModel, options?: IOptions)
or something similar :)
According to openAI API specification, chatCompletions can be configured with a set of messages:
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}],
});
This change would allow to implement easily use cases such as the "Socratic Tutor" https://platform.openai.com/examples/default-socratic-tutor.
All the best,
Mauro
Thank you for this plugin, i just have a question,
how to use this plugin with gpt-4 ?
Basically use the library by making a simple request according to their example.
Im not sure why iam getting this error do i need to pay or the free trial can be used?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.