-
Notifications
You must be signed in to change notification settings - Fork 609
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
Ldelalande/model settings #651
Merged
Merged
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dc8525d
basic more models page
lily-de 1a25773
make the back button a component; change add models dialog button black
lily-de dc3065c
search autocomplete and toasts
lily-de b380783
fix search results background
lily-de 4100fc1
styling of search results
lily-de 022ab7d
make currently selected model globally available
lily-de eb45edc
start hardcoding real goose stuff
lily-de 81b64fa
detect state of currently set API keys
lily-de 5b6a1d8
filter search results by configured providers
lily-de 0a88e98
latest:
lily-de 56df3f7
add configure provider button
lily-de 9ab7d2d
add route to set model env
lily-de a8d77dc
most recently used models
lily-de b4d8ba8
sync model with global context upon initial startup or provider reset
lily-de c673f27
lint
lily-de 83cf21b
remove addModelsDialog; install accordion library
lily-de 63f0f58
bump react version back up
lily-de b91ec06
remove commented out toastContainer
lily-de 2013b47
get linter to recognize some types
lily-de File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
ui/desktop/src/components/settings/api_keys/ActiveKeysContext.tsx
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, {createContext, useContext, useState, ReactNode, useEffect} from "react"; | ||
import {getActiveProviders} from "./utils"; | ||
|
||
// Create a context for active keys | ||
const ActiveKeysContext = createContext<{ | ||
activeKeys: string[]; | ||
setActiveKeys: (keys: string[]) => void; | ||
} | undefined>(undefined); | ||
|
||
export const ActiveKeysProvider = ({ children }: { children: ReactNode }) => { | ||
const [activeKeys, setActiveKeys] = useState<string[]>([]); // Start with an empty list | ||
const [isLoading, setIsLoading] = useState(true); // Track loading state | ||
|
||
// Fetch active keys from the backend | ||
useEffect(() => { | ||
const fetchActiveProviders = async () => { | ||
try { | ||
const providers = await getActiveProviders(); // Fetch the active providers | ||
console.log("Fetched providers:", providers); | ||
setActiveKeys(providers); // Update state with fetched providers | ||
} catch (error) { | ||
console.error("Error fetching active providers:", error); | ||
} finally { | ||
setIsLoading(false); // Ensure loading is marked as complete | ||
} | ||
}; | ||
|
||
fetchActiveProviders(); // Call the async function | ||
}, []); | ||
|
||
// Provide active keys and ability to update them | ||
return ( | ||
<ActiveKeysContext.Provider value={{ activeKeys, setActiveKeys }}> | ||
{!isLoading ? children : <div>Loading...</div>} {/* Conditional rendering */} | ||
</ActiveKeysContext.Provider> | ||
); | ||
}; | ||
|
||
// Custom hook to access active keys | ||
export const useActiveKeys = () => { | ||
const context = useContext(ActiveKeysContext); | ||
if (!context) { | ||
throw new Error("useActiveKeys must be used within an ActiveKeysProvider"); | ||
} | ||
return context; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
payload.model.to_uppercase()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's provider pretty sure ... like
OPENAI_MODEL
,ANTHROPIC_MODEL
,DATABRICKS_MODEL
etcThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to work based on log statements!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I guess I was just confused by the surface level param mapping
We have
payload.model
andpayload.provider
but we set{}_MODEL
topayload.provider
Not a big deal though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah i see how that is confusing.. it's just to match what we are looking for in the backend when we set up an agent with a specific provider -- eg here's where we set up anthropic with a model or default to sonnet