jtawf
jtawf
WWasp-lang
Created by jtawf on 8/10/2023 in #đŸ™‹questions
using client-side env variables
Error Message: Cannot find module '@wasp/entities'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? Cannot find module 'react'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? Cannot find module '@aws-sdk/client-s3'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
18 replies
WWasp-lang
Created by jtawf on 8/10/2023 in #đŸ™‹questions
using client-side env variables
when i added the module flag it threw different errors about not being able to find other modules like react or @wasp/types
18 replies
WWasp-lang
Created by jtawf on 8/10/2023 in #đŸ™‹questions
using client-side env variables
for some reason it doesn't, i never modified ts.config either
18 replies
WWasp-lang
Created by jtawf on 8/10/2023 in #đŸ™‹questions
using client-side env variables
thanks @miho, do i have to change the module flag as mentioned (The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.) or will the fix include that?
18 replies
WWasp-lang
Created by jtawf on 8/10/2023 in #đŸ™‹questions
using client-side env variables
ok thanks!
18 replies
WWasp-lang
Created by jtawf on 7/27/2023 in #đŸ™‹questions
generateGptResponse error
hmm okay, just gave it a try and still not working, does a better look at the try-catch within the function help?
try {
if (!context.user.hasPaid && !context.user.credits) {
throw new HttpError(402, 'User has not paid or is out of credits');
} else if (context.user.credits && !context.user.hasPaid) {
console.log('decrementing credits');
await context.entities.User.update({
where: { id: context.user.id },
data: {
credits: {
decrement: 1,
},
},
});
}

console.log('fetching', payload);

const response = await fetch('https://api.openai.com/v1/chat/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.OPENAI_API_KEY!}`,
},
method: 'POST',
body: JSON.stringify(payload),
});

console.log(response);

const json = (await response.json()) as OpenAIResponse;

return context.entities.RelatedObject.create({
data: {
content: json?.choices[0].message.content,
user: { connect: { id: context.user.id } }
}
});

} catch (error: any) {

if (!context.user.hasPaid && error?.statusCode != 402) {
await context.entities.User.update({
where: { id: context.user.id },
data: { credits: { increment: 1 } }
});
}

console.error(error);

}

return new Promise((resolve, reject) => {
reject(new HttpError(500, 'Something went wrong'));
});

};
try {
if (!context.user.hasPaid && !context.user.credits) {
throw new HttpError(402, 'User has not paid or is out of credits');
} else if (context.user.credits && !context.user.hasPaid) {
console.log('decrementing credits');
await context.entities.User.update({
where: { id: context.user.id },
data: {
credits: {
decrement: 1,
},
},
});
}

console.log('fetching', payload);

const response = await fetch('https://api.openai.com/v1/chat/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.OPENAI_API_KEY!}`,
},
method: 'POST',
body: JSON.stringify(payload),
});

console.log(response);

const json = (await response.json()) as OpenAIResponse;

return context.entities.RelatedObject.create({
data: {
content: json?.choices[0].message.content,
user: { connect: { id: context.user.id } }
}
});

} catch (error: any) {

if (!context.user.hasPaid && error?.statusCode != 402) {
await context.entities.User.update({
where: { id: context.user.id },
data: { credits: { increment: 1 } }
});
}

console.error(error);

}

return new Promise((resolve, reject) => {
reject(new HttpError(500, 'Something went wrong'));
});

};
12 replies
WWasp-lang
Created by jtawf on 7/27/2023 in #đŸ™‹questions
generateGptResponse error
and logs are here as well
[Server] decrementing credits
[Server] fetching {
[Server] model: 'gpt-3.5-turbo',
[Server] messages: [
[Server] {
[Server] role: 'system',
[Server] content: 'You are a technical recruiter, view the provided document and provide a response according to the command: [object Object]'
[Server] },
[Server] { role: 'user', content: 'hello' }
[Server] ],
[Server] temperature: 1
[Server] }
[Server!] TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object
[Server!] at checkListener (node:events:266:3)
[Server!] at ClientRequest.once (node:events:647:3)
[Server!] at new ClientRequest (node:_http_client:245:10)
[Server!] at Object.request (node:https:360:10)
[Server] decrementing credits
[Server] fetching {
[Server] model: 'gpt-3.5-turbo',
[Server] messages: [
[Server] {
[Server] role: 'system',
[Server] content: 'You are a technical recruiter, view the provided document and provide a response according to the command: [object Object]'
[Server] },
[Server] { role: 'user', content: 'hello' }
[Server] ],
[Server] temperature: 1
[Server] }
[Server!] TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object
[Server!] at checkListener (node:events:266:3)
[Server!] at ClientRequest.once (node:events:647:3)
[Server!] at new ClientRequest (node:_http_client:245:10)
[Server!] at Object.request (node:https:360:10)
12 replies
WWasp-lang
Created by jtawf on 7/27/2023 in #đŸ™‹questions
generateGptResponse error
of course @Vinny (@Wasp)! Just for context here I verified that my open api key is being properly used and I'm receiving the 'fetching' log that details my payload then the errors occurs when fetching the response and I don't receive the log detailing my response
const payload = {
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: "You are a technical recruiter, view the provided document and provide a response according to the command: " + command,
},
{
role: 'user',
content: "hello",
},
],
temperature: 1,
};

try {
if (!context.user.hasPaid && !context.user.credits) {
throw new HttpError(402, 'User has not paid or is out of credits');
} else if (context.user.credits && !context.user.hasPaid) {
console.log('decrementing credits');
await context.entities.User.update({
where: { id: context.user.id },
data: {
credits: {
decrement: 1,
},
},
});
}

console.log('fetching', payload); //logs properly

const response = await fetch('https://api.openai.com/v1/chat/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.OPENAI_API_KEY!}`,
},
method: 'POST',
body: JSON.stringify(payload),
});

console.log(response); //does not log
const payload = {
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: "You are a technical recruiter, view the provided document and provide a response according to the command: " + command,
},
{
role: 'user',
content: "hello",
},
],
temperature: 1,
};

try {
if (!context.user.hasPaid && !context.user.credits) {
throw new HttpError(402, 'User has not paid or is out of credits');
} else if (context.user.credits && !context.user.hasPaid) {
console.log('decrementing credits');
await context.entities.User.update({
where: { id: context.user.id },
data: {
credits: {
decrement: 1,
},
},
});
}

console.log('fetching', payload); //logs properly

const response = await fetch('https://api.openai.com/v1/chat/completions', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.OPENAI_API_KEY!}`,
},
method: 'POST',
body: JSON.stringify(payload),
});

console.log(response); //does not log
12 replies
WWasp-lang
Created by jtawf on 7/27/2023 in #đŸ™‹questions
generateGptResponse error
hey guys sorry for the late reply, I'm using the saas pern template and the issue appears when making the call to the GPT api. I call the action through the front-end as well.
12 replies
WWasp-lang
Created by fossfighter on 5/8/2023 in #đŸ™‹questions
accessing env on client
hey hey, having the same issue but slightly different @Wasp Team. All my variables in env.server are prefixed with REACTAPP (besides SEND_EMAILS_IN_DEVELOPMENT, MAILGUN_API_KEY, MAILGUN_DOMAIN) and when I import.meta.env; client-side the issue I get is: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.
31 replies