mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-03 09:08:52 +01:00
* WIP: conversion of `ocr` to `context` * refactor: make `primeResources` backwards-compatible for `ocr` tool_resources * refactor: Convert legacy `ocr` tool resource to `context` in agent updates - Implemented conversion logic to replace `ocr` with `context` in both incoming updates and existing agent data. - Merged file IDs and files from `ocr` into `context` while ensuring deduplication. - Updated tools array to reflect the change from `ocr` to `context`. * refactor: Enhance context file handling in agent processing - Updated the logic for managing context files by consolidating file IDs from both `ocr` and `context` resources. - Improved backwards compatibility by ensuring that context files are correctly populated and handled. - Simplified the iteration over context files for better readability and maintainability. * refactor: Enhance tool_resources handling in primeResources - Added tests to verify the deletion behavior of tool_resources fields, ensuring original objects remain unchanged. - Implemented logic to delete `ocr` and `context` fields after fetching and re-categorizing files. - Preserved context field when the context capability is disabled, ensuring correct behavior in various scenarios. * refactor: Replace `ocrEnabled` with `contextEnabled` in AgentConfig * refactor: Adjust legacy tool handling order for improved clarity * refactor: Implement OCR to context conversion functions and remove original conversion logic in update agent handling * refactor: Move contextEnabled declaration to maintain consistent order in capabilities * refactor: Update localization keys for file context to improve clarity and accuracy * chore: Update localization key for file context information to improve clarity
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { AgentCapabilities } from 'librechat-data-provider';
|
|
|
|
interface AgentCapabilitiesResult {
|
|
toolsEnabled: boolean;
|
|
actionsEnabled: boolean;
|
|
artifactsEnabled: boolean;
|
|
ocrEnabled: boolean;
|
|
contextEnabled: boolean;
|
|
fileSearchEnabled: boolean;
|
|
webSearchEnabled: boolean;
|
|
codeEnabled: boolean;
|
|
}
|
|
|
|
export default function useAgentCapabilities(
|
|
capabilities: AgentCapabilities[] | undefined,
|
|
): AgentCapabilitiesResult {
|
|
const toolsEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.tools) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const actionsEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.actions) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const artifactsEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.artifacts) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const ocrEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.ocr) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const contextEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.context) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const fileSearchEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.file_search) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const webSearchEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.web_search) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
const codeEnabled = useMemo(
|
|
() => capabilities?.includes(AgentCapabilities.execute_code) ?? false,
|
|
[capabilities],
|
|
);
|
|
|
|
return {
|
|
ocrEnabled,
|
|
codeEnabled,
|
|
toolsEnabled,
|
|
actionsEnabled,
|
|
contextEnabled,
|
|
artifactsEnabled,
|
|
webSearchEnabled,
|
|
fileSearchEnabled,
|
|
};
|
|
}
|