Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
β’
d0daba2
1
Parent(s):
144c52f
make sure we don't call providers in case of missing api key
Browse files
src/app/engine/render.ts
CHANGED
@@ -187,7 +187,7 @@ export async function newRender({
|
|
187 |
segments: []
|
188 |
} as RenderedScene
|
189 |
} else if (renderingEngine === "REPLICATE") {
|
190 |
-
if (!replicateApiKey) {
|
191 |
throw new Error(`invalid replicateApiKey, you need to configure your REPLICATE_API_TOKEN in order to use the REPLICATE rendering engine`)
|
192 |
}
|
193 |
if (!replicateApiModel) {
|
|
|
187 |
segments: []
|
188 |
} as RenderedScene
|
189 |
} else if (renderingEngine === "REPLICATE") {
|
190 |
+
if (!replicateApiKey || `${replicateApiKey || ""}`.length < 8) {
|
191 |
throw new Error(`invalid replicateApiKey, you need to configure your REPLICATE_API_TOKEN in order to use the REPLICATE rendering engine`)
|
192 |
}
|
193 |
if (!replicateApiModel) {
|
src/app/queries/predictWithAnthropic.ts
CHANGED
@@ -20,6 +20,7 @@ export async function predict({
|
|
20 |
process.env.LLM_ANTHROPIC_API_MODEL ||
|
21 |
"claude-3-opus-20240229"
|
22 |
}`
|
|
|
23 |
|
24 |
const anthropic = new Anthropic({
|
25 |
apiKey: anthropicApiKey,
|
|
|
20 |
process.env.LLM_ANTHROPIC_API_MODEL ||
|
21 |
"claude-3-opus-20240229"
|
22 |
}`
|
23 |
+
if (!anthropicApiKey) { throw new Error(`cannot call Anthropic without an API key`) }
|
24 |
|
25 |
const anthropic = new Anthropic({
|
26 |
apiKey: anthropicApiKey,
|
src/app/queries/predictWithGroq.ts
CHANGED
@@ -20,6 +20,8 @@ export async function predict({
|
|
20 |
"mixtral-8x7b-32768"
|
21 |
}`
|
22 |
|
|
|
|
|
23 |
const groq = new Groq({
|
24 |
apiKey: groqApiKey,
|
25 |
})
|
|
|
20 |
"mixtral-8x7b-32768"
|
21 |
}`
|
22 |
|
23 |
+
if (!groqApiKey) { throw new Error(`cannot call Groq without an API key`) }
|
24 |
+
|
25 |
const groq = new Groq({
|
26 |
apiKey: groqApiKey,
|
27 |
})
|
src/app/queries/predictWithOpenAI.ts
CHANGED
@@ -21,6 +21,9 @@ export async function predict({
|
|
21 |
"gpt-4-turbo"
|
22 |
}`
|
23 |
|
|
|
|
|
|
|
24 |
const openaiApiBaseUrl = `${process.env.LLM_OPENAI_API_BASE_URL || "https://api.openai.com/v1"}`
|
25 |
|
26 |
const openai = new OpenAI({
|
|
|
21 |
"gpt-4-turbo"
|
22 |
}`
|
23 |
|
24 |
+
if (!openaiApiKey) { throw new Error(`cannot call OpenAI without an API key`) }
|
25 |
+
|
26 |
+
|
27 |
const openaiApiBaseUrl = `${process.env.LLM_OPENAI_API_BASE_URL || "https://api.openai.com/v1"}`
|
28 |
|
29 |
const openai = new OpenAI({
|