hyperforge 1.0.0.post19__py3-none-any.whl
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.
- hyperforge/__init__.py +16 -0
- hyperforge/agent.py +81 -0
- hyperforge/api/__init__.py +20 -0
- hyperforge/api/app.py +155 -0
- hyperforge/api/authentication.py +271 -0
- hyperforge/api/commands.py +33 -0
- hyperforge/api/internal/__init__.py +4 -0
- hyperforge/api/internal/inspect.py +30 -0
- hyperforge/api/internal/router.py +3 -0
- hyperforge/api/logging.py +18 -0
- hyperforge/api/models.py +129 -0
- hyperforge/api/session.py +197 -0
- hyperforge/api/settings.py +38 -0
- hyperforge/api/utils.py +354 -0
- hyperforge/api/v1/__init__.py +23 -0
- hyperforge/api/v1/agents.py +531 -0
- hyperforge/api/v1/interaction.py +430 -0
- hyperforge/api/v1/mcp_content.py +311 -0
- hyperforge/api/v1/mcp_interaction.py +322 -0
- hyperforge/api/v1/oauth.py +60 -0
- hyperforge/api/v1/prompt.py +129 -0
- hyperforge/api/v1/router.py +3 -0
- hyperforge/api/v1/schema.py +56 -0
- hyperforge/api/v1/session.py +182 -0
- hyperforge/api/v1/utils.py +12 -0
- hyperforge/api/v1/workflows.py +643 -0
- hyperforge/arag.py +28 -0
- hyperforge/broker/__init__.py +52 -0
- hyperforge/broker/local.py +116 -0
- hyperforge/broker/redis.py +161 -0
- hyperforge/configure.py +571 -0
- hyperforge/context/__init__.py +0 -0
- hyperforge/context/agent.py +377 -0
- hyperforge/context/config.py +103 -0
- hyperforge/database.py +3 -0
- hyperforge/db/__init__.py +6 -0
- hyperforge/db/agents.py +1521 -0
- hyperforge/db/encryption.py +91 -0
- hyperforge/db/exceptions.py +26 -0
- hyperforge/db/settings.py +16 -0
- hyperforge/db/workflow_cleanup.py +69 -0
- hyperforge/definition.py +13 -0
- hyperforge/driver.py +31 -0
- hyperforge/dummy.py +28 -0
- hyperforge/engine.py +189 -0
- hyperforge/exceptions.py +14 -0
- hyperforge/feature_flag.py +105 -0
- hyperforge/fixtures.py +602 -0
- hyperforge/interaction.py +116 -0
- hyperforge/llm.py +75 -0
- hyperforge/manager.py +432 -0
- hyperforge/memory/__init__.py +5 -0
- hyperforge/memory/memory.py +974 -0
- hyperforge/minimal_fixtures.py +75 -0
- hyperforge/models.py +336 -0
- hyperforge/nua.py +336 -0
- hyperforge/openapi.py +63 -0
- hyperforge/prompts.py +188 -0
- hyperforge/pubsub.py +90 -0
- hyperforge/py.typed +0 -0
- hyperforge/redis_utils.py +82 -0
- hyperforge/retrieval/__init__.py +0 -0
- hyperforge/retrieval/agent.py +169 -0
- hyperforge/retrieval/config.py +94 -0
- hyperforge/server/__init__.py +5 -0
- hyperforge/server/cache.py +131 -0
- hyperforge/server/run.py +109 -0
- hyperforge/server/sandbox.py +60 -0
- hyperforge/server/session.py +421 -0
- hyperforge/server/settings.py +47 -0
- hyperforge/server/utils.py +57 -0
- hyperforge/server/web.py +31 -0
- hyperforge/settings.py +18 -0
- hyperforge/standalone/__init__.py +5 -0
- hyperforge/standalone/agent.py +189 -0
- hyperforge/standalone/app.py +264 -0
- hyperforge/standalone/config.py +137 -0
- hyperforge/standalone/const.py +1 -0
- hyperforge/standalone/run.py +60 -0
- hyperforge/standalone/settings.py +133 -0
- hyperforge/standalone/ui_router.py +241 -0
- hyperforge/trace.py +42 -0
- hyperforge/utils/__init__.py +112 -0
- hyperforge/utils/http.py +48 -0
- hyperforge/workflows.py +44 -0
- hyperforge-1.0.0.post19.dist-info/METADATA +95 -0
- hyperforge-1.0.0.post19.dist-info/RECORD +90 -0
- hyperforge-1.0.0.post19.dist-info/WHEEL +5 -0
- hyperforge-1.0.0.post19.dist-info/entry_points.txt +8 -0
- hyperforge-1.0.0.post19.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, Annotated, Any, Dict, List
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
from fastapi import Header
|
|
5
|
+
from pydantic import BaseModel, BeforeValidator
|
|
6
|
+
from starlette.requests import Request
|
|
7
|
+
|
|
8
|
+
from hyperforge.api.authentication import requires_one
|
|
9
|
+
from hyperforge.api.models import AgentID, DriverID, StashRoles
|
|
10
|
+
from hyperforge.api.v1.router import router
|
|
11
|
+
from hyperforge.configure import (
|
|
12
|
+
validate_agent_context,
|
|
13
|
+
validate_agent_generation,
|
|
14
|
+
validate_agent_postprocess,
|
|
15
|
+
validate_agent_preprocess,
|
|
16
|
+
validate_driver,
|
|
17
|
+
)
|
|
18
|
+
from hyperforge.db.agents import AgentManager
|
|
19
|
+
from hyperforge.db.encryption import dump_without_encrypted_fields
|
|
20
|
+
from hyperforge.driver import DriverConfig
|
|
21
|
+
from hyperforge.models import Rules
|
|
22
|
+
|
|
23
|
+
if TYPE_CHECKING:
|
|
24
|
+
from hyperforge.api.app import HTTPApplication
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@router.post(
|
|
28
|
+
"/api/v1/agent/{agent_id}/rules",
|
|
29
|
+
status_code=200,
|
|
30
|
+
description="Set Agent Configuration",
|
|
31
|
+
tags=["Retrieval Agent"],
|
|
32
|
+
)
|
|
33
|
+
@requires_one([StashRoles.OWNER])
|
|
34
|
+
async def set_rules(
|
|
35
|
+
request: Request,
|
|
36
|
+
agent_id: str,
|
|
37
|
+
item: Rules,
|
|
38
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
39
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
40
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
41
|
+
):
|
|
42
|
+
app: HTTPApplication = request.app
|
|
43
|
+
agent_manager: AgentManager = app.agent_manager
|
|
44
|
+
|
|
45
|
+
await agent_manager.set_rules(agent_id=agent_id, account=x_stf_account, rules=item)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@router.get(
|
|
49
|
+
"/api/v1/agent/{agent_id}/rules",
|
|
50
|
+
status_code=200,
|
|
51
|
+
description="Set Agent Configuration",
|
|
52
|
+
tags=["Retrieval Agent"],
|
|
53
|
+
)
|
|
54
|
+
@requires_one([StashRoles.OWNER])
|
|
55
|
+
async def get_rules(
|
|
56
|
+
request: Request,
|
|
57
|
+
agent_id: str,
|
|
58
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
59
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
60
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
61
|
+
):
|
|
62
|
+
app: HTTPApplication = request.app
|
|
63
|
+
agent_manager: AgentManager = app.agent_manager
|
|
64
|
+
|
|
65
|
+
return await agent_manager.get_rules(agent_id=agent_id, account=x_stf_account)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@router.post(
|
|
69
|
+
"/api/v1/agent/{agent_id}/drivers",
|
|
70
|
+
status_code=200,
|
|
71
|
+
description="Set Agent Configuration",
|
|
72
|
+
tags=["Retrieval Agent"],
|
|
73
|
+
)
|
|
74
|
+
@requires_one([StashRoles.OWNER])
|
|
75
|
+
async def add_driver(
|
|
76
|
+
request: Request,
|
|
77
|
+
agent_id: str,
|
|
78
|
+
item: Annotated[DriverConfig, BeforeValidator(validate_driver)],
|
|
79
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
80
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
81
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
82
|
+
) -> DriverID:
|
|
83
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
84
|
+
driver_id = await agent_manager.add_driver(
|
|
85
|
+
account=x_stf_account,
|
|
86
|
+
agent_id=agent_id,
|
|
87
|
+
config=item,
|
|
88
|
+
)
|
|
89
|
+
return DriverID(id=driver_id)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@router.patch(
|
|
93
|
+
"/api/v1/agent/{agent_id}/driver/{driver}",
|
|
94
|
+
status_code=200,
|
|
95
|
+
description="Set Agent Configuration",
|
|
96
|
+
tags=["Retrieval Agent"],
|
|
97
|
+
)
|
|
98
|
+
@requires_one([StashRoles.OWNER])
|
|
99
|
+
async def patch_driver(
|
|
100
|
+
request: Request,
|
|
101
|
+
agent_id: str,
|
|
102
|
+
driver: str,
|
|
103
|
+
item: Annotated[DriverConfig, BeforeValidator(validate_driver)],
|
|
104
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
105
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
106
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
107
|
+
):
|
|
108
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
109
|
+
|
|
110
|
+
await agent_manager.patch_driver(
|
|
111
|
+
account=x_stf_account, agent_id=agent_id, config=item, driver=driver
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@router.delete(
|
|
116
|
+
"/api/v1/agent/{agent_id}/driver/{driver}",
|
|
117
|
+
status_code=200,
|
|
118
|
+
description="Set Agent Configuration",
|
|
119
|
+
tags=["Retrieval Agent"],
|
|
120
|
+
)
|
|
121
|
+
@requires_one([StashRoles.OWNER])
|
|
122
|
+
async def delete_driver(
|
|
123
|
+
request: Request,
|
|
124
|
+
agent_id: str,
|
|
125
|
+
driver: str,
|
|
126
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
127
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
128
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
129
|
+
):
|
|
130
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
131
|
+
|
|
132
|
+
return await agent_manager.delete_driver(
|
|
133
|
+
account=x_stf_account, agent_id=agent_id, driver=driver
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@router.get(
|
|
138
|
+
"/api/v1/agent/{agent_id}/drivers",
|
|
139
|
+
status_code=200,
|
|
140
|
+
description="Get Agent Configuration",
|
|
141
|
+
tags=["Retrieval Agent"],
|
|
142
|
+
)
|
|
143
|
+
@requires_one([StashRoles.OWNER])
|
|
144
|
+
async def get_drivers(
|
|
145
|
+
request: Request,
|
|
146
|
+
agent_id: str,
|
|
147
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
148
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
149
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
150
|
+
) -> list[Dict[str, Any]]:
|
|
151
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
152
|
+
|
|
153
|
+
# TODO: This returns DriverConfig while the rest of APIs use DriverConfigs
|
|
154
|
+
# Standardize (into the simpler DriverConfigs?) for consistency
|
|
155
|
+
# Same for the `get_driver` function
|
|
156
|
+
drivers: list[DriverConfig] = await agent_manager.get_drivers(
|
|
157
|
+
account=x_stf_account,
|
|
158
|
+
agent_id=agent_id,
|
|
159
|
+
)
|
|
160
|
+
return [dump_without_encrypted_fields(driver) for driver in drivers]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@router.post(
|
|
164
|
+
"/api/v1/agent/{agent_id}/preprocess",
|
|
165
|
+
status_code=200,
|
|
166
|
+
description="Add PreProcess Agent Configuration",
|
|
167
|
+
tags=["Retrieval Agent"],
|
|
168
|
+
)
|
|
169
|
+
@requires_one([StashRoles.OWNER])
|
|
170
|
+
async def add_preprocess(
|
|
171
|
+
request: Request,
|
|
172
|
+
agent_id: str,
|
|
173
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_preprocess)],
|
|
174
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
175
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
176
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
177
|
+
) -> AgentID:
|
|
178
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
179
|
+
|
|
180
|
+
agent_id = await agent_manager.add_preprocess(
|
|
181
|
+
agent_id=agent_id,
|
|
182
|
+
account=x_stf_account,
|
|
183
|
+
agent=item,
|
|
184
|
+
)
|
|
185
|
+
return AgentID(id=agent_id)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@router.patch(
|
|
189
|
+
"/api/v1/agent/{agent_id}/preprocess/{preprocess}",
|
|
190
|
+
status_code=200,
|
|
191
|
+
description="Set PreProcess Agent Configuration",
|
|
192
|
+
tags=["Retrieval Agent"],
|
|
193
|
+
)
|
|
194
|
+
@requires_one([StashRoles.OWNER])
|
|
195
|
+
async def patch_preprocess(
|
|
196
|
+
request: Request,
|
|
197
|
+
agent_id: str,
|
|
198
|
+
preprocess: str,
|
|
199
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_preprocess)],
|
|
200
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
201
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
202
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
203
|
+
):
|
|
204
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
205
|
+
|
|
206
|
+
await agent_manager.patch_preprocess(
|
|
207
|
+
account=x_stf_account, agent_id=agent_id, preprocess=preprocess, agent=item
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@router.delete(
|
|
212
|
+
"/api/v1/agent/{agent_id}/preprocess/{preprocess}",
|
|
213
|
+
status_code=200,
|
|
214
|
+
description="Delete PreProcess Agent Configuration",
|
|
215
|
+
tags=["Retrieval Agent"],
|
|
216
|
+
)
|
|
217
|
+
@requires_one([StashRoles.OWNER])
|
|
218
|
+
async def delete_preprocess(
|
|
219
|
+
request: Request,
|
|
220
|
+
agent_id: str,
|
|
221
|
+
preprocess: str,
|
|
222
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
223
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
224
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
225
|
+
):
|
|
226
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
227
|
+
|
|
228
|
+
return await agent_manager.delete_preprocess(
|
|
229
|
+
account=x_stf_account, agent_id=agent_id, preprocess=preprocess
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@router.get(
|
|
234
|
+
"/api/v1/agent/{agent_id}/preprocess",
|
|
235
|
+
status_code=200,
|
|
236
|
+
description="Set Agent Configuration",
|
|
237
|
+
tags=["Retrieval Agent"],
|
|
238
|
+
)
|
|
239
|
+
@requires_one([StashRoles.OWNER])
|
|
240
|
+
async def get_preprocess(
|
|
241
|
+
request: Request,
|
|
242
|
+
agent_id: str,
|
|
243
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
244
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
245
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
246
|
+
) -> List[Any]:
|
|
247
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
248
|
+
|
|
249
|
+
return await agent_manager.get_preprocess(
|
|
250
|
+
account=x_stf_account,
|
|
251
|
+
agent_id=agent_id,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@router.post(
|
|
256
|
+
"/api/v1/agent/{agent_id}/generation",
|
|
257
|
+
status_code=200,
|
|
258
|
+
description="Add Generation Agent Configuration",
|
|
259
|
+
tags=["Retrieval Agent"],
|
|
260
|
+
)
|
|
261
|
+
@requires_one([StashRoles.OWNER])
|
|
262
|
+
async def add_generation(
|
|
263
|
+
request: Request,
|
|
264
|
+
agent_id: str,
|
|
265
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_generation)],
|
|
266
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
267
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
268
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
269
|
+
) -> AgentID:
|
|
270
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
271
|
+
|
|
272
|
+
agent_id = await agent_manager.add_generation(
|
|
273
|
+
agent_id=agent_id,
|
|
274
|
+
account=x_stf_account,
|
|
275
|
+
agent=item,
|
|
276
|
+
)
|
|
277
|
+
return AgentID(id=agent_id)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
@router.patch(
|
|
281
|
+
"/api/v1/agent/{agent_id}/generation/{generation}",
|
|
282
|
+
status_code=200,
|
|
283
|
+
description="Set PreProcess Agent Configuration",
|
|
284
|
+
tags=["Retrieval Agent"],
|
|
285
|
+
)
|
|
286
|
+
@requires_one([StashRoles.OWNER])
|
|
287
|
+
async def patch_generation(
|
|
288
|
+
request: Request,
|
|
289
|
+
agent_id: str,
|
|
290
|
+
generation: str,
|
|
291
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_generation)],
|
|
292
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
293
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
294
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
295
|
+
):
|
|
296
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
297
|
+
await agent_manager.patch_generation(
|
|
298
|
+
account=x_stf_account, agent_id=agent_id, generation=generation, agent=item
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@router.delete(
|
|
303
|
+
"/api/v1/agent/{agent_id}/generation/{generation}",
|
|
304
|
+
status_code=200,
|
|
305
|
+
description="Delete Generation Agent Configuration",
|
|
306
|
+
tags=["Retrieval Agent"],
|
|
307
|
+
)
|
|
308
|
+
@requires_one([StashRoles.OWNER])
|
|
309
|
+
async def delete_generation(
|
|
310
|
+
request: Request,
|
|
311
|
+
agent_id: str,
|
|
312
|
+
generation: str,
|
|
313
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
314
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
315
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
316
|
+
):
|
|
317
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
318
|
+
|
|
319
|
+
return await agent_manager.delete_generation(
|
|
320
|
+
account=x_stf_account, agent_id=agent_id, generation=generation
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
@router.get(
|
|
325
|
+
"/api/v1/agent/{agent_id}/generation",
|
|
326
|
+
status_code=200,
|
|
327
|
+
description="Set Agent Configuration",
|
|
328
|
+
tags=["Retrieval Agent"],
|
|
329
|
+
)
|
|
330
|
+
@requires_one([StashRoles.OWNER])
|
|
331
|
+
async def get_generation(
|
|
332
|
+
request: Request,
|
|
333
|
+
agent_id: str,
|
|
334
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
335
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
336
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
337
|
+
) -> List[Any]:
|
|
338
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
339
|
+
|
|
340
|
+
return await agent_manager.get_generation(
|
|
341
|
+
account=x_stf_account,
|
|
342
|
+
agent_id=agent_id,
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
@router.post(
|
|
347
|
+
"/api/v1/agent/{agent_id}/postprocess",
|
|
348
|
+
status_code=200,
|
|
349
|
+
description="Add PostProcess Agent Configuration",
|
|
350
|
+
tags=["Retrieval Agent"],
|
|
351
|
+
)
|
|
352
|
+
@requires_one([StashRoles.OWNER])
|
|
353
|
+
async def add_postprocess(
|
|
354
|
+
request: Request,
|
|
355
|
+
agent_id: str,
|
|
356
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_postprocess)],
|
|
357
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
358
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
359
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
360
|
+
) -> AgentID:
|
|
361
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
362
|
+
|
|
363
|
+
agent_id = await agent_manager.add_postprocess(
|
|
364
|
+
agent_id=agent_id,
|
|
365
|
+
account=x_stf_account,
|
|
366
|
+
agent=item,
|
|
367
|
+
)
|
|
368
|
+
return AgentID(id=agent_id)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
@router.patch(
|
|
372
|
+
"/api/v1/agent/{agent_id}/postprocess/{postprocess}",
|
|
373
|
+
status_code=200,
|
|
374
|
+
description="Set PostProcess Agent Configuration",
|
|
375
|
+
tags=["Retrieval Agent"],
|
|
376
|
+
)
|
|
377
|
+
@requires_one([StashRoles.OWNER])
|
|
378
|
+
async def patch_postprocess(
|
|
379
|
+
request: Request,
|
|
380
|
+
agent_id: str,
|
|
381
|
+
postprocess: str,
|
|
382
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_postprocess)],
|
|
383
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
384
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
385
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
386
|
+
):
|
|
387
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
388
|
+
|
|
389
|
+
await agent_manager.patch_postprocess(
|
|
390
|
+
account=x_stf_account, agent_id=agent_id, postprocess=postprocess, agent=item
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
@router.delete(
|
|
395
|
+
"/api/v1/agent/{agent_id}/postprocess/{postprocess}",
|
|
396
|
+
status_code=200,
|
|
397
|
+
description="Delete PreProcess Agent Configuration",
|
|
398
|
+
tags=["Retrieval Agent"],
|
|
399
|
+
)
|
|
400
|
+
@requires_one([StashRoles.OWNER])
|
|
401
|
+
async def delete_postprocess(
|
|
402
|
+
request: Request,
|
|
403
|
+
agent_id: str,
|
|
404
|
+
postprocess: str,
|
|
405
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
406
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
407
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
408
|
+
):
|
|
409
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
410
|
+
|
|
411
|
+
return await agent_manager.delete_postprocess(
|
|
412
|
+
account=x_stf_account, agent_id=agent_id, postprocess=postprocess
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
@router.get(
|
|
417
|
+
"/api/v1/agent/{agent_id}/postprocess",
|
|
418
|
+
status_code=200,
|
|
419
|
+
description="Set Agent Configuration",
|
|
420
|
+
tags=["Retrieval Agent"],
|
|
421
|
+
)
|
|
422
|
+
@requires_one([StashRoles.OWNER])
|
|
423
|
+
async def get_postprocess(
|
|
424
|
+
request: Request,
|
|
425
|
+
agent_id: str,
|
|
426
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
427
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
428
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
429
|
+
) -> List[Any]:
|
|
430
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
431
|
+
|
|
432
|
+
return await agent_manager.get_postprocess(
|
|
433
|
+
account=x_stf_account,
|
|
434
|
+
agent_id=agent_id,
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
@router.post(
|
|
439
|
+
"/api/v1/agent/{agent_id}/context",
|
|
440
|
+
status_code=200,
|
|
441
|
+
description="Add Context Agent Configuration",
|
|
442
|
+
tags=["Retrieval Agent"],
|
|
443
|
+
include_in_schema=False,
|
|
444
|
+
)
|
|
445
|
+
@requires_one([StashRoles.OWNER])
|
|
446
|
+
async def add_context(
|
|
447
|
+
request: Request,
|
|
448
|
+
agent_id: str,
|
|
449
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_context)],
|
|
450
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
451
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
452
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
453
|
+
) -> AgentID:
|
|
454
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
455
|
+
|
|
456
|
+
agent_id = await agent_manager.add_context(
|
|
457
|
+
agent_id=agent_id,
|
|
458
|
+
account=x_stf_account,
|
|
459
|
+
agent=item,
|
|
460
|
+
)
|
|
461
|
+
return AgentID(id=agent_id)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
@router.patch(
|
|
465
|
+
"/api/v1/agent/{agent_id}/context/{context}",
|
|
466
|
+
status_code=200,
|
|
467
|
+
description="Set Context Agent Configuration",
|
|
468
|
+
tags=["Retrieval Agent"],
|
|
469
|
+
include_in_schema=False,
|
|
470
|
+
)
|
|
471
|
+
@requires_one([StashRoles.OWNER])
|
|
472
|
+
async def patch_context(
|
|
473
|
+
request: Request,
|
|
474
|
+
agent_id: str,
|
|
475
|
+
context: UUID,
|
|
476
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_context)],
|
|
477
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
478
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
479
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
480
|
+
):
|
|
481
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
482
|
+
|
|
483
|
+
await agent_manager.patch_context(
|
|
484
|
+
account=x_stf_account, agent_id=agent_id, context=context, agent=item
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
@router.delete(
|
|
489
|
+
"/api/v1/agent/{agent_id}/context/{context}",
|
|
490
|
+
status_code=200,
|
|
491
|
+
description="Delete Context Agent Configuration",
|
|
492
|
+
tags=["Retrieval Agent"],
|
|
493
|
+
include_in_schema=False,
|
|
494
|
+
)
|
|
495
|
+
@requires_one([StashRoles.OWNER])
|
|
496
|
+
async def delete_context(
|
|
497
|
+
request: Request,
|
|
498
|
+
agent_id: str,
|
|
499
|
+
context: UUID,
|
|
500
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
501
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
502
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
503
|
+
):
|
|
504
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
505
|
+
|
|
506
|
+
return await agent_manager.delete_context(
|
|
507
|
+
account=x_stf_account, agent_id=agent_id, context=context
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
@router.get(
|
|
512
|
+
"/api/v1/agent/{agent_id}/context",
|
|
513
|
+
status_code=200,
|
|
514
|
+
description="Get list of Context Agents",
|
|
515
|
+
tags=["Retrieval Agent"],
|
|
516
|
+
include_in_schema=False,
|
|
517
|
+
)
|
|
518
|
+
@requires_one([StashRoles.OWNER])
|
|
519
|
+
async def get_context(
|
|
520
|
+
request: Request,
|
|
521
|
+
agent_id: str,
|
|
522
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
523
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
524
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
525
|
+
) -> List[Any]:
|
|
526
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
527
|
+
|
|
528
|
+
return await agent_manager.get_context(
|
|
529
|
+
account=x_stf_account,
|
|
530
|
+
agent_id=agent_id,
|
|
531
|
+
)
|