django-agent-studio 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_agent_studio-0.1.0/PKG-INFO +416 -0
- django_agent_studio-0.1.0/README.md +381 -0
- django_agent_studio-0.1.0/__init__.py +12 -0
- django_agent_studio-0.1.0/api/__init__.py +4 -0
- django_agent_studio-0.1.0/api/permissions.py +160 -0
- django_agent_studio-0.1.0/api/serializers.py +606 -0
- django_agent_studio-0.1.0/api/urls.py +245 -0
- django_agent_studio-0.1.0/api/views.py +1548 -0
- django_agent_studio-0.1.0/apps.py +24 -0
- django_agent_studio-0.1.0/django_agent_studio.egg-info/PKG-INFO +416 -0
- django_agent_studio-0.1.0/django_agent_studio.egg-info/SOURCES.txt +45 -0
- django_agent_studio-0.1.0/django_agent_studio.egg-info/dependency_links.txt +1 -0
- django_agent_studio-0.1.0/django_agent_studio.egg-info/requires.txt +11 -0
- django_agent_studio-0.1.0/django_agent_studio.egg-info/top_level.txt +1 -0
- django_agent_studio-0.1.0/management/__init__.py +2 -0
- django_agent_studio-0.1.0/management/commands/__init__.py +2 -0
- django_agent_studio-0.1.0/pyproject.toml +87 -0
- django_agent_studio-0.1.0/setup.cfg +4 -0
- django_agent_studio-0.1.0/static/agent-frontend/chat-widget-markdown.js +110 -0
- django_agent_studio-0.1.0/static/agent-frontend/chat-widget.css +1401 -0
- django_agent_studio-0.1.0/static/agent-frontend/chat-widget.js +319 -0
- django_agent_studio-0.1.0/templates/django_agent_studio/agent_list.html +101 -0
- django_agent_studio-0.1.0/templates/django_agent_studio/base.html +137 -0
- django_agent_studio-0.1.0/templates/django_agent_studio/builder.html +1443 -0
- django_agent_studio-0.1.0/templates/django_agent_studio/home.html +97 -0
- django_agent_studio-0.1.0/templates/django_agent_studio/test.html +126 -0
- django_agent_studio-0.1.0/urls.py +25 -0
- django_agent_studio-0.1.0/views.py +100 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-agent-studio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Visual agent builder and management studio for Django - build custom GPTs with a two-pane interface
|
|
5
|
+
Author: Chris Barry
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/makemore/django-agent-studio
|
|
8
|
+
Project-URL: Documentation, https://github.com/makemore/django-agent-studio#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/makemore/django-agent-studio
|
|
10
|
+
Keywords: django,ai,agent,llm,gpt,builder,studio
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Framework :: Django :: 4.2
|
|
15
|
+
Classifier: Framework :: Django :: 5.0
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: Django>=4.2
|
|
26
|
+
Requires-Dist: djangorestframework>=3.14
|
|
27
|
+
Requires-Dist: django-agent-runtime>=0.3.12
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-django>=4.5; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
|
|
36
|
+
# Django Agent Studio
|
|
37
|
+
|
|
38
|
+
A visual agent builder and management interface for Django applications. Create, customize, and test AI agents through a conversational interface or REST API.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
### 🤖 Agent Builder Interface
|
|
43
|
+
|
|
44
|
+
A two-pane interface for building agents:
|
|
45
|
+
- **Left pane**: Test your agent in real-time
|
|
46
|
+
- **Right pane**: Conversational builder agent that helps you configure your agent
|
|
47
|
+
|
|
48
|
+
The builder agent can:
|
|
49
|
+
- Create new agents
|
|
50
|
+
- Update system prompts, models, and settings
|
|
51
|
+
- Add/remove tools and knowledge sources
|
|
52
|
+
- Scan your Django project for functions to use as tools
|
|
53
|
+
- Manage RAG (Retrieval-Augmented Generation) configuration
|
|
54
|
+
|
|
55
|
+
### 🔧 Dynamic Tool Discovery
|
|
56
|
+
|
|
57
|
+
Automatically discover functions in your Django project that can be used as agent tools:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# Functions like this are automatically discovered
|
|
61
|
+
def get_customer_orders(customer_id: int, limit: int = 10) -> list[dict]:
|
|
62
|
+
"""
|
|
63
|
+
Fetch recent orders for a customer.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
customer_id: The customer's ID
|
|
67
|
+
limit: Maximum number of orders to return
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
List of order dictionaries
|
|
71
|
+
"""
|
|
72
|
+
return Order.objects.filter(customer_id=customer_id)[:limit]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The scanner extracts:
|
|
76
|
+
- Function signatures and parameters
|
|
77
|
+
- Type hints and docstrings
|
|
78
|
+
- Whether functions are async
|
|
79
|
+
- Side effect detection (writes, deletes, etc.)
|
|
80
|
+
|
|
81
|
+
### 📚 Knowledge Management
|
|
82
|
+
|
|
83
|
+
Add context to your agents through multiple knowledge types:
|
|
84
|
+
- **Text**: Direct text content
|
|
85
|
+
- **URL**: Web pages (fetched and indexed)
|
|
86
|
+
- **File**: Uploaded documents
|
|
87
|
+
- **Dynamic**: Generated at runtime via callbacks
|
|
88
|
+
|
|
89
|
+
Knowledge can be:
|
|
90
|
+
- Always included in context
|
|
91
|
+
- Included via RAG similarity search
|
|
92
|
+
- Included on-demand when relevant
|
|
93
|
+
|
|
94
|
+
### 🔐 Permission System
|
|
95
|
+
|
|
96
|
+
Fine-grained access control for dynamic tool operations:
|
|
97
|
+
|
|
98
|
+
| Level | Capabilities |
|
|
99
|
+
|-------|-------------|
|
|
100
|
+
| **None** | No access to dynamic tools |
|
|
101
|
+
| **Viewer** | View discovered functions and existing tools |
|
|
102
|
+
| **Scanner** | Scan project for functions |
|
|
103
|
+
| **Requester** | Request tool creation (needs admin approval) |
|
|
104
|
+
| **Creator** | Create tools directly |
|
|
105
|
+
| **Admin** | Full access including approving requests |
|
|
106
|
+
|
|
107
|
+
### ✅ Approval Workflow
|
|
108
|
+
|
|
109
|
+
For organizations requiring oversight:
|
|
110
|
+
1. Users with "Requester" access submit tool creation requests
|
|
111
|
+
2. Admins review proposed tool configurations
|
|
112
|
+
3. Admins can approve (with optional modifications) or reject
|
|
113
|
+
4. Approved tools are automatically created and marked as verified
|
|
114
|
+
|
|
115
|
+
### 📝 Version Control
|
|
116
|
+
|
|
117
|
+
- **Agent Versions**: Create and manage multiple versions of an agent
|
|
118
|
+
- **Revisions**: Automatic snapshots after every change
|
|
119
|
+
- **Restore**: Roll back to any previous revision
|
|
120
|
+
|
|
121
|
+
## Installation
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pip install django-agent-studio
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Add to your `INSTALLED_APPS`:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
INSTALLED_APPS = [
|
|
131
|
+
# ...
|
|
132
|
+
'django_agent_runtime', # Required dependency
|
|
133
|
+
'django_agent_studio',
|
|
134
|
+
]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Include the URLs:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# urls.py
|
|
141
|
+
from django.urls import path, include
|
|
142
|
+
|
|
143
|
+
urlpatterns = [
|
|
144
|
+
# ...
|
|
145
|
+
path('studio/', include('django_agent_studio.urls')),
|
|
146
|
+
path('api/agent-runtime/', include('django_agent_runtime.api.urls')),
|
|
147
|
+
]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Run migrations:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
python manage.py migrate
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Usage
|
|
157
|
+
|
|
158
|
+
### Web Interface
|
|
159
|
+
|
|
160
|
+
Navigate to `/studio/` to access the agent builder interface.
|
|
161
|
+
|
|
162
|
+
### REST API
|
|
163
|
+
|
|
164
|
+
#### Agents
|
|
165
|
+
|
|
166
|
+
```http
|
|
167
|
+
# List your agents
|
|
168
|
+
GET /studio/api/agents/
|
|
169
|
+
|
|
170
|
+
# Create an agent
|
|
171
|
+
POST /studio/api/agents/
|
|
172
|
+
{
|
|
173
|
+
"name": "Customer Support Bot",
|
|
174
|
+
"description": "Helps customers with orders and returns"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Get agent details
|
|
178
|
+
GET /studio/api/agents/{id}/
|
|
179
|
+
|
|
180
|
+
# Get full agent schema (for debugging/export)
|
|
181
|
+
GET /studio/api/agents/{id}/full-schema/
|
|
182
|
+
|
|
183
|
+
# Update agent schema
|
|
184
|
+
PUT /studio/api/agents/{id}/full-schema/
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Versions
|
|
188
|
+
|
|
189
|
+
```http
|
|
190
|
+
# List versions
|
|
191
|
+
GET /studio/api/agents/{id}/versions/
|
|
192
|
+
|
|
193
|
+
# Create a new version
|
|
194
|
+
POST /studio/api/agents/{id}/versions/
|
|
195
|
+
|
|
196
|
+
# Activate a version
|
|
197
|
+
POST /studio/api/agents/{id}/versions/{version_id}/activate/
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Tools
|
|
201
|
+
|
|
202
|
+
```http
|
|
203
|
+
# List agent tools
|
|
204
|
+
GET /studio/api/agents/{id}/tools/
|
|
205
|
+
|
|
206
|
+
# Add a tool
|
|
207
|
+
POST /studio/api/agents/{id}/tools/
|
|
208
|
+
|
|
209
|
+
# List dynamic tools
|
|
210
|
+
GET /studio/api/agents/{id}/dynamic-tools/
|
|
211
|
+
|
|
212
|
+
# Toggle dynamic tool active status
|
|
213
|
+
POST /studio/api/agents/{id}/dynamic-tools/{tool_id}/toggle/
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Knowledge
|
|
217
|
+
|
|
218
|
+
```http
|
|
219
|
+
# List knowledge sources
|
|
220
|
+
GET /studio/api/agents/{id}/knowledge/
|
|
221
|
+
|
|
222
|
+
# Add knowledge
|
|
223
|
+
POST /studio/api/agents/{id}/knowledge/
|
|
224
|
+
{
|
|
225
|
+
"name": "Product FAQ",
|
|
226
|
+
"knowledge_type": "text",
|
|
227
|
+
"content": "Q: How do I return an item?...",
|
|
228
|
+
"inclusion_mode": "always"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### Dynamic Tool Discovery
|
|
233
|
+
|
|
234
|
+
```http
|
|
235
|
+
# Scan project for functions
|
|
236
|
+
POST /studio/api/agents/{id}/scan-project/
|
|
237
|
+
{
|
|
238
|
+
"include_private": false,
|
|
239
|
+
"include_tests": false,
|
|
240
|
+
"app_filter": "myapp"
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
# List discovered functions
|
|
244
|
+
GET /studio/api/discovered-functions/
|
|
245
|
+
|
|
246
|
+
# Generate tools from functions
|
|
247
|
+
POST /studio/api/agents/{id}/generate-tools/
|
|
248
|
+
{
|
|
249
|
+
"function_ids": ["uuid1", "uuid2"],
|
|
250
|
+
"requires_confirmation": true
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
#### Approval Workflow
|
|
255
|
+
|
|
256
|
+
```http
|
|
257
|
+
# List approval requests
|
|
258
|
+
GET /studio/api/tool-approval-requests/
|
|
259
|
+
|
|
260
|
+
# Review a request (admin only)
|
|
261
|
+
POST /studio/api/tool-approval-requests/{id}/review/
|
|
262
|
+
{
|
|
263
|
+
"action": "approve", # or "reject"
|
|
264
|
+
"review_notes": "Looks good!",
|
|
265
|
+
"override_name": "custom_tool_name" # optional
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
# Cancel your own request
|
|
269
|
+
POST /studio/api/tool-approval-requests/{id}/cancel/
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Permission Management
|
|
273
|
+
|
|
274
|
+
```http
|
|
275
|
+
# Get your access level
|
|
276
|
+
GET /studio/api/dynamic-tool-access/me/
|
|
277
|
+
|
|
278
|
+
# Grant access (admin only)
|
|
279
|
+
POST /studio/api/dynamic-tool-access/grant/
|
|
280
|
+
{
|
|
281
|
+
"user_id": 123,
|
|
282
|
+
"access_level": "creator",
|
|
283
|
+
"restricted_to_agent_ids": ["uuid1"], # optional
|
|
284
|
+
"notes": "Granted for project X"
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
# Revoke access (admin only)
|
|
288
|
+
POST /studio/api/dynamic-tool-access/revoke/
|
|
289
|
+
{
|
|
290
|
+
"user_id": 123
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### Templates
|
|
295
|
+
|
|
296
|
+
```http
|
|
297
|
+
# List public template agents
|
|
298
|
+
GET /studio/api/templates/
|
|
299
|
+
|
|
300
|
+
# Fork a template
|
|
301
|
+
POST /studio/api/agents/{id}/fork/
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Builder Agent
|
|
305
|
+
|
|
306
|
+
The builder agent (`agent-builder`) is a special agent that helps users create and configure other agents through conversation. It has access to tools for:
|
|
307
|
+
|
|
308
|
+
- `create_agent` - Create a new agent
|
|
309
|
+
- `get_current_config` - View current agent configuration
|
|
310
|
+
- `update_system_prompt` - Update the agent's personality/instructions
|
|
311
|
+
- `update_agent_name` - Change name and description
|
|
312
|
+
- `update_model_settings` - Change LLM model and parameters
|
|
313
|
+
- `add_knowledge` - Add knowledge sources
|
|
314
|
+
- `remove_knowledge` - Remove knowledge sources
|
|
315
|
+
- `scan_project_for_tools` - Discover functions in the codebase
|
|
316
|
+
- `list_discovered_functions` - Browse discovered functions
|
|
317
|
+
- `get_function_details` - Get details about a specific function
|
|
318
|
+
- `add_tool_from_function` - Add a function as a tool
|
|
319
|
+
- `list_agent_tools` - List all tools on the agent
|
|
320
|
+
- `remove_tool` - Remove a tool
|
|
321
|
+
- `list_revisions` - View revision history
|
|
322
|
+
- `get_revision` - Get a specific revision
|
|
323
|
+
- `restore_revision` - Restore to a previous state
|
|
324
|
+
- `index_knowledge` - Index knowledge for RAG
|
|
325
|
+
- `get_rag_status` - Check RAG indexing status
|
|
326
|
+
- `preview_rag_search` - Test RAG search queries
|
|
327
|
+
- `update_rag_config` - Configure RAG settings
|
|
328
|
+
|
|
329
|
+
## Multi-Agent Systems
|
|
330
|
+
|
|
331
|
+
Django Agent Studio supports building multi-agent systems where agents can invoke other agents as tools. This enables powerful patterns like routers, specialists, and hierarchical agent teams.
|
|
332
|
+
|
|
333
|
+
### Overview
|
|
334
|
+
|
|
335
|
+
Multi-agent systems use the "agent-as-tool" pattern from `agent-runtime-core`:
|
|
336
|
+
|
|
337
|
+
- **Router Pattern**: A main agent routes requests to specialist agents
|
|
338
|
+
- **Delegation**: Sub-agents run and return results to the parent
|
|
339
|
+
- **Handoff**: Control transfers completely to a sub-agent
|
|
340
|
+
|
|
341
|
+
For full documentation, see:
|
|
342
|
+
- [agent-runtime-core Multi-Agent Systems](https://github.com/makemore/agent-runtime-core#multi-agent-systems)
|
|
343
|
+
- [django-agent-runtime Multi-Agent Systems](https://github.com/makemore/django-agent-runtime#multi-agent-systems)
|
|
344
|
+
|
|
345
|
+
### Using Multi-Agent with Studio Agents
|
|
346
|
+
|
|
347
|
+
Studio-created agents can be used as sub-agents in code-defined router agents:
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
from django_agent_studio.runtime import StudioAgentRuntime
|
|
351
|
+
from agent_runtime_core.multi_agent import AgentTool, InvocationMode, ContextMode
|
|
352
|
+
|
|
353
|
+
# Load a studio-created agent
|
|
354
|
+
billing_agent = StudioAgentRuntime.from_agent_id("uuid-of-billing-agent")
|
|
355
|
+
|
|
356
|
+
# Wrap it as a tool
|
|
357
|
+
billing_tool = AgentTool(
|
|
358
|
+
agent=billing_agent,
|
|
359
|
+
name="billing_specialist",
|
|
360
|
+
description="Handles billing questions and refunds",
|
|
361
|
+
invocation_mode=InvocationMode.DELEGATE,
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
# Use in a router agent
|
|
365
|
+
class RouterAgent(AgentRuntime):
|
|
366
|
+
def __init__(self):
|
|
367
|
+
self.agent_tools = [billing_tool]
|
|
368
|
+
|
|
369
|
+
async def run(self, ctx: RunContext) -> RunResult:
|
|
370
|
+
# Register and use agent tools...
|
|
371
|
+
pass
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Key Concepts
|
|
375
|
+
|
|
376
|
+
| Concept | Description |
|
|
377
|
+
|---------|-------------|
|
|
378
|
+
| **AgentTool** | Wraps any agent to be callable as a tool |
|
|
379
|
+
| **DELEGATE mode** | Sub-agent returns result to parent (parent continues) |
|
|
380
|
+
| **HANDOFF mode** | Control transfers to sub-agent (parent exits) |
|
|
381
|
+
| **Context modes** | FULL (all history), SUMMARY, or MESSAGE_ONLY |
|
|
382
|
+
|
|
383
|
+
### Events
|
|
384
|
+
|
|
385
|
+
Multi-agent invocations emit events for observability:
|
|
386
|
+
|
|
387
|
+
- `sub_agent.start` - Sub-agent invocation started
|
|
388
|
+
- `sub_agent.end` - Sub-agent completed
|
|
389
|
+
- Events include `parent_run_id` and `sub_agent_run_id` for tracing
|
|
390
|
+
|
|
391
|
+
## Configuration
|
|
392
|
+
|
|
393
|
+
Configure via Django settings or environment variables:
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
AGENT_RUNTIME = {
|
|
397
|
+
# Default model for new agents
|
|
398
|
+
'DEFAULT_MODEL': 'gpt-4o',
|
|
399
|
+
|
|
400
|
+
# RAG settings
|
|
401
|
+
'RAG_EMBEDDING_MODEL': 'text-embedding-3-small',
|
|
402
|
+
'RAG_CHUNK_SIZE': 500,
|
|
403
|
+
'RAG_CHUNK_OVERLAP': 50,
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Dependencies
|
|
408
|
+
|
|
409
|
+
- `django-agent-runtime` - Core agent runtime
|
|
410
|
+
- `agent-runtime-core` - Agent execution framework
|
|
411
|
+
- `agent-frontend` - Chat widget for the UI
|
|
412
|
+
|
|
413
|
+
## License
|
|
414
|
+
|
|
415
|
+
MIT
|
|
416
|
+
|