You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/agents/index.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ class MyAppAppConfig(AppConfig):
57
57
58
58
## Configuring Agent URLs
59
59
60
-
To make your agents accessible at automatically generated URLs, add`agent_urls()` to your `urlpatterns`:
60
+
Agents can be made accessible at automatically generated URLs by adding`agent_urls()` to your `urlpatterns`:
61
61
62
62
```python
63
63
from django.urls import path, include
@@ -71,6 +71,18 @@ urlpatterns = [
71
71
72
72
This will generate URLs under `ai/` for all your registered agents based on their `slug` values. The `SimplePromptAgent` from the above example will be accessible at `ai/prompt/`.
73
73
74
+
Alternatively, you can register views for individual agents using the `as_view` classmethod on Agent classes:
75
+
76
+
````python
77
+
78
+
from django.urls import path, include
79
+
from .agents import SimplePromptAgent
80
+
81
+
urlpatterns = [
82
+
...
83
+
path("ai/simple/", SimplePromptAgent.as_view()),
84
+
]
85
+
74
86
## Using Agents
75
87
76
88
Agents can either be invoked directly:
@@ -79,7 +91,7 @@ Agents can either be invoked directly:
79
91
from .agents import SimplePromptAgent
80
92
81
93
SimplePromptAgent().execute(prompt="Foo")
82
-
```
94
+
````
83
95
84
96
or via their URL:
85
97
@@ -92,3 +104,25 @@ POST https://www.example.com/ai/prompt/
92
104
}
93
105
}
94
106
```
107
+
108
+
## Permissions
109
+
110
+
You can control who can execute your agents using permission. See the [Permissions](./permissions) documentation for detailed information on how to secure your agents.
111
+
112
+
Quick example:
113
+
114
+
```python
115
+
116
+
from django_ai_core.contrib.agents import Agent
117
+
from django_ai_core.contrib.agents.permissions import IsAuthenticated
0 commit comments