File tree Expand file tree Collapse file tree 6 files changed +117
-4
lines changed Expand file tree Collapse file tree 6 files changed +117
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { s } from '@/router/init' ;
2
+ import { contract } from '@/contract' ;
3
+ import { getToolType } from '@tool/controller' ;
4
+
5
+ export const getTypeHandler = s . route ( contract . tool . getType , async ( ) => {
6
+ const type = getToolType ( ) ;
7
+
8
+ return {
9
+ status : 200 ,
10
+ body : type
11
+ } ;
12
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import z from 'zod' ;
2
2
import { c } from '@/contract/init' ;
3
3
import { ToolListItemSchema , type ToolListItemType } from './type/api' ;
4
- import { SystemVarSchema } from './type/tool' ;
4
+ import { ToolTypeEnum } from './type/tool' ;
5
5
6
6
export const toolContract = c . router (
7
7
{
@@ -23,6 +23,23 @@ export const toolContract = c.router(
23
23
responses : {
24
24
200 : ToolListItemSchema
25
25
}
26
+ } ,
27
+ getType : {
28
+ path : '/getType' ,
29
+ method : 'GET' ,
30
+ description : 'Get tool type' ,
31
+ responses : {
32
+ 200 : z . array (
33
+ z . object ( {
34
+ type : z . nativeEnum ( ToolTypeEnum ) ,
35
+ name : z . object ( {
36
+ en : z . string ( ) ,
37
+ 'zh-CN' : z . string ( ) ,
38
+ 'zh-Hant' : z . string ( )
39
+ } )
40
+ } )
41
+ )
42
+ }
26
43
}
27
44
} ,
28
45
{
Original file line number Diff line number Diff line change 1
1
import type { ToolType } from './type' ;
2
2
import { tools } from './constants' ;
3
+ import type { ToolTypeEnum } from './type/tool' ;
4
+ import { ToolTypeTranslations } from './type/tool' ;
3
5
4
6
export function getTool ( toolId : string ) : ToolType | undefined {
5
7
return tools . find ( ( tool ) => tool . toolId === toolId ) ;
6
8
}
9
+
10
+ export function getToolType ( ) : Array < {
11
+ type : ToolTypeEnum ;
12
+ name : { en : string ; 'zh-CN' : string ; 'zh-Hant' : string } ;
13
+ } > {
14
+ return Object . entries ( ToolTypeTranslations ) . map ( ( [ type , name ] ) => ( {
15
+ type : type as ToolTypeEnum ,
16
+ name
17
+ } ) ) ;
18
+ }
Original file line number Diff line number Diff line change 1
1
import { s } from '@/router/init' ;
2
2
import { getToolHandler } from './api/getTool' ;
3
3
import { getToolsHandler } from './api/list' ;
4
+ import { getTypeHandler } from './api/getType' ;
4
5
import { contract } from '@/contract' ;
5
6
6
7
export const toolRouter = s . router ( contract . tool , {
7
8
getTool : getToolHandler ,
8
- list : getToolsHandler
9
+ list : getToolsHandler ,
10
+ getType : getTypeHandler
9
11
} ) ;
Original file line number Diff line number Diff line change @@ -91,6 +91,78 @@ export enum ToolTypeEnum {
91
91
other = 'other'
92
92
}
93
93
94
+ export type ToolClassifyType = {
95
+ [ key in ToolTypeEnum ] : {
96
+ en : string ;
97
+ 'zh-CN' : string ;
98
+ 'zh-Hant' : string ;
99
+ } ;
100
+ } ;
101
+
102
+ /* Tool config is passed to FastGPT */
103
+ export const ToolTypeTranslations = {
104
+ [ ToolTypeEnum . tools ] : {
105
+ en : 'tools' ,
106
+ 'zh-CN' : '工具' ,
107
+ 'zh-Hant' : '工具'
108
+ } ,
109
+ [ ToolTypeEnum . search ] : {
110
+ en : 'search' ,
111
+ 'zh-CN' : '搜索' ,
112
+ 'zh-Hant' : '搜尋'
113
+ } ,
114
+ [ ToolTypeEnum . multimodal ] : {
115
+ en : 'multimodal' ,
116
+ 'zh-CN' : '多模态' ,
117
+ 'zh-Hant' : '多模態'
118
+ } ,
119
+ [ ToolTypeEnum . communication ] : {
120
+ en : 'communication' ,
121
+ 'zh-CN' : '通信' ,
122
+ 'zh-Hant' : '通信'
123
+ } ,
124
+ [ ToolTypeEnum . finance ] : {
125
+ en : 'finance' ,
126
+ 'zh-CN' : '金融' ,
127
+ 'zh-Hant' : '金融'
128
+ } ,
129
+ [ ToolTypeEnum . design ] : {
130
+ en : 'design' ,
131
+ 'zh-CN' : '设计' ,
132
+ 'zh-Hant' : '設計'
133
+ } ,
134
+ [ ToolTypeEnum . productivity ] : {
135
+ en : 'productivity' ,
136
+ 'zh-CN' : '生产力' ,
137
+ 'zh-Hant' : '生產力'
138
+ } ,
139
+ [ ToolTypeEnum . news ] : {
140
+ en : 'news' ,
141
+ 'zh-CN' : '新闻' ,
142
+ 'zh-Hant' : '新聞'
143
+ } ,
144
+ [ ToolTypeEnum . entertainment ] : {
145
+ en : 'entertainment' ,
146
+ 'zh-CN' : '娱乐' ,
147
+ 'zh-Hant' : '娛樂'
148
+ } ,
149
+ [ ToolTypeEnum . social ] : {
150
+ en : 'social' ,
151
+ 'zh-CN' : '社交' ,
152
+ 'zh-Hant' : '社交'
153
+ } ,
154
+ [ ToolTypeEnum . scientific ] : {
155
+ en : 'scientific' ,
156
+ 'zh-CN' : '科学' ,
157
+ 'zh-Hant' : '科學'
158
+ } ,
159
+ [ ToolTypeEnum . other ] : {
160
+ en : 'other' ,
161
+ 'zh-CN' : '其他' ,
162
+ 'zh-Hant' : '其他'
163
+ }
164
+ } as const ;
165
+
94
166
export const VersionListItemSchema = z . object ( {
95
167
value : z . string ( ) ,
96
168
description : z . string ( ) . optional ( ) ,
Original file line number Diff line number Diff line change 1
1
import createClient from '@/contract/client' ;
2
2
import type { SystemVarType } from '@tool/type/tool' ;
3
3
import type { StreamMessageType } from '@tool/type/tool' ;
4
-
5
4
export default createClient ;
6
5
7
6
export type { SystemVarType , StreamMessageType as StreamMessage } ;
8
-
9
7
export { RunToolWithStream } from './runToolStream' ;
10
8
export { StreamDataAnswerTypeEnum } from '@tool/type/tool' ;
11
9
export { ModelProviders , aiproxyIdMap } from '@model/constants' ;
You can’t perform that action at this time.
0 commit comments