1
1
import { TabsContent } from "@/components/ui/tabs" ;
2
2
import { Button } from "@/components/ui/button" ;
3
- import { Textarea } from "@/components/ui/textarea " ;
3
+ import { Input } from "@/components/ui/input " ;
4
4
import { Send , AlertCircle } from "lucide-react" ;
5
5
import { Alert , AlertDescription , AlertTitle } from "@/components/ui/alert" ;
6
6
import { useState } from "react" ;
7
+ import { Label } from "@/components/ui/label" ;
7
8
8
9
export type Tool = {
9
10
name : string ;
11
+ description : string ;
12
+ inputSchema : {
13
+ type : string ;
14
+ properties : Record < string , { type : string ; description : string } > ;
15
+ } ;
10
16
} ;
11
17
12
18
const ToolsTab = ( {
@@ -26,7 +32,7 @@ const ToolsTab = ({
26
32
toolResult : string ;
27
33
error : string | null ;
28
34
} ) => {
29
- const [ params , setParams ] = useState ( "" ) ;
35
+ const [ params , setParams ] = useState < Record < string , unknown > > ( { } ) ;
30
36
31
37
return (
32
38
< TabsContent value = "tools" className = "grid grid-cols-2 gap-4" >
@@ -46,6 +52,9 @@ const ToolsTab = ({
46
52
onClick = { ( ) => setSelectedTool ( tool ) }
47
53
>
48
54
< span className = "flex-1" > { tool . name } </ span >
55
+ < span className = "text-sm text-gray-500" >
56
+ { tool . description }
57
+ </ span >
49
58
</ div >
50
59
) ) }
51
60
</ div >
@@ -67,22 +76,47 @@ const ToolsTab = ({
67
76
</ Alert >
68
77
) : selectedTool ? (
69
78
< div className = "space-y-4" >
70
- < Textarea
71
- placeholder = "Tool parameters (JSON)"
72
- className = "h-32 font-mono"
73
- value = { params }
74
- onChange = { ( e ) => setParams ( e . target . value ) }
75
- />
76
- < Button
77
- onClick = { ( ) => callTool ( selectedTool . name , JSON . parse ( params ) ) }
78
- >
79
+ < p className = "text-sm text-gray-600" >
80
+ { selectedTool . description }
81
+ </ p >
82
+ { Object . entries ( selectedTool . inputSchema . properties ) . map (
83
+ ( [ key , value ] ) => (
84
+ < div key = { key } >
85
+ < Label
86
+ htmlFor = { key }
87
+ className = "block text-sm font-medium text-gray-700"
88
+ >
89
+ { key }
90
+ </ Label >
91
+ < Input
92
+ type = { value . type === "number" ? "number" : "text" }
93
+ id = { key }
94
+ name = { key }
95
+ placeholder = { value . description }
96
+ onChange = { ( e ) =>
97
+ setParams ( {
98
+ ...params ,
99
+ [ key ] :
100
+ value . type === "number"
101
+ ? Number ( e . target . value )
102
+ : e . target . value ,
103
+ } )
104
+ }
105
+ />
106
+ </ div >
107
+ ) ,
108
+ ) }
109
+ < Button onClick = { ( ) => callTool ( selectedTool . name , params ) } >
79
110
< Send className = "w-4 h-4 mr-2" />
80
111
Run Tool
81
112
</ Button >
82
113
{ toolResult && (
83
- < pre className = "bg-gray-50 p-4 rounded text-sm overflow-auto max-h-64" >
84
- { JSON . stringify ( toolResult , null , 2 ) }
85
- </ pre >
114
+ < >
115
+ < h4 className = "font-semibold mb-2" > Tool Result:</ h4 >
116
+ < pre className = "bg-gray-50 p-4 rounded text-sm overflow-auto max-h-64" >
117
+ { toolResult }
118
+ </ pre >
119
+ </ >
86
120
) }
87
121
</ div >
88
122
) : (
0 commit comments