mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
[app] Conditionally start goosed based on valid config (#550)
This commit is contained in:
@@ -64,7 +64,7 @@ export function ApiKeyWarning({ className }: ApiKeyWarningProps) {
|
||||
<Bird />
|
||||
</div>
|
||||
<div className="text-center space-y-4 max-w-2xl w-full">
|
||||
<h2 className="text-2xl font-semibold text-gray-800">API Key Required</h2>
|
||||
<h2 className="text-2xl font-semibold text-gray-800">Credentials Required</h2>
|
||||
<p className="text-gray-600 mb-4">
|
||||
To use Goose, you need to set environment variables for one of the following providers:
|
||||
</p>
|
||||
@@ -94,8 +94,7 @@ export function ApiKeyWarning({ className }: ApiKeyWarningProps) {
|
||||
</pre>
|
||||
</Collapsible>
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-500 mt-4">
|
||||
<p className="text-gray-600 mt-4">
|
||||
After setting these variables, restart Goose for the changes to take effect.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+17
-12
@@ -35,23 +35,20 @@ const parseArgs = () => {
|
||||
};
|
||||
|
||||
const checkApiCredentials = () => {
|
||||
|
||||
loadZshEnv(app.isPackaged);
|
||||
|
||||
//{env-macro-start}//
|
||||
const apiKeyProvidersValid =
|
||||
['openai', 'anthropic', 'google', 'groq', 'openrouter'].includes(process.env.GOOSE_PROVIDER__TYPE) &&
|
||||
process.env.GOOSE_PROVIDER__HOST &&
|
||||
process.env.GOOSE_PROVIDER__MODEL &&
|
||||
process.env.GOOSE_PROVIDER__API_KEY;
|
||||
|
||||
['openai', 'anthropic', 'google', 'groq', 'openrouter'].includes(process.env.GOOSE_PROVIDER__TYPE) &&
|
||||
process.env.GOOSE_PROVIDER__HOST &&
|
||||
process.env.GOOSE_PROVIDER__MODEL &&
|
||||
process.env.GOOSE_PROVIDER__API_KEY;
|
||||
|
||||
const optionalApiKeyProvidersValid =
|
||||
['ollama', 'databricks'].includes(process.env.GOOSE_PROVIDER__TYPE) &&
|
||||
process.env.GOOSE_PROVIDER__HOST &&
|
||||
process.env.GOOSE_PROVIDER__MODEL;
|
||||
process.env.GOOSE_PROVIDER__HOST &&
|
||||
process.env.GOOSE_PROVIDER__MODEL;
|
||||
|
||||
return apiKeyProvidersValid|| optionalApiKeyProvidersValid;
|
||||
//{env-macro-end}//
|
||||
return apiKeyProvidersValid || optionalApiKeyProvidersValid;
|
||||
};
|
||||
|
||||
const generateSecretKey = () => {
|
||||
@@ -119,7 +116,15 @@ const createChat = async (app, query?: string, dir?: string) => {
|
||||
// Apply current environment settings before creating chat
|
||||
updateEnvironmentVariables(envToggles);
|
||||
|
||||
const [port, working_dir] = await startGoosed(app, dir);
|
||||
const maybeStartGoosed = async () => {
|
||||
if (checkApiCredentials()) {
|
||||
return startGoosed(app, dir);
|
||||
} else {
|
||||
return [0, ''];
|
||||
}
|
||||
}
|
||||
|
||||
const [port, working_dir] = await maybeStartGoosed();
|
||||
const mainWindow = new BrowserWindow({
|
||||
titleBarStyle: 'hidden',
|
||||
trafficLightPosition: { x: 16, y: 10 },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'node:path';
|
||||
import Electron from 'electron';
|
||||
|
||||
export const getBinaryPath = (app: Electron.App, binaryName: string): string => {
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
Reference in New Issue
Block a user