mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-05-06 16:25:04 +00:00
fix: remove internal tools when creating tools and better Approval gate UX
This commit is contained in:
@@ -2,6 +2,8 @@ from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class Tool(ABC):
|
||||
internal: bool = False
|
||||
|
||||
@abstractmethod
|
||||
def execute_action(self, action_name: str, **kwargs):
|
||||
pass
|
||||
|
||||
@@ -20,6 +20,8 @@ class InternalSearchTool(Tool):
|
||||
- list_files action: browse the file/folder structure
|
||||
"""
|
||||
|
||||
internal = True
|
||||
|
||||
def __init__(self, config: Dict):
|
||||
self.config = config
|
||||
self.retrieved_docs: List[Dict] = []
|
||||
|
||||
@@ -36,6 +36,8 @@ class ThinkTool(Tool):
|
||||
The reasoning content is captured in tool_call data for transparency.
|
||||
"""
|
||||
|
||||
internal = True
|
||||
|
||||
def __init__(self, config=None):
|
||||
pass
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ToolManager:
|
||||
continue
|
||||
module = importlib.import_module(f"application.agents.tools.{name}")
|
||||
for member_name, obj in inspect.getmembers(module, inspect.isclass):
|
||||
if issubclass(obj, Tool) and obj is not Tool:
|
||||
if issubclass(obj, Tool) and obj is not Tool and not obj.internal:
|
||||
tool_config = self.config.get(name, {})
|
||||
self.tools[name] = obj(tool_config)
|
||||
|
||||
|
||||
@@ -928,13 +928,23 @@ function ToolCallApprovalBar({
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
className="bg-primary hover:bg-primary/90 rounded-full px-4 py-1 text-xs font-medium text-white"
|
||||
onClick={() => onToolAction?.(toolCall.call_id, 'approved')}
|
||||
className={`rounded-full px-4 py-1 text-xs font-medium transition-colors ${
|
||||
comment
|
||||
? 'bg-muted text-muted-foreground cursor-default opacity-50'
|
||||
: 'bg-primary hover:bg-primary/90 text-white'
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (!comment) onToolAction?.(toolCall.call_id, 'approved');
|
||||
}}
|
||||
>
|
||||
Approve
|
||||
</button>
|
||||
<button
|
||||
className="hover:bg-accent text-muted-foreground rounded-full border px-4 py-1 text-xs font-medium"
|
||||
className={`rounded-full border px-4 py-1 text-xs font-medium transition-colors ${
|
||||
comment
|
||||
? 'border-destructive bg-destructive/10 text-destructive font-semibold'
|
||||
: 'hover:bg-accent text-muted-foreground'
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (expanded && comment) {
|
||||
onToolAction?.(toolCall.call_id, 'denied', comment);
|
||||
@@ -974,6 +984,11 @@ function ToolCallApprovalBar({
|
||||
className="border-border bg-background w-full rounded-lg border px-3 py-1.5 text-sm"
|
||||
value={comment}
|
||||
onChange={(e) => setComment(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && comment) {
|
||||
onToolAction?.(toolCall.call_id, 'denied', comment);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user