forked from stackblitz/bolt.new
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix: error building my application #1414 * fix for vite * Update vite.config.ts * Update root.tsx * fix the root.tsx and the debugtab * lm studio fix and fix for the api key * Update api.enhancer for prompt enhancement * bugfixes * Revert api.enhancer.ts back to original code * Update api.enhancer.ts * Update api.git-proxy.$.ts * Update api.git-proxy.$.ts * Update api.enhancer.ts
- Loading branch information
1 parent
7045646
commit 332edd3
Showing
18 changed files
with
371 additions
and
801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
import type { LoaderFunction } from '@remix-run/cloudflare'; | ||
import { providerBaseUrlEnvKeys } from '~/utils/constants'; | ||
import { LLMManager } from '~/lib/modules/llm/manager'; | ||
import { getApiKeysFromCookie } from '~/lib/api/cookies'; | ||
|
||
export const loader: LoaderFunction = async ({ context, request }) => { | ||
const url = new URL(request.url); | ||
const provider = url.searchParams.get('provider'); | ||
|
||
if (!provider || !providerBaseUrlEnvKeys[provider].apiTokenKey) { | ||
if (!provider) { | ||
return Response.json({ isSet: false }); | ||
} | ||
|
||
const envVarName = providerBaseUrlEnvKeys[provider].apiTokenKey; | ||
const isSet = !!(process.env[envVarName] || (context?.cloudflare?.env as Record<string, any>)?.[envVarName]); | ||
const llmManager = LLMManager.getInstance(context?.cloudflare?.env as any); | ||
const providerInstance = llmManager.getProvider(provider); | ||
|
||
if (!providerInstance || !providerInstance.config.apiTokenKey) { | ||
return Response.json({ isSet: false }); | ||
} | ||
|
||
const envVarName = providerInstance.config.apiTokenKey; | ||
|
||
// Get API keys from cookie | ||
const cookieHeader = request.headers.get('Cookie'); | ||
const apiKeys = getApiKeysFromCookie(cookieHeader); | ||
|
||
/* | ||
* Check API key in order of precedence: | ||
* 1. Client-side API keys (from cookies) | ||
* 2. Server environment variables (from Cloudflare env) | ||
* 3. Process environment variables (from .env.local) | ||
* 4. LLMManager environment variables | ||
*/ | ||
const isSet = !!( | ||
apiKeys?.[provider] || | ||
(context?.cloudflare?.env as Record<string, any>)?.[envVarName] || | ||
process.env[envVarName] || | ||
llmManager.env[envVarName] | ||
); | ||
|
||
return Response.json({ isSet }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.