Skip to content

Commit 65bb931

Browse files
committed
Agent Playground
1 parent 8aede1c commit 65bb931

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

agent-ui/src/components/phase3/AgentPlayground/AgentPlayground.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,39 @@ export const AgentPlayground: React.FC<AgentPlaygroundProps> = ({ className }) =
192192
Test and experiment with integrated agents
193193
</p>
194194
</div>
195-
<Button variant="outline">
196-
<Settings className="mr-2 h-4 w-4" />
197-
Configure
198-
</Button>
195+
:start_line:195
196+
-------
197+
<div className="flex space-x-2">
198+
<Button variant="outline" onClick={() => { /* TODO: Implement configuration modal */ }}>
199+
<Settings className="mr-2 h-4 w-4" />
200+
Configure
201+
</Button>
202+
<Button variant="destructive" onClick={async () => {
203+
if (confirm("Are you sure you want to clear all sessions? This action cannot be undone.")) {
204+
try {
205+
const response = await fetch('/v1/playground/clear_sessions', {
206+
method: 'POST',
207+
headers: {
208+
'Content-Type': 'application/json',
209+
'X-API-Key': 'YOUR_API_KEY' // Replace with actual API key handling
210+
},
211+
});
212+
if (response.ok) {
213+
setRequests([]); // Clear local requests on successful API call
214+
alert("All sessions cleared successfully!");
215+
} else {
216+
const errorData = await response.json();
217+
alert(`Failed to clear sessions: ${errorData.detail || response.statusText}`);
218+
}
219+
} catch (error: any) {
220+
alert(`Error clearing sessions: ${error.message}`);
221+
}
222+
}
223+
}}>
224+
<RotateCcw className="mr-2 h-4 w-4" />
225+
Clear All Sessions
226+
</Button>
227+
</div>
199228
</div>
200229

201230
<div className="grid gap-6 lg:grid-cols-3">

src/api/routers/playground.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
sessions_storage = {}
2525

2626

27+
@router.post("/clear_sessions")
28+
async def clear_all_sessions(api_key: Optional[str] = Depends(get_api_key)):
29+
"""
30+
Clear all stored sessions.
31+
"""
32+
sessions_storage.clear()
33+
return {"message": "All sessions cleared successfully"}
34+
35+
2736
@router.get("/status")
2837
async def get_playground_status():
2938
"""

0 commit comments

Comments
 (0)