Files
ragflow/web/src/interfaces/database/llm.ts

121 lines
2.8 KiB
TypeScript
Raw Normal View History

export interface IThirdOAIModel {
available: boolean;
create_date: string;
create_time: number;
fid: string;
id: number;
llm_name: string;
max_tokens: number;
model_type: string;
status: string;
tags: string;
update_date: string;
update_time: number;
tenant_id?: string;
tenant_name?: string;
Feat: Support tool calling in Generate component (#7572) ### What problem does this PR solve? Hello, our use case requires LLM agent to invoke some tools, so I made a simple implementation here. This PR does two things: 1. A simple plugin mechanism based on `pluginlib`: This mechanism lives in the `plugin` directory. It will only load plugins from `plugin/embedded_plugins` for now. A sample plugin `bad_calculator.py` is placed in `plugin/embedded_plugins/llm_tools`, it accepts two numbers `a` and `b`, then give a wrong result `a + b + 100`. In the future, it can load plugins from external location with little code change. Plugins are divided into different types. The only plugin type supported in this PR is `llm_tools`, which must implement the `LLMToolPlugin` class in the `plugin/llm_tool_plugin.py`. More plugin types can be added in the future. 2. A tool selector in the `Generate` component: Added a tool selector to select one or more tools for LLM: ![image](https://github.com/user-attachments/assets/74a21fdf-9333-4175-991b-43df6524c5dc) And with the `bad_calculator` tool, it results this with the `qwen-max` model: ![image](https://github.com/user-attachments/assets/93aff9c4-8550-414a-90a2-1a15a5249d94) ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
2025-05-16 16:32:19 +08:00
is_tools: boolean;
}
export type IThirdOAIModelCollection = Record<string, IThirdOAIModel[]>;
export interface IFactory {
create_date: string;
create_time: number;
logo: string;
name: string;
status: string;
tags: string;
update_date: string;
update_time: number;
}
export interface IMyLlmValue {
llm: Llm[];
tags: string;
}
export interface Llm {
name: string;
type: string;
status: '0' | '1';
used_token: number;
}
export interface IAvailableProvider {
name: string;
model_types: string[];
url: { default?: string; [key: string]: string | undefined };
2026-07-08 09:47:29 +08:00
has_instance: boolean;
}
export interface IProviderInstance {
2026-07-08 09:47:29 +08:00
/**
* Usually a plain key string, but the showProviderInstance endpoint
* may return an object `{ api_key, ...nested }` for providers that
* bundle extra credentials (see the nested fields below).
*/
api_key: string | Record<string, any>;
id: string;
instance_name: string;
provider_id: string;
region: string;
status: string;
/**
* Optional: only returned by the showProviderInstance endpoint. Used
2026-07-08 09:47:29 +08:00
* to pre-fill the base_url/api_base form field when opening a saved
* instance.
*/
base_url?: string;
2026-07-08 09:47:29 +08:00
/**
* Provider-specific credentials that may be returned either at the top
* level or nested inside `api_key`:
* - group_id MiniMax
* - api_version Azure OpenAI
* - provider_order OpenRouter
*/
group_id?: string;
api_version?: string;
provider_order?: string;
}
export interface IAddedModel {
model_id: string;
model_type: string[];
name: string;
provider_id: string;
provider_name: string;
instance_id: string;
instance_name: string;
tenant_id?: string;
tenant_name?: string;
}
export interface IInstanceModel {
max_tokens: number;
model_type: string[];
name: string;
status: string;
2026-07-08 09:47:29 +08:00
/**
* Persisted verification result from the backend:
* - `true` verified successfully
* - `false` verified but failed
* - `undefined` never verified yet
*/
verify?: 'unknown' | 'success' | 'fail';
/**
* Persisted Tool-call flag from `tenant_model.extra.is_tools`.
* The backend's `_hybrid_get_instance_models` includes this so the
* frontend can forward the correct value in auto-save payloads
* without relying solely on the (possibly unfetched) catalog.
*/
is_tools?: boolean;
}
export interface IDefaultModel {
model_id: string;
enable: boolean;
model_instance: string;
model_name: string;
model_provider: string;
model_type: string;
}