Skip to content

Commit

Permalink
Merge pull request #837 from qgpcybs/main
Browse files Browse the repository at this point in the history
fix: load image from diff endpoints
  • Loading branch information
lalalune authored Dec 15, 2024
2 parents 7288fd0 + 4ce5f59 commit 026caf7
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/plugin-node/src/services/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,22 @@ export class ImageDescriptionService
},
];

const response = await fetch(
"https://api.openai.com/v1/chat/completions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.runtime.getSetting("OPENAI_API_KEY")}`,
},
body: JSON.stringify({
model: "gpt-4o-mini",
messages: [{ role: "user", content }],
max_tokens: isGif ? 500 : 300,
}),
}
);
const endpoint =
models[this.runtime.imageModelProvider].endpoint ??
"https://api.openai.com/v1";

const response = await fetch(endpoint + "/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.runtime.getSetting("OPENAI_API_KEY")}`,
},
body: JSON.stringify({
model: "gpt-4o-mini",
messages: [{ role: "user", content }],
max_tokens: isGif ? 500 : 300,
}),
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down

0 comments on commit 026caf7

Please sign in to comment.