Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sources/modules/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ export async function describeImage(imagePath: string) {
}

export async function gptRequest(systemPrompt: string, userPrompt: string) {
const headers = {
'Authorization': `Bearer ${keys.openai}`,
'Content-Type': 'application/json'
};
try {
const response = await axios.post("https://api.openai.com/v1/chat/completions", {
model: "gpt-4o",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt },
],
});
return response.data;
},{headers});
return response.data.choices[0].message.content;
} catch (error) {
console.error("Error in gptRequest:", error);
return null; // or handle error differently
Expand All @@ -106,4 +110,4 @@ console.info(gptRequest(
,
'where is the person?'

))
))