Skip to content

Commit

Permalink
Merge branch 'develop' into update-env-plugin-goat
Browse files Browse the repository at this point in the history
  • Loading branch information
monilpat authored Dec 24, 2024
2 parents e7deb53 + 8b23c3a commit 6878314
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,30 @@ export const generateImage = async (
});

const apiKey =
runtime.imageModelProvider === runtime.modelProvider
? runtime.token
: (runtime.getSetting("HEURIST_API_KEY") ??
runtime.getSetting("TOGETHER_API_KEY") ??
runtime.getSetting("FAL_API_KEY") ??
runtime.getSetting("OPENAI_API_KEY") ??
runtime.getSetting("VENICE_API_KEY"));

runtime.imageModelProvider === runtime.modelProvider
? runtime.token
: (() => {
// First try to match the specific provider
switch (runtime.imageModelProvider) {
case ModelProviderName.HEURIST:
return runtime.getSetting("HEURIST_API_KEY");
case ModelProviderName.TOGETHER:
return runtime.getSetting("TOGETHER_API_KEY");
case ModelProviderName.FAL:
return runtime.getSetting("FAL_API_KEY");
case ModelProviderName.OPENAI:
return runtime.getSetting("OPENAI_API_KEY");
case ModelProviderName.VENICE:
return runtime.getSetting("VENICE_API_KEY");
default:
// If no specific match, try the fallback chain
return (runtime.getSetting("HEURIST_API_KEY") ??
runtime.getSetting("TOGETHER_API_KEY") ??
runtime.getSetting("FAL_API_KEY") ??
runtime.getSetting("OPENAI_API_KEY") ??
runtime.getSetting("VENICE_API_KEY"));
}
})();
try {
if (runtime.imageModelProvider === ModelProviderName.HEURIST) {
const response = await fetch(
Expand Down

0 comments on commit 6878314

Please sign in to comment.