feat: add OpenRouter support and refactor LLM provider imports

- Introduced OpenRouter as a new LLM provider in the system.
- Updated LLM provider imports from '@/utils/ai' to '@/utils/llm' for consistency.
- Added new SVG icon for OpenRouter in the assets directory.
- Enhanced AutoProbe interfaces to accommodate new pattern structures.
This commit is contained in:
Marvin Zhang
2025-05-25 23:13:37 +08:00
parent 0022b5ae40
commit 0f80639a96
8 changed files with 56 additions and 29 deletions

View File

@@ -0,0 +1 @@
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenRouter</title><path d="M16.804 1.957l7.22 4.105v.087L16.73 10.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147 1.352L8.345 11.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314 1.17.796 2.701 1.866 1.11.775 2.083 1.177 3.147 1.352l.3.045c.694.091 1.375.094 2.825.033l.022-2.159 7.22 4.105v.087L16.589 22l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997 21.997 0 00-.755-.498l-.467-.28a55.927 55.927 0 00-.76-.43C2.908 14.73.563 14.116 0 14.116V9.888l.14.004c.564-.007 2.91-.622 3.809-1.124l1.016-.58.438-.274c.428-.28 1.072-.726 2.686-1.853 1.621-1.133 3.186-1.78 4.881-2.059 1.152-.19 1.974-.213 3.814-.138l.02-1.907z"></path></svg>

After

Width:  |  Height:  |  Size: 906 B

View File

@@ -2,7 +2,7 @@
import { computed, onBeforeMount, ref, watch } from 'vue';
import { translate } from '@/utils';
import { ElMessage } from 'element-plus';
import { getLLMProviderItems } from '@/utils/ai';
import { getLLMProviderItems } from '@/utils/llm';
const props = defineProps<{
loading?: boolean;

View File

@@ -10,7 +10,7 @@ import {
import { useI18n } from 'vue-i18n';
import {
getLLMProviderItems,
} from '@/utils/ai';
} from '@/utils/llm';
// Add TypeScript interface for tree node
interface TreeNode {

View File

@@ -13,6 +13,25 @@ export declare global {
viewport?: PageViewPort;
}
// Hierarchical pattern structure for V2
interface PatternV2 {
name: string;
type: PatternTypeV2;
selector_type?: SelectorType;
selector?: string;
is_absolute_selector?: boolean;
extraction_type?: ExtractType;
attribute_name?: string;
children?: PatternV2[];
}
interface PagePatternV2 {
name: string;
children?: PatternV2[];
}
type PatternTypeV2 = 'field' | 'list' | 'list-item' | 'action' | 'content';
type AutoProbeTaskStatus =
| 'pending'
| 'running'
@@ -67,7 +86,8 @@ export declare global {
status: AutoProbeTaskStatus;
error?: string;
html?: string;
page_pattern?: PagePattern;
// page_pattern?: PagePattern;
page_pattern?: PagePatternV2;
page_data?: PageData;
page_elements?: PageElement[];
provider_id?: string;
@@ -75,14 +95,6 @@ export declare global {
usage?: LLMResponseUsage;
}
interface AutoProbeTaskResult {
html?: string;
screenshot_base64?: string;
page_pattern?: PagePattern;
page_data?: PageData;
page_elements?: PageElement[];
}
type AutoProbeItemType = 'page_pattern' | 'list' | 'field' | 'pagination';
interface AutoProbeNavItem<T = any> extends NavItem<T> {

View File

@@ -14,6 +14,7 @@ export declare global {
| 'qwen'
| 'deepseek'
| 'mistral'
| 'openrouter'
| 'openai-compatible';
interface LLMProvider extends BaseModel {

View File

@@ -92,6 +92,19 @@ export const getLLMProviderItems = (): LLMProviderItem[] => {
icon: ['svg', 'deepseek'],
defaultModels: ['deepseek-chat', 'deepseek-reasoner'],
},
{
type: 'openrouter',
name: 'OpenRouter',
icon: ['svg', 'openrouter'],
defaultModels: [
'anthropic/claude-sonnet-4',
'anthropic/claude-3.7-sonnet',
'google/gemini-2.5-pro-preview',
'google/gemini-2.5-flash-preview',
'openai/gpt-4.1',
'openai/gpt-4o-mini',
],
},
{
type: 'openai-compatible',
name: 'OpenAI Compatible',

View File

@@ -128,23 +128,23 @@ const useAutoProbeList = () => {
hasFilter: true,
allowFilterSearch: true,
},
{
key: 'patterns',
label: t('views.autoprobe.table.columns.patterns'),
icon: ['fa', 'network-wired'],
width: '200',
value: (row: AutoProbe) => {
return (
<ClAutoProbePatternStats
autoprobe={row}
clickable
onClick={() => router.push(`/autoprobes/${row._id}/patterns`)}
/>
);
},
hasFilter: true,
allowFilterSearch: true,
},
// {
// key: 'patterns',
// label: t('views.autoprobe.table.columns.patterns'),
// icon: ['fa', 'network-wired'],
// width: '200',
// value: (row: AutoProbe) => {
// return (
// <ClAutoProbePatternStats
// autoprobe={row}
// clickable
// onClick={() => router.push(`/autoprobes/${row._id}/patterns`)}
// />
// );
// },
// hasFilter: true,
// allowFilterSearch: true,
// },
{
key: TABLE_COLUMN_NAME_ACTIONS,
label: t('components.table.columns.actions'),

View File

@@ -14,7 +14,7 @@ import {
ACTION_EDIT,
TABLE_COLUMN_NAME_ACTIONS,
} from '@/constants';
import { getLLMProviderItems } from '@/utils/ai';
import { getLLMProviderItems } from '@/utils/llm';
const t = translate;