Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix it to use env vars if available #1063

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/goose-cli/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn setup_profile(temp_dir_path: &Path, profile_string: Option<&str>) {
"profile_items": {
"default": {
"provider": "databricks",
"model": "claude-3-5-sonnet-2",
"model": "goose",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"claude-3-5-sonnet-2" is not a generic name, so may as well make it use an alias as that is what it is in databricks anyway

"additional_extensions": []
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/goose-server/src/routes/providers_and_keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"databricks": {
"name": "Databricks",
"description": "Connect to LLMs via Databricks",
"models": ["claude-3-5-sonnet-2"],
"models": ["goose"],
"required_keys": ["DATABRICKS_HOST"]
},
"google": {
Expand Down
8 changes: 8 additions & 0 deletions ui/desktop/src/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { Card } from './components/ui/card';
import { ScrollArea, ScrollAreaHandle } from './components/ui/scroll-area';
import UserMessage from './components/UserMessage';
import WingToWing, { Working } from './components/WingToWing';

Check warning on line 13 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'WingToWing' is defined but never used. Allowed unused vars must match /^_/u
import { askAi } from './utils/askAI';
import { getStoredModel, Provider } from './utils/providerUtils';
import { ChatLayout } from './components/chat_window/ChatLayout';
Expand Down Expand Up @@ -108,7 +108,7 @@
useEffect(() => {
const updatedChats = chats.map((c) => (c.id === selectedChatId ? { ...c, messages } : c));
setChats(updatedChats);
}, [messages, selectedChatId]);

Check warning on line 111 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

React Hook useEffect has missing dependencies: 'chats' and 'setChats'. Either include them or remove the dependency array. If 'setChats' changes too often, find the parent component that defines it and wrap that definition in useCallback

const initialQueryAppended = useRef(false);
useEffect(() => {
Expand All @@ -116,7 +116,7 @@
append({ role: 'user', content: initialQuery });
initialQueryAppended.current = true;
}
}, [initialQuery]);

Check warning on line 119 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

React Hook useEffect has a missing dependency: 'append'. Either include it or remove the dependency array

useEffect(() => {
if (messages.length > 0) {
Expand Down Expand Up @@ -272,7 +272,7 @@
const openNewChatWindow = () => {
window.electron.createChatWindow();
};
const { switchModel, currentModel } = useModel(); // Access switchModel via useModel

Check warning on line 275 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'currentModel' is assigned a value but never used. Allowed unused vars must match /^_/u
const { addRecentModel } = useRecentModels(); // Access addRecentModel from useRecentModels

// Add keyboard shortcut handler
Expand Down Expand Up @@ -311,13 +311,13 @@

const [selectedChatId, setSelectedChatId] = useState(1);
const [mode, setMode] = useState<'expanded' | 'compact'>(initialQuery ? 'compact' : 'expanded');
const [working, setWorking] = useState<Working>(Working.Idle);

Check warning on line 314 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'working' is assigned a value but never used. Allowed unused vars must match /^_/u
const [progressMessage, setProgressMessage] = useState<string>('');

Check warning on line 315 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'progressMessage' is assigned a value but never used. Allowed unused vars must match /^_/u
const [selectedProvider, setSelectedProvider] = useState<string | Provider | null>(null);

Check warning on line 316 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'selectedProvider' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 316 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'setSelectedProvider' is assigned a value but never used. Allowed unused vars must match /^_/u
const [showWelcomeModal, setShowWelcomeModal] = useState(true);

// Add this useEffect to track changes and update welcome state
const toggleMode = () => {

Check warning on line 320 in ui/desktop/src/ChatWindow.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'toggleMode' is assigned a value but never used. Allowed unused vars must match /^_/u
const newMode = mode === 'expanded' ? 'compact' : 'expanded';
console.log(`Toggle to ${newMode}`);
setMode(newMode);
Expand Down Expand Up @@ -363,6 +363,14 @@
useEffect(() => {
const setupStoredProvider = async () => {
const config = window.electron.getConfig();

if (config.GOOSE_PROVIDER && config.GOOSE_MODEL) {
window.electron.logInfo(
'Initializing system with environment: GOOSE_MODEL and GOOSE_PROVIDER as priority.'
);
await initializeSystem(config.GOOSE_PROVIDER, config.GOOSE_MODEL);
return;
}
const storedProvider = getStoredProvider(config);
const storedModel = getStoredModel();
if (storedProvider) {
Expand Down
7 changes: 6 additions & 1 deletion ui/desktop/src/components/BottomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export default function BottomMenu({ hasMessages }) {
};
}, [isModelMenuOpen]);

let envModelProvider = null;
if (window.electron.getConfig().GOOSE_MODEL && window.electron.getConfig().GOOSE_PROVIDER) {
envModelProvider = `${window.electron.getConfig().GOOSE_MODEL} - ${window.electron.getConfig().GOOSE_PROVIDER}`;
}

return (
<div className="flex justify-between items-center text-textSubtle relative bg-bgSubtle border-t border-borderSubtle text-xs pl-4 h-[40px] pb-1 align-middle">
{/* Directory Chooser - Always visible */}
Expand All @@ -72,7 +77,7 @@ export default function BottomMenu({ hasMessages }) {
className="flex items-center cursor-pointer"
onClick={() => setIsModelMenuOpen(!isModelMenuOpen)}
>
<span>{currentModel?.name || 'Select Model'}</span>
<span>{envModelProvider || currentModel?.name || 'Select Model'}</span>
{isModelMenuOpen ? (
<ChevronDown className="w-4 h-4 ml-1" />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const azure_openai_models = ['gpt-4o'];
export const default_models = {
openai: 'gpt-4o',
anthropic: 'claude-3-5-sonnet-latest',
databricks: 'claude-3-5-sonnet-2',
databricks: 'goose',
google: 'gemini-2.0-flash-exp',
groq: 'llama-3.3-70b-versatile',
openrouter: 'anthropic/claude-3.5-sonnet',
Expand Down
7 changes: 5 additions & 2 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const getGooseProvider = () => {
//{env-macro-start}//
//needed when goose is bundled for a specific provider
//{env-macro-end}//
return process.env.GOOSE_PROVIDER;
return [process.env.GOOSE_PROVIDER, process.env.GOOSE_MODEL];
};

const generateSecretKey = () => {
Expand All @@ -83,8 +83,11 @@ const generateSecretKey = () => {
return key;
};

let [provider, model] = getGooseProvider();

let appConfig = {
GOOSE_PROVIDER: getGooseProvider(),
GOOSE_PROVIDER: provider,
GOOSE_MODEL: model,
GOOSE_API_HOST: 'http://127.0.0.1',
GOOSE_PORT: 0,
GOOSE_WORKING_DIR: '',
Expand Down
Loading