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,643 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, Annotated, Any, List
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
from fastapi import Header, HTTPException
|
|
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, 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
|
+
)
|
|
17
|
+
from hyperforge.db import exceptions
|
|
18
|
+
from hyperforge.db.agents import AgentManager
|
|
19
|
+
from hyperforge.models import Rules
|
|
20
|
+
from hyperforge.workflows import WorkflowData, WorkflowInput, WorkflowUpdate
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from hyperforge.api.app import HTTPApplication
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
async def _not_found_as_404(awaitable):
|
|
27
|
+
try:
|
|
28
|
+
return await awaitable
|
|
29
|
+
except exceptions.NotFoundError as exc:
|
|
30
|
+
raise HTTPException(status_code=404, detail=str(exc))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@router.post(
|
|
34
|
+
"/api/v1/agent/{agent_id}/workflows",
|
|
35
|
+
status_code=200,
|
|
36
|
+
description="Add Workflow Configuration",
|
|
37
|
+
tags=["Workflows"],
|
|
38
|
+
)
|
|
39
|
+
@requires_one([StashRoles.OWNER])
|
|
40
|
+
async def add_workflow(
|
|
41
|
+
request: Request,
|
|
42
|
+
agent_id: str,
|
|
43
|
+
item: WorkflowInput,
|
|
44
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
45
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
46
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
47
|
+
):
|
|
48
|
+
app: HTTPApplication = request.app
|
|
49
|
+
agent_manager: AgentManager = app.agent_manager
|
|
50
|
+
|
|
51
|
+
await agent_manager.add_workflow(
|
|
52
|
+
agent_id=agent_id, item=item, account=x_stf_account
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@router.get(
|
|
57
|
+
"/api/v1/agent/{agent_id}/workflows",
|
|
58
|
+
status_code=200,
|
|
59
|
+
description="Get Workflow Configuration",
|
|
60
|
+
tags=["Workflows"],
|
|
61
|
+
)
|
|
62
|
+
@requires_one([StashRoles.OWNER])
|
|
63
|
+
async def get_workflows(
|
|
64
|
+
request: Request,
|
|
65
|
+
agent_id: str,
|
|
66
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
67
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
68
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
69
|
+
) -> List[WorkflowData]:
|
|
70
|
+
app: HTTPApplication = request.app
|
|
71
|
+
agent_manager: AgentManager = app.agent_manager
|
|
72
|
+
|
|
73
|
+
return await agent_manager.workflows_list(agent_id=agent_id, account=x_stf_account)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@router.patch(
|
|
77
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}",
|
|
78
|
+
status_code=200,
|
|
79
|
+
description="Set Workflow Configuration",
|
|
80
|
+
tags=["Workflows"],
|
|
81
|
+
)
|
|
82
|
+
@requires_one([StashRoles.OWNER])
|
|
83
|
+
async def set_workflow(
|
|
84
|
+
request: Request,
|
|
85
|
+
agent_id: str,
|
|
86
|
+
workflow_id: str,
|
|
87
|
+
item: WorkflowUpdate,
|
|
88
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
89
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
90
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
91
|
+
):
|
|
92
|
+
app: HTTPApplication = request.app
|
|
93
|
+
agent_manager: AgentManager = app.agent_manager
|
|
94
|
+
|
|
95
|
+
await _not_found_as_404(
|
|
96
|
+
agent_manager.set_workflow(
|
|
97
|
+
workflow_id=workflow_id,
|
|
98
|
+
agent_id=agent_id,
|
|
99
|
+
item=item,
|
|
100
|
+
account=x_stf_account,
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@router.delete(
|
|
106
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}",
|
|
107
|
+
status_code=200,
|
|
108
|
+
description="Delete Workflow Configuration",
|
|
109
|
+
tags=["Workflows"],
|
|
110
|
+
)
|
|
111
|
+
@requires_one([StashRoles.OWNER])
|
|
112
|
+
async def delete_workflow(
|
|
113
|
+
request: Request,
|
|
114
|
+
agent_id: str,
|
|
115
|
+
workflow_id: str,
|
|
116
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
117
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
118
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
119
|
+
):
|
|
120
|
+
app: HTTPApplication = request.app
|
|
121
|
+
agent_manager: AgentManager = app.agent_manager
|
|
122
|
+
|
|
123
|
+
try:
|
|
124
|
+
await agent_manager.delete_workflow(
|
|
125
|
+
workflow_id=workflow_id,
|
|
126
|
+
agent_id=agent_id,
|
|
127
|
+
account=x_stf_account,
|
|
128
|
+
deleted_by=x_stf_user,
|
|
129
|
+
)
|
|
130
|
+
except exceptions.ProtectedWorkflowError as exc:
|
|
131
|
+
raise HTTPException(status_code=409, detail=str(exc))
|
|
132
|
+
except exceptions.NotFoundError:
|
|
133
|
+
raise HTTPException(status_code=404, detail="Workflow not found")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@router.post(
|
|
137
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/rules",
|
|
138
|
+
status_code=200,
|
|
139
|
+
description="Set Workflow Rules Configuration",
|
|
140
|
+
tags=["Workflows"],
|
|
141
|
+
)
|
|
142
|
+
@requires_one([StashRoles.OWNER])
|
|
143
|
+
async def set_rules(
|
|
144
|
+
request: Request,
|
|
145
|
+
agent_id: str,
|
|
146
|
+
workflow_id: str,
|
|
147
|
+
item: Rules,
|
|
148
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
149
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
150
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
151
|
+
):
|
|
152
|
+
app: HTTPApplication = request.app
|
|
153
|
+
agent_manager: AgentManager = app.agent_manager
|
|
154
|
+
|
|
155
|
+
await _not_found_as_404(
|
|
156
|
+
agent_manager.set_workflow_rules(
|
|
157
|
+
agent_id=agent_id,
|
|
158
|
+
workflow_id=workflow_id,
|
|
159
|
+
account=x_stf_account,
|
|
160
|
+
rules=item,
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@router.get(
|
|
166
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/rules",
|
|
167
|
+
status_code=200,
|
|
168
|
+
description="Get Workflow Rules Configuration",
|
|
169
|
+
tags=["Workflows"],
|
|
170
|
+
)
|
|
171
|
+
@requires_one([StashRoles.OWNER])
|
|
172
|
+
async def get_rules(
|
|
173
|
+
request: Request,
|
|
174
|
+
agent_id: str,
|
|
175
|
+
workflow_id: str,
|
|
176
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
177
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
178
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
179
|
+
):
|
|
180
|
+
app: HTTPApplication = request.app
|
|
181
|
+
agent_manager: AgentManager = app.agent_manager
|
|
182
|
+
|
|
183
|
+
return await _not_found_as_404(
|
|
184
|
+
agent_manager.get_workflow_rules(
|
|
185
|
+
agent_id=agent_id, workflow_id=workflow_id, account=x_stf_account
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@router.post(
|
|
191
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/preprocess",
|
|
192
|
+
status_code=200,
|
|
193
|
+
description="Add PreProcess Workflows Configuration",
|
|
194
|
+
tags=["Workflows"],
|
|
195
|
+
)
|
|
196
|
+
@requires_one([StashRoles.OWNER])
|
|
197
|
+
async def add_preprocess(
|
|
198
|
+
request: Request,
|
|
199
|
+
agent_id: str,
|
|
200
|
+
workflow_id: str,
|
|
201
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_preprocess)],
|
|
202
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
203
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
204
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
205
|
+
) -> AgentID:
|
|
206
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
207
|
+
|
|
208
|
+
agent_id = await _not_found_as_404(
|
|
209
|
+
agent_manager.add_preprocess(
|
|
210
|
+
agent_id=agent_id,
|
|
211
|
+
account=x_stf_account,
|
|
212
|
+
workflow_id=workflow_id,
|
|
213
|
+
agent=item,
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
return AgentID(id=agent_id)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@router.patch(
|
|
220
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/preprocess/{preprocess}",
|
|
221
|
+
status_code=200,
|
|
222
|
+
description="Set PreProcess Workflows Configuration",
|
|
223
|
+
tags=["Workflows"],
|
|
224
|
+
)
|
|
225
|
+
@requires_one([StashRoles.OWNER])
|
|
226
|
+
async def patch_preprocess(
|
|
227
|
+
request: Request,
|
|
228
|
+
agent_id: str,
|
|
229
|
+
workflow_id: str,
|
|
230
|
+
preprocess: str,
|
|
231
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_preprocess)],
|
|
232
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
233
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
234
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
235
|
+
):
|
|
236
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
237
|
+
|
|
238
|
+
await _not_found_as_404(
|
|
239
|
+
agent_manager.patch_preprocess(
|
|
240
|
+
account=x_stf_account,
|
|
241
|
+
agent_id=agent_id,
|
|
242
|
+
workflow_id=workflow_id,
|
|
243
|
+
preprocess=preprocess,
|
|
244
|
+
agent=item,
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@router.delete(
|
|
250
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/preprocess/{preprocess}",
|
|
251
|
+
status_code=200,
|
|
252
|
+
description="Delete PreProcess Workflows Configuration",
|
|
253
|
+
tags=["Workflows"],
|
|
254
|
+
)
|
|
255
|
+
@requires_one([StashRoles.OWNER])
|
|
256
|
+
async def delete_preprocess(
|
|
257
|
+
request: Request,
|
|
258
|
+
agent_id: str,
|
|
259
|
+
preprocess: str,
|
|
260
|
+
workflow_id: str,
|
|
261
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
262
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
263
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
264
|
+
):
|
|
265
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
266
|
+
|
|
267
|
+
return await _not_found_as_404(
|
|
268
|
+
agent_manager.delete_preprocess(
|
|
269
|
+
account=x_stf_account,
|
|
270
|
+
agent_id=agent_id,
|
|
271
|
+
workflow_id=workflow_id,
|
|
272
|
+
preprocess=preprocess,
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@router.get(
|
|
278
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/preprocess",
|
|
279
|
+
status_code=200,
|
|
280
|
+
description="Set Workflow Configuration",
|
|
281
|
+
tags=["Workflows"],
|
|
282
|
+
)
|
|
283
|
+
@requires_one([StashRoles.OWNER])
|
|
284
|
+
async def get_preprocess(
|
|
285
|
+
request: Request,
|
|
286
|
+
agent_id: str,
|
|
287
|
+
workflow_id: str,
|
|
288
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
289
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
290
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
291
|
+
) -> List[Any]:
|
|
292
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
293
|
+
|
|
294
|
+
return await _not_found_as_404(
|
|
295
|
+
agent_manager.get_preprocess(
|
|
296
|
+
account=x_stf_account,
|
|
297
|
+
agent_id=agent_id,
|
|
298
|
+
workflow_id=workflow_id,
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@router.post(
|
|
304
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/generation",
|
|
305
|
+
status_code=200,
|
|
306
|
+
description="Add Generation Workflows Configuration",
|
|
307
|
+
tags=["Workflows"],
|
|
308
|
+
)
|
|
309
|
+
@requires_one([StashRoles.OWNER])
|
|
310
|
+
async def add_generation(
|
|
311
|
+
request: Request,
|
|
312
|
+
agent_id: str,
|
|
313
|
+
workflow_id: str,
|
|
314
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_generation)],
|
|
315
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
316
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
317
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
318
|
+
) -> AgentID:
|
|
319
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
320
|
+
|
|
321
|
+
agent_id = await _not_found_as_404(
|
|
322
|
+
agent_manager.add_generation(
|
|
323
|
+
agent_id=agent_id,
|
|
324
|
+
account=x_stf_account,
|
|
325
|
+
agent=item,
|
|
326
|
+
workflow_id=workflow_id,
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
return AgentID(id=agent_id)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
@router.patch(
|
|
333
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/generation/{generation}",
|
|
334
|
+
status_code=200,
|
|
335
|
+
description="Set Generation Workflows Configuration",
|
|
336
|
+
tags=["Workflows"],
|
|
337
|
+
)
|
|
338
|
+
@requires_one([StashRoles.OWNER])
|
|
339
|
+
async def patch_generation(
|
|
340
|
+
request: Request,
|
|
341
|
+
agent_id: str,
|
|
342
|
+
workflow_id: str,
|
|
343
|
+
generation: str,
|
|
344
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_generation)],
|
|
345
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
346
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
347
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
348
|
+
):
|
|
349
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
350
|
+
|
|
351
|
+
await _not_found_as_404(
|
|
352
|
+
agent_manager.patch_generation(
|
|
353
|
+
account=x_stf_account,
|
|
354
|
+
agent_id=agent_id,
|
|
355
|
+
generation=generation,
|
|
356
|
+
agent=item,
|
|
357
|
+
workflow_id=workflow_id,
|
|
358
|
+
)
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
@router.delete(
|
|
363
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/generation/{generation}",
|
|
364
|
+
status_code=200,
|
|
365
|
+
description="Delete Generation Workflows Configuration",
|
|
366
|
+
tags=["Workflows"],
|
|
367
|
+
)
|
|
368
|
+
@requires_one([StashRoles.OWNER])
|
|
369
|
+
async def delete_generation(
|
|
370
|
+
request: Request,
|
|
371
|
+
agent_id: str,
|
|
372
|
+
workflow_id: str,
|
|
373
|
+
generation: str,
|
|
374
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
375
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
376
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
377
|
+
):
|
|
378
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
379
|
+
|
|
380
|
+
return await _not_found_as_404(
|
|
381
|
+
agent_manager.delete_generation(
|
|
382
|
+
account=x_stf_account,
|
|
383
|
+
agent_id=agent_id,
|
|
384
|
+
generation=generation,
|
|
385
|
+
workflow_id=workflow_id,
|
|
386
|
+
)
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
@router.get(
|
|
391
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/generation",
|
|
392
|
+
status_code=200,
|
|
393
|
+
description="Get Generation Workflows Configuration",
|
|
394
|
+
tags=["Workflows"],
|
|
395
|
+
)
|
|
396
|
+
@requires_one([StashRoles.OWNER])
|
|
397
|
+
async def get_generation(
|
|
398
|
+
request: Request,
|
|
399
|
+
agent_id: str,
|
|
400
|
+
workflow_id: str,
|
|
401
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
402
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
403
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
404
|
+
) -> List[Any]:
|
|
405
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
406
|
+
|
|
407
|
+
return await _not_found_as_404(
|
|
408
|
+
agent_manager.get_generation(
|
|
409
|
+
account=x_stf_account,
|
|
410
|
+
agent_id=agent_id,
|
|
411
|
+
workflow_id=workflow_id,
|
|
412
|
+
)
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
@router.post(
|
|
417
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/postprocess",
|
|
418
|
+
status_code=200,
|
|
419
|
+
description="Add PostProcess Workflows Configuration",
|
|
420
|
+
tags=["Workflows"],
|
|
421
|
+
)
|
|
422
|
+
@requires_one([StashRoles.OWNER])
|
|
423
|
+
async def add_postprocess(
|
|
424
|
+
request: Request,
|
|
425
|
+
agent_id: str,
|
|
426
|
+
workflow_id: str,
|
|
427
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_postprocess)],
|
|
428
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
429
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
430
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
431
|
+
) -> AgentID:
|
|
432
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
433
|
+
|
|
434
|
+
agent_id = await _not_found_as_404(
|
|
435
|
+
agent_manager.add_postprocess(
|
|
436
|
+
agent_id=agent_id,
|
|
437
|
+
account=x_stf_account,
|
|
438
|
+
agent=item,
|
|
439
|
+
workflow_id=workflow_id,
|
|
440
|
+
)
|
|
441
|
+
)
|
|
442
|
+
return AgentID(id=agent_id)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
@router.patch(
|
|
446
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/postprocess/{postprocess}",
|
|
447
|
+
status_code=200,
|
|
448
|
+
description="Set PostProcess Workflows Configuration",
|
|
449
|
+
tags=["Workflows"],
|
|
450
|
+
)
|
|
451
|
+
@requires_one([StashRoles.OWNER])
|
|
452
|
+
async def patch_postprocess(
|
|
453
|
+
request: Request,
|
|
454
|
+
agent_id: str,
|
|
455
|
+
workflow_id: str,
|
|
456
|
+
postprocess: str,
|
|
457
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_postprocess)],
|
|
458
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
459
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
460
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
461
|
+
):
|
|
462
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
463
|
+
|
|
464
|
+
await _not_found_as_404(
|
|
465
|
+
agent_manager.patch_postprocess(
|
|
466
|
+
account=x_stf_account,
|
|
467
|
+
agent_id=agent_id,
|
|
468
|
+
postprocess=postprocess,
|
|
469
|
+
agent=item,
|
|
470
|
+
workflow_id=workflow_id,
|
|
471
|
+
)
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
@router.delete(
|
|
476
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/postprocess/{postprocess}",
|
|
477
|
+
status_code=200,
|
|
478
|
+
description="Delete PostProcess Workflows Configuration",
|
|
479
|
+
tags=["Workflows"],
|
|
480
|
+
)
|
|
481
|
+
@requires_one([StashRoles.OWNER])
|
|
482
|
+
async def delete_postprocess(
|
|
483
|
+
request: Request,
|
|
484
|
+
agent_id: str,
|
|
485
|
+
workflow_id: str,
|
|
486
|
+
postprocess: str,
|
|
487
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
488
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
489
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
490
|
+
):
|
|
491
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
492
|
+
|
|
493
|
+
return await _not_found_as_404(
|
|
494
|
+
agent_manager.delete_postprocess(
|
|
495
|
+
account=x_stf_account,
|
|
496
|
+
agent_id=agent_id,
|
|
497
|
+
postprocess=postprocess,
|
|
498
|
+
workflow_id=workflow_id,
|
|
499
|
+
)
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
@router.get(
|
|
504
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/postprocess",
|
|
505
|
+
status_code=200,
|
|
506
|
+
description="Get PostProcess Workflows Configuration",
|
|
507
|
+
tags=["Workflows"],
|
|
508
|
+
)
|
|
509
|
+
@requires_one([StashRoles.OWNER])
|
|
510
|
+
async def get_postprocess(
|
|
511
|
+
request: Request,
|
|
512
|
+
agent_id: str,
|
|
513
|
+
workflow_id: str,
|
|
514
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
515
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
516
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
517
|
+
) -> List[Any]:
|
|
518
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
519
|
+
|
|
520
|
+
return await _not_found_as_404(
|
|
521
|
+
agent_manager.get_postprocess(
|
|
522
|
+
account=x_stf_account,
|
|
523
|
+
agent_id=agent_id,
|
|
524
|
+
workflow_id=workflow_id,
|
|
525
|
+
)
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
@router.post(
|
|
530
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/context",
|
|
531
|
+
status_code=200,
|
|
532
|
+
description="Add Context Workflows Configuration",
|
|
533
|
+
tags=["Workflows"],
|
|
534
|
+
include_in_schema=False,
|
|
535
|
+
)
|
|
536
|
+
@requires_one([StashRoles.OWNER])
|
|
537
|
+
async def add_context(
|
|
538
|
+
request: Request,
|
|
539
|
+
agent_id: str,
|
|
540
|
+
workflow_id: str,
|
|
541
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_context)],
|
|
542
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
543
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
544
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
545
|
+
) -> AgentID:
|
|
546
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
547
|
+
|
|
548
|
+
agent_id = await _not_found_as_404(
|
|
549
|
+
agent_manager.add_context(
|
|
550
|
+
agent_id=agent_id,
|
|
551
|
+
account=x_stf_account,
|
|
552
|
+
agent=item,
|
|
553
|
+
workflow_id=workflow_id,
|
|
554
|
+
)
|
|
555
|
+
)
|
|
556
|
+
return AgentID(id=agent_id)
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
@router.patch(
|
|
560
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/context/{context}",
|
|
561
|
+
status_code=200,
|
|
562
|
+
description="Set Context Workflows Configuration",
|
|
563
|
+
tags=["Workflows"],
|
|
564
|
+
include_in_schema=False,
|
|
565
|
+
)
|
|
566
|
+
@requires_one([StashRoles.OWNER])
|
|
567
|
+
async def patch_context(
|
|
568
|
+
request: Request,
|
|
569
|
+
agent_id: str,
|
|
570
|
+
workflow_id: str,
|
|
571
|
+
context: UUID,
|
|
572
|
+
item: Annotated[BaseModel, BeforeValidator(validate_agent_context)],
|
|
573
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
574
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
575
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
576
|
+
):
|
|
577
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
578
|
+
|
|
579
|
+
await _not_found_as_404(
|
|
580
|
+
agent_manager.patch_context(
|
|
581
|
+
account=x_stf_account,
|
|
582
|
+
agent_id=agent_id,
|
|
583
|
+
context=context,
|
|
584
|
+
agent=item,
|
|
585
|
+
workflow_id=workflow_id,
|
|
586
|
+
)
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
@router.delete(
|
|
591
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/context/{context}",
|
|
592
|
+
status_code=200,
|
|
593
|
+
description="Delete Context Workflows Configuration",
|
|
594
|
+
tags=["Workflows"],
|
|
595
|
+
include_in_schema=False,
|
|
596
|
+
)
|
|
597
|
+
@requires_one([StashRoles.OWNER])
|
|
598
|
+
async def delete_context(
|
|
599
|
+
request: Request,
|
|
600
|
+
agent_id: str,
|
|
601
|
+
workflow_id: str,
|
|
602
|
+
context: UUID,
|
|
603
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
604
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
605
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
606
|
+
):
|
|
607
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
608
|
+
|
|
609
|
+
return await _not_found_as_404(
|
|
610
|
+
agent_manager.delete_context(
|
|
611
|
+
account=x_stf_account,
|
|
612
|
+
agent_id=agent_id,
|
|
613
|
+
context=context,
|
|
614
|
+
workflow_id=workflow_id,
|
|
615
|
+
)
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
@router.get(
|
|
620
|
+
"/api/v1/agent/{agent_id}/workflow/{workflow_id}/context",
|
|
621
|
+
status_code=200,
|
|
622
|
+
description="Get list of Context Workflows Configuration",
|
|
623
|
+
tags=["Workflows"],
|
|
624
|
+
include_in_schema=False,
|
|
625
|
+
)
|
|
626
|
+
@requires_one([StashRoles.OWNER])
|
|
627
|
+
async def get_context(
|
|
628
|
+
request: Request,
|
|
629
|
+
agent_id: str,
|
|
630
|
+
workflow_id: str,
|
|
631
|
+
x_stf_user: str = Header(..., include_in_schema=False),
|
|
632
|
+
x_stf_account: str = Header(..., include_in_schema=False),
|
|
633
|
+
x_stf_account_type: str = Header(..., include_in_schema=False),
|
|
634
|
+
) -> List[Any]:
|
|
635
|
+
agent_manager: AgentManager = request.app.agent_manager
|
|
636
|
+
|
|
637
|
+
return await _not_found_as_404(
|
|
638
|
+
agent_manager.get_context(
|
|
639
|
+
account=x_stf_account,
|
|
640
|
+
agent_id=agent_id,
|
|
641
|
+
workflow_id=workflow_id,
|
|
642
|
+
)
|
|
643
|
+
)
|
hyperforge/arag.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
from hyperforge.engine import main
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ARAG:
|
|
10
|
+
def run(
|
|
11
|
+
self,
|
|
12
|
+
config_file: str = "definition.yaml",
|
|
13
|
+
question: Optional[str] = None,
|
|
14
|
+
intermediate_steps: bool = True,
|
|
15
|
+
):
|
|
16
|
+
with open(config_file, "r") as file:
|
|
17
|
+
config = yaml.safe_load(file)
|
|
18
|
+
if question is None:
|
|
19
|
+
question = input("Question to do: ")
|
|
20
|
+
if question is None:
|
|
21
|
+
print("No question detected")
|
|
22
|
+
return
|
|
23
|
+
return asyncio.run(
|
|
24
|
+
main(
|
|
25
|
+
config=config,
|
|
26
|
+
question=question,
|
|
27
|
+
)
|
|
28
|
+
)
|