* Added flows with new components * commented model provider assignment * Added agent component display name * commented provider assignment, assign provider on the generic component, assign custom values * fixed ollama not showing loading steps, fixed loading steps never being removed * made embedding and llm model optional on onboarding call * added isEmbedding handling on useModelSelection * added isEmbedding on onboarding card, separating embedding from non embedding card * Added one additional step to configure embeddings * Added embedding provider config * Changed settings.py to return if not embedding * Added editing fields to onboarding * updated onboarding and flows_service to change embedding and llm separately * updated templates that needs to be changed with provider values * updated flows with new components * Changed config manager to not have default models * Changed flows_service settings * Complete steps if not embedding * Add more onboarding steps * Removed one step from llm steps * Added Anthropic as a model for the language model on the frontend * Added anthropic models * Added anthropic support on Backend * Fixed provider health and validation * Format settings * Change anthropic logo * Changed button to not jump * Changed flows service to make anthropic work * Fixed some things * add embedding specific global variables * updated flows * fixed ingestion flow * Implemented anthropic on settings page * add embedding provider logo * updated backend to work with multiple provider config * update useUpdateSettings with new settings type * updated provider health banner to check for health with new api * changed queries and mutations to use new api * changed embedding model input to work with new api * Implemented provider based config on the frontend * update existing design * fixed settings configured * fixed provider health query to include health check for both the providers * Changed model-providers to show correctly the configured providers * Updated prompt * updated openrag agent * Fixed settings to allow editing providers and changing llm and embedding models * updated settings * changed lf ver * bump openrag version * added more steps * update settings to create the global variables * updated steps * updated default prompt --------- Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
71 lines
2 KiB
TypeScript
71 lines
2 KiB
TypeScript
import { useEffect } from "react";
|
|
import type { Dispatch, SetStateAction } from "react";
|
|
import type { OnboardingVariables } from "../../api/mutations/useOnboardingMutation";
|
|
|
|
interface ConfigValues {
|
|
apiKey?: string;
|
|
endpoint?: string;
|
|
projectId?: string;
|
|
languageModel?: string;
|
|
embeddingModel?: string;
|
|
}
|
|
|
|
export function useUpdateSettings(
|
|
provider: string,
|
|
config: ConfigValues,
|
|
setSettings: Dispatch<SetStateAction<OnboardingVariables>>,
|
|
isEmbedding?: boolean,
|
|
) {
|
|
useEffect(() => {
|
|
setSettings((prev) => {
|
|
const updatedSettings: OnboardingVariables = {
|
|
...prev,
|
|
embedding_model: config.embeddingModel || prev.embedding_model || "",
|
|
llm_model: config.languageModel || prev.llm_model || "",
|
|
};
|
|
|
|
// Set provider field based on whether this is for embedding or LLM
|
|
if (isEmbedding) {
|
|
updatedSettings.embedding_provider = provider;
|
|
} else {
|
|
updatedSettings.llm_provider = provider;
|
|
}
|
|
|
|
// Map provider-specific API keys
|
|
if (config.apiKey) {
|
|
if (provider === "openai") {
|
|
updatedSettings.openai_api_key = config.apiKey;
|
|
} else if (provider === "anthropic") {
|
|
updatedSettings.anthropic_api_key = config.apiKey;
|
|
} else if (provider === "watsonx") {
|
|
updatedSettings.watsonx_api_key = config.apiKey;
|
|
}
|
|
}
|
|
|
|
// Map provider-specific endpoints
|
|
if (config.endpoint) {
|
|
if (provider === "watsonx") {
|
|
updatedSettings.watsonx_endpoint = config.endpoint;
|
|
} else if (provider === "ollama") {
|
|
updatedSettings.ollama_endpoint = config.endpoint;
|
|
}
|
|
}
|
|
|
|
// Map project ID (WatsonX only)
|
|
if (config.projectId && provider === "watsonx") {
|
|
updatedSettings.watsonx_project_id = config.projectId;
|
|
}
|
|
|
|
return updatedSettings;
|
|
});
|
|
}, [
|
|
provider,
|
|
config.apiKey,
|
|
config.endpoint,
|
|
config.projectId,
|
|
config.languageModel,
|
|
config.embeddingModel,
|
|
setSettings,
|
|
isEmbedding,
|
|
]);
|
|
}
|