feat(app): Introduce quality mode. Improve functionality of balanced mode using readability to get page content and pull relevant excerpts
feat(UI): Show progress during inferrence feat(security): Don't show API keys in the UI any more feat(models): Support Claude 4 Anthropic models
This commit is contained in:
parent
288120dc1d
commit
c47a630372
17 changed files with 2142 additions and 818 deletions
52
src/lib/utils/modelUtils.ts
Normal file
52
src/lib/utils/modelUtils.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
||||
|
||||
/**
|
||||
* Extract the model name from an LLM instance
|
||||
* Handles different LLM implementations that may store the model name in different properties
|
||||
* @param llm The LLM instance
|
||||
* @returns The model name or 'Unknown' if not found
|
||||
*/
|
||||
export function getModelName(llm: BaseChatModel): string {
|
||||
try {
|
||||
// @ts-ignore - Different LLM implementations have different properties
|
||||
if (llm.modelName) {
|
||||
// @ts-ignore
|
||||
return llm.modelName;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
if (llm._llm && llm._llm.modelName) {
|
||||
// @ts-ignore
|
||||
return llm._llm.modelName;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
if (llm.model && llm.model.modelName) {
|
||||
// @ts-ignore
|
||||
return llm.model.modelName;
|
||||
}
|
||||
|
||||
if ('model' in llm) {
|
||||
// @ts-ignore
|
||||
const model = llm.model;
|
||||
if (typeof model === 'string') {
|
||||
return model;
|
||||
}
|
||||
// @ts-ignore
|
||||
if (model && model.modelName) {
|
||||
// @ts-ignore
|
||||
return model.modelName;
|
||||
}
|
||||
}
|
||||
|
||||
if (llm.constructor && llm.constructor.name) {
|
||||
// Last resort: use the class name
|
||||
return llm.constructor.name;
|
||||
}
|
||||
|
||||
return 'Unknown';
|
||||
} catch (e) {
|
||||
console.error('Failed to get model name:', e);
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue