Self-hosted dashboard and admin auth (#4837)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
co-authored by
kartik-mem0
parent
15feaa8ac4
commit
db8ac61713
@@ -0,0 +1,47 @@
|
||||
type ProviderConfig = {
|
||||
provider?: string;
|
||||
config?: {
|
||||
model?: string;
|
||||
api_key?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type EffectiveConfig = {
|
||||
llm?: ProviderConfig;
|
||||
embedder?: ProviderConfig;
|
||||
};
|
||||
|
||||
export const getEffectiveConfig = (data: unknown): EffectiveConfig | null => {
|
||||
if (!data || typeof data !== "object") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const record = data as Record<string, unknown>;
|
||||
return (
|
||||
(record.effective_config as EffectiveConfig) ||
|
||||
(record.config as EffectiveConfig) ||
|
||||
(record as EffectiveConfig)
|
||||
);
|
||||
};
|
||||
|
||||
export const buildProviderConfig = ({
|
||||
provider,
|
||||
model,
|
||||
apiKey,
|
||||
}: {
|
||||
provider: string;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
}) => {
|
||||
if (!provider) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
provider,
|
||||
config: {
|
||||
model: model || undefined,
|
||||
api_key: apiKey || undefined,
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user