arkaos 2.97.0 → 2.99.0
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.
- package/VERSION +1 -1
- package/core/agents/__pycache__/field_suggester.cpython-313.pyc +0 -0
- package/core/agents/field_suggester.py +133 -0
- package/dashboard/app/components/AgentEditDrawer.vue +107 -1
- package/dashboard/app/pages/personas/[id].vue +92 -0
- package/dashboard/app/pages/personas/new.vue +67 -0
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/__pycache__/dashboard-api.cpython-313.pyc +0 -0
- package/scripts/dashboard-api.py +43 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.99.0
|
|
Binary file
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""AI-assisted list-field suggester for agents and personas (PR81).
|
|
2
|
+
|
|
3
|
+
Generates short lists of `mental_models`, `frameworks`, or
|
|
4
|
+
`expertise_domains` for an entity given its existing context.
|
|
5
|
+
|
|
6
|
+
The LLM is told NOT to duplicate items already present in
|
|
7
|
+
`context["current"]`, and to return a strict JSON array of strings.
|
|
8
|
+
|
|
9
|
+
Used by:
|
|
10
|
+
- POST /api/agents/suggest — ✨ Suggest button in AgentEditDrawer
|
|
11
|
+
- POST /api/personas/suggest — ✨ Suggest button in persona edit slideover
|
|
12
|
+
|
|
13
|
+
The module is provider-agnostic: callers can inject a fake `LLMProvider`
|
|
14
|
+
in tests, and production callers fall back to `get_llm_provider()`.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import re
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
|
|
23
|
+
from core.runtime.llm_provider import LLMProvider, LLMUnavailable, get_llm_provider
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
_VALID_FIELDS: tuple[str, ...] = (
|
|
27
|
+
"mental_models",
|
|
28
|
+
"frameworks",
|
|
29
|
+
"expertise_domains",
|
|
30
|
+
)
|
|
31
|
+
_MAX_COUNT = 12
|
|
32
|
+
_DEFAULT_COUNT = 5
|
|
33
|
+
|
|
34
|
+
_SYSTEM = (
|
|
35
|
+
"You suggest short, concrete items for behavioural agent and persona "
|
|
36
|
+
"profiles. Return ONLY a JSON array of strings. No prose, no fences, no keys."
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
_FIELD_LABELS: dict[str, str] = {
|
|
40
|
+
"mental_models": "mental models",
|
|
41
|
+
"frameworks": "frameworks",
|
|
42
|
+
"expertise_domains": "expertise domains",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class SuggestionError(RuntimeError):
|
|
47
|
+
"""LLM produced unusable output or could not be reached."""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
class SuggestionResult:
|
|
52
|
+
suggestions: list[str]
|
|
53
|
+
provider_name: str
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def suggest_field(
|
|
57
|
+
field: str,
|
|
58
|
+
context: dict,
|
|
59
|
+
*,
|
|
60
|
+
count: int = _DEFAULT_COUNT,
|
|
61
|
+
provider: LLMProvider | None = None,
|
|
62
|
+
) -> SuggestionResult:
|
|
63
|
+
"""Return up to `count` AI-suggested items for the named field."""
|
|
64
|
+
if field not in _VALID_FIELDS:
|
|
65
|
+
raise SuggestionError(f"unknown field: {field!r}")
|
|
66
|
+
count = max(1, min(_MAX_COUNT, int(count)))
|
|
67
|
+
llm = provider or get_llm_provider()
|
|
68
|
+
prompt = _build_prompt(field, context, count)
|
|
69
|
+
try:
|
|
70
|
+
resp = llm.complete(prompt, max_tokens=600, system=_SYSTEM)
|
|
71
|
+
except LLMUnavailable as exc:
|
|
72
|
+
raise SuggestionError(str(exc)) from exc
|
|
73
|
+
items = _parse(resp.text)
|
|
74
|
+
deduped = _dedupe_against_current(items, context.get("current") or [])
|
|
75
|
+
return SuggestionResult(
|
|
76
|
+
suggestions=deduped[:count],
|
|
77
|
+
provider_name=llm.name(),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _build_prompt(field: str, context: dict, count: int) -> str:
|
|
82
|
+
name = (context.get("name") or "").strip() or "the entity"
|
|
83
|
+
role = (context.get("role") or context.get("title") or "").strip()
|
|
84
|
+
department = (context.get("department") or "").strip()
|
|
85
|
+
current = list(context.get("current") or [])[:20]
|
|
86
|
+
lines = [f"Suggest {count} new {_FIELD_LABELS[field]} for {name}."]
|
|
87
|
+
if role:
|
|
88
|
+
lines.append(f"Role: {role}.")
|
|
89
|
+
if department:
|
|
90
|
+
lines.append(f"Department: {department}.")
|
|
91
|
+
if current:
|
|
92
|
+
lines.append(
|
|
93
|
+
"Do NOT repeat any of these items already in the profile: "
|
|
94
|
+
+ ", ".join(current)
|
|
95
|
+
+ "."
|
|
96
|
+
)
|
|
97
|
+
lines.append(
|
|
98
|
+
"Return a JSON array of short strings (2-5 words each). "
|
|
99
|
+
"No explanations, no numbering, no surrounding object."
|
|
100
|
+
)
|
|
101
|
+
return "\n".join(lines)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _parse(text: str) -> list[str]:
|
|
105
|
+
cleaned = re.sub(r"^```(?:json)?\s*|\s*```$", "", text.strip(), flags=re.MULTILINE)
|
|
106
|
+
cleaned = cleaned.strip()
|
|
107
|
+
try:
|
|
108
|
+
data = json.loads(cleaned)
|
|
109
|
+
except (json.JSONDecodeError, ValueError):
|
|
110
|
+
return _fallback_lines(cleaned)
|
|
111
|
+
if not isinstance(data, list):
|
|
112
|
+
return _fallback_lines(cleaned)
|
|
113
|
+
return [str(x).strip() for x in data if str(x).strip()]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _fallback_lines(text: str) -> list[str]:
|
|
117
|
+
items: list[str] = []
|
|
118
|
+
for raw in re.split(r"[\n,]", text):
|
|
119
|
+
line = raw.strip(" \t-*•·0123456789.).\"'`")
|
|
120
|
+
if line and 2 <= len(line) <= 80:
|
|
121
|
+
items.append(line)
|
|
122
|
+
return items
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _dedupe_against_current(items: list[str], current: list) -> list[str]:
|
|
126
|
+
seen = {str(c).strip().lower() for c in current}
|
|
127
|
+
out: list[str] = []
|
|
128
|
+
for item in items:
|
|
129
|
+
key = item.strip().lower()
|
|
130
|
+
if key and key not in seen:
|
|
131
|
+
out.append(item)
|
|
132
|
+
seen.add(key)
|
|
133
|
+
return out
|
|
@@ -110,6 +110,76 @@ function csvToList(value: string): string[] {
|
|
|
110
110
|
return value.split(',').map((s) => s.trim()).filter(Boolean)
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// PR81 v2.99.0 — AI list-field suggester.
|
|
114
|
+
type SuggestField = 'mental_models_primary' | 'frameworks' | 'expertise_domains'
|
|
115
|
+
const suggestingField = ref<SuggestField | null>(null)
|
|
116
|
+
|
|
117
|
+
async function suggest(field: SuggestField) {
|
|
118
|
+
if (!draft.value || !props.agent) return
|
|
119
|
+
const backendField = field === 'mental_models_primary' ? 'mental_models' : field
|
|
120
|
+
const current
|
|
121
|
+
= field === 'mental_models_primary'
|
|
122
|
+
? draft.value.mental_models.primary
|
|
123
|
+
: field === 'frameworks'
|
|
124
|
+
? draft.value.frameworks
|
|
125
|
+
: draft.value.expertise_domains
|
|
126
|
+
suggestingField.value = field
|
|
127
|
+
try {
|
|
128
|
+
const res = await $fetch<{
|
|
129
|
+
suggestions: string[]
|
|
130
|
+
provider_name: string
|
|
131
|
+
error?: string
|
|
132
|
+
}>(`${apiBase}/api/agents/suggest`, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
body: {
|
|
135
|
+
field: backendField,
|
|
136
|
+
count: 5,
|
|
137
|
+
context: {
|
|
138
|
+
name: props.agent.name,
|
|
139
|
+
role: props.agent.role,
|
|
140
|
+
department: props.agent.department,
|
|
141
|
+
current,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
if (res.error) throw new Error(res.error)
|
|
146
|
+
const additions = (res.suggestions ?? []).filter(
|
|
147
|
+
(s) => !current.some((c) => c.toLowerCase() === s.toLowerCase()),
|
|
148
|
+
)
|
|
149
|
+
if (additions.length === 0) {
|
|
150
|
+
toast.add({
|
|
151
|
+
title: 'No new suggestions',
|
|
152
|
+
description: 'The model returned only items you already have.',
|
|
153
|
+
color: 'info',
|
|
154
|
+
})
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
const merged = [...current, ...additions]
|
|
158
|
+
if (field === 'mental_models_primary') {
|
|
159
|
+
draft.value.mental_models.primary = merged
|
|
160
|
+
} else if (field === 'frameworks') {
|
|
161
|
+
draft.value.frameworks = merged
|
|
162
|
+
} else {
|
|
163
|
+
draft.value.expertise_domains = merged
|
|
164
|
+
}
|
|
165
|
+
markDirty()
|
|
166
|
+
toast.add({
|
|
167
|
+
title: `Added ${additions.length} suggestion${additions.length === 1 ? '' : 's'}`,
|
|
168
|
+
description: `via ${res.provider_name}`,
|
|
169
|
+
color: 'success',
|
|
170
|
+
icon: 'i-lucide-sparkles',
|
|
171
|
+
})
|
|
172
|
+
} catch (err) {
|
|
173
|
+
toast.add({
|
|
174
|
+
title: 'Suggestion failed',
|
|
175
|
+
description: err instanceof Error ? err.message : 'unknown error',
|
|
176
|
+
color: 'error',
|
|
177
|
+
})
|
|
178
|
+
} finally {
|
|
179
|
+
suggestingField.value = null
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
113
183
|
async function save() {
|
|
114
184
|
if (!draft.value || !props.agent?.id) return
|
|
115
185
|
saving.value = true
|
|
@@ -254,7 +324,19 @@ const vocabOptions = [
|
|
|
254
324
|
</section>
|
|
255
325
|
|
|
256
326
|
<section class="space-y-3">
|
|
257
|
-
<
|
|
327
|
+
<div class="flex items-center justify-between">
|
|
328
|
+
<h3 class="text-xs font-semibold uppercase tracking-wider text-muted">Mental models</h3>
|
|
329
|
+
<UButton
|
|
330
|
+
label="Suggest with AI"
|
|
331
|
+
icon="i-lucide-sparkles"
|
|
332
|
+
size="xs"
|
|
333
|
+
color="primary"
|
|
334
|
+
variant="soft"
|
|
335
|
+
:loading="suggestingField === 'mental_models_primary'"
|
|
336
|
+
:disabled="suggestingField !== null"
|
|
337
|
+
@click="suggest('mental_models_primary')"
|
|
338
|
+
/>
|
|
339
|
+
</div>
|
|
258
340
|
<UFormField label="Primary" help="comma-separated">
|
|
259
341
|
<UInput
|
|
260
342
|
:model-value="listToCsv(draft.mental_models.primary)"
|
|
@@ -274,6 +356,18 @@ const vocabOptions = [
|
|
|
274
356
|
<section class="space-y-3">
|
|
275
357
|
<h3 class="text-xs font-semibold uppercase tracking-wider text-muted">Expertise</h3>
|
|
276
358
|
<UFormField label="Domains" help="comma-separated">
|
|
359
|
+
<template #hint>
|
|
360
|
+
<UButton
|
|
361
|
+
label="Suggest with AI"
|
|
362
|
+
icon="i-lucide-sparkles"
|
|
363
|
+
size="xs"
|
|
364
|
+
color="primary"
|
|
365
|
+
variant="soft"
|
|
366
|
+
:loading="suggestingField === 'expertise_domains'"
|
|
367
|
+
:disabled="suggestingField !== null"
|
|
368
|
+
@click="suggest('expertise_domains')"
|
|
369
|
+
/>
|
|
370
|
+
</template>
|
|
277
371
|
<UInput
|
|
278
372
|
:model-value="listToCsv(draft.expertise_domains)"
|
|
279
373
|
@update:model-value="(v: string) => { if (draft) { draft.expertise_domains = csvToList(v); markDirty() } }"
|
|
@@ -281,6 +375,18 @@ const vocabOptions = [
|
|
|
281
375
|
/>
|
|
282
376
|
</UFormField>
|
|
283
377
|
<UFormField label="Frameworks" help="comma-separated">
|
|
378
|
+
<template #hint>
|
|
379
|
+
<UButton
|
|
380
|
+
label="Suggest with AI"
|
|
381
|
+
icon="i-lucide-sparkles"
|
|
382
|
+
size="xs"
|
|
383
|
+
color="primary"
|
|
384
|
+
variant="soft"
|
|
385
|
+
:loading="suggestingField === 'frameworks'"
|
|
386
|
+
:disabled="suggestingField !== null"
|
|
387
|
+
@click="suggest('frameworks')"
|
|
388
|
+
/>
|
|
389
|
+
</template>
|
|
284
390
|
<UInput
|
|
285
391
|
:model-value="listToCsv(draft.frameworks)"
|
|
286
392
|
@update:model-value="(v: string) => { if (draft) { draft.frameworks = csvToList(v); markDirty() } }"
|
|
@@ -221,6 +221,62 @@ function csvToList(value: string): string[] {
|
|
|
221
221
|
return value.split(',').map((s) => s.trim()).filter(Boolean)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
// PR81 v2.99.0 — AI list-field suggester for personas.
|
|
225
|
+
type SuggestField = 'mental_models' | 'frameworks' | 'expertise_domains'
|
|
226
|
+
const suggestingField = ref<SuggestField | null>(null)
|
|
227
|
+
|
|
228
|
+
async function suggest(field: SuggestField) {
|
|
229
|
+
if (!draft.value || !detail.value) return
|
|
230
|
+
const current = (draft.value as any)[field] as string[]
|
|
231
|
+
suggestingField.value = field
|
|
232
|
+
try {
|
|
233
|
+
const res = await $fetch<{
|
|
234
|
+
suggestions: string[]
|
|
235
|
+
provider_name: string
|
|
236
|
+
error?: string
|
|
237
|
+
}>(`${apiBase}/api/personas/suggest`, {
|
|
238
|
+
method: 'POST',
|
|
239
|
+
body: {
|
|
240
|
+
field,
|
|
241
|
+
count: 5,
|
|
242
|
+
context: {
|
|
243
|
+
name: detail.value.name,
|
|
244
|
+
title: detail.value.title,
|
|
245
|
+
current,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
})
|
|
249
|
+
if (res.error) throw new Error(res.error)
|
|
250
|
+
const additions = (res.suggestions ?? []).filter(
|
|
251
|
+
(s) => !current.some((c) => c.toLowerCase() === s.toLowerCase()),
|
|
252
|
+
)
|
|
253
|
+
if (additions.length === 0) {
|
|
254
|
+
toast.add({
|
|
255
|
+
title: 'No new suggestions',
|
|
256
|
+
description: 'The model returned only items you already have.',
|
|
257
|
+
color: 'info',
|
|
258
|
+
})
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
;(draft.value as any)[field] = [...current, ...additions]
|
|
262
|
+
markDirty()
|
|
263
|
+
toast.add({
|
|
264
|
+
title: `Added ${additions.length} suggestion${additions.length === 1 ? '' : 's'}`,
|
|
265
|
+
description: `via ${res.provider_name}`,
|
|
266
|
+
color: 'success',
|
|
267
|
+
icon: 'i-lucide-sparkles',
|
|
268
|
+
})
|
|
269
|
+
} catch (err) {
|
|
270
|
+
toast.add({
|
|
271
|
+
title: 'Suggestion failed',
|
|
272
|
+
description: err instanceof Error ? err.message : 'unknown error',
|
|
273
|
+
color: 'error',
|
|
274
|
+
})
|
|
275
|
+
} finally {
|
|
276
|
+
suggestingField.value = null
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
224
280
|
const mbtiOptions = [
|
|
225
281
|
'INTJ', 'INTP', 'ENTJ', 'ENTP',
|
|
226
282
|
'INFJ', 'INFP', 'ENFJ', 'ENFP',
|
|
@@ -627,6 +683,18 @@ const vocabOptions = [
|
|
|
627
683
|
<section class="space-y-3">
|
|
628
684
|
<h3 class="text-xs font-semibold uppercase tracking-wider text-muted">Knowledge</h3>
|
|
629
685
|
<UFormField label="Mental models" help="comma-separated">
|
|
686
|
+
<template #hint>
|
|
687
|
+
<UButton
|
|
688
|
+
label="Suggest with AI"
|
|
689
|
+
icon="i-lucide-sparkles"
|
|
690
|
+
size="xs"
|
|
691
|
+
color="primary"
|
|
692
|
+
variant="soft"
|
|
693
|
+
:loading="suggestingField === 'mental_models'"
|
|
694
|
+
:disabled="suggestingField !== null"
|
|
695
|
+
@click="suggest('mental_models')"
|
|
696
|
+
/>
|
|
697
|
+
</template>
|
|
630
698
|
<UInput
|
|
631
699
|
:model-value="listToCsv(draft.mental_models)"
|
|
632
700
|
@update:model-value="(v: string) => { if (draft) { draft.mental_models = csvToList(v); markDirty() } }"
|
|
@@ -634,6 +702,18 @@ const vocabOptions = [
|
|
|
634
702
|
/>
|
|
635
703
|
</UFormField>
|
|
636
704
|
<UFormField label="Expertise domains" help="comma-separated">
|
|
705
|
+
<template #hint>
|
|
706
|
+
<UButton
|
|
707
|
+
label="Suggest with AI"
|
|
708
|
+
icon="i-lucide-sparkles"
|
|
709
|
+
size="xs"
|
|
710
|
+
color="primary"
|
|
711
|
+
variant="soft"
|
|
712
|
+
:loading="suggestingField === 'expertise_domains'"
|
|
713
|
+
:disabled="suggestingField !== null"
|
|
714
|
+
@click="suggest('expertise_domains')"
|
|
715
|
+
/>
|
|
716
|
+
</template>
|
|
637
717
|
<UInput
|
|
638
718
|
:model-value="listToCsv(draft.expertise_domains)"
|
|
639
719
|
@update:model-value="(v: string) => { if (draft) { draft.expertise_domains = csvToList(v); markDirty() } }"
|
|
@@ -641,6 +721,18 @@ const vocabOptions = [
|
|
|
641
721
|
/>
|
|
642
722
|
</UFormField>
|
|
643
723
|
<UFormField label="Frameworks" help="comma-separated">
|
|
724
|
+
<template #hint>
|
|
725
|
+
<UButton
|
|
726
|
+
label="Suggest with AI"
|
|
727
|
+
icon="i-lucide-sparkles"
|
|
728
|
+
size="xs"
|
|
729
|
+
color="primary"
|
|
730
|
+
variant="soft"
|
|
731
|
+
:loading="suggestingField === 'frameworks'"
|
|
732
|
+
:disabled="suggestingField !== null"
|
|
733
|
+
@click="suggest('frameworks')"
|
|
734
|
+
/>
|
|
735
|
+
</template>
|
|
644
736
|
<UInput
|
|
645
737
|
:model-value="listToCsv(draft.frameworks)"
|
|
646
738
|
@update:model-value="(v: string) => { if (draft) { draft.frameworks = csvToList(v); markDirty() } }"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// PR80 v2.98.0 — /personas/new wraps the 4-step AI PersonaWizard.
|
|
3
|
+
//
|
|
4
|
+
// Fills the dead link that PR78 introduced when it moved the New Persona
|
|
5
|
+
// button into the table header but never built the destination route.
|
|
6
|
+
//
|
|
7
|
+
// Wizard contract (defined in components/PersonaWizard.vue):
|
|
8
|
+
// @completed(persona) → wizard finished + saved; navigate to detail
|
|
9
|
+
// @cancelled → operator backed out; return to the table
|
|
10
|
+
//
|
|
11
|
+
// The wizard never auto-saves; every step is operator-confirmed inside
|
|
12
|
+
// the component, so this page is purely a hosting shell.
|
|
13
|
+
|
|
14
|
+
import type { Persona } from '~/types'
|
|
15
|
+
|
|
16
|
+
const toast = useToast()
|
|
17
|
+
|
|
18
|
+
function onCompleted(persona: Persona) {
|
|
19
|
+
toast.add({
|
|
20
|
+
title: 'Persona created',
|
|
21
|
+
description: `${persona.name} is ready in the library.`,
|
|
22
|
+
color: 'success',
|
|
23
|
+
icon: 'i-lucide-check-circle',
|
|
24
|
+
})
|
|
25
|
+
navigateTo(`/personas/${persona.id}`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function onCancelled() {
|
|
29
|
+
navigateTo('/personas')
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<UDashboardPanel id="personas-new">
|
|
35
|
+
<template #header>
|
|
36
|
+
<UDashboardNavbar title="New Persona">
|
|
37
|
+
<template #leading>
|
|
38
|
+
<UButton
|
|
39
|
+
icon="i-lucide-arrow-left"
|
|
40
|
+
variant="ghost"
|
|
41
|
+
size="sm"
|
|
42
|
+
aria-label="Back to personas"
|
|
43
|
+
to="/personas"
|
|
44
|
+
/>
|
|
45
|
+
</template>
|
|
46
|
+
<template #trailing>
|
|
47
|
+
<UBadge
|
|
48
|
+
label="AI-assisted"
|
|
49
|
+
icon="i-lucide-sparkles"
|
|
50
|
+
color="primary"
|
|
51
|
+
variant="soft"
|
|
52
|
+
size="sm"
|
|
53
|
+
/>
|
|
54
|
+
</template>
|
|
55
|
+
</UDashboardNavbar>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<template #body>
|
|
59
|
+
<div class="max-w-5xl mx-auto py-2">
|
|
60
|
+
<PersonaWizard
|
|
61
|
+
@completed="onCompleted"
|
|
62
|
+
@cancelled="onCancelled"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
</UDashboardPanel>
|
|
67
|
+
</template>
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
Binary file
|
package/scripts/dashboard-api.py
CHANGED
|
@@ -1683,6 +1683,49 @@ def metrics():
|
|
|
1683
1683
|
return {"entries": entries[-50:], "avg_ms": round(avg_ms, 1), "total_calls": len(entries)}
|
|
1684
1684
|
|
|
1685
1685
|
|
|
1686
|
+
# --- AI list-field suggester (PR81 v2.99.0) ---
|
|
1687
|
+
|
|
1688
|
+
@app.post("/api/agents/suggest")
|
|
1689
|
+
def agents_suggest(body: dict):
|
|
1690
|
+
"""Suggest list items for the agent edit drawer via LLM.
|
|
1691
|
+
|
|
1692
|
+
Body: {
|
|
1693
|
+
"field": "mental_models" | "frameworks" | "expertise_domains",
|
|
1694
|
+
"context": {"name", "role", "department", "current": [...]},
|
|
1695
|
+
"count": <optional, default 5, max 12>
|
|
1696
|
+
}
|
|
1697
|
+
Returns: {"suggestions": [...], "provider_name": "...", "source": "agent"}
|
|
1698
|
+
"""
|
|
1699
|
+
return _do_field_suggest(body, source="agent")
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
@app.post("/api/personas/suggest")
|
|
1703
|
+
def personas_suggest(body: dict):
|
|
1704
|
+
"""Suggest list items for the persona edit slideover via LLM.
|
|
1705
|
+
|
|
1706
|
+
Same shape as /api/agents/suggest. `context.title` may be passed
|
|
1707
|
+
instead of `context.role` for personas.
|
|
1708
|
+
"""
|
|
1709
|
+
return _do_field_suggest(body, source="persona")
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
def _do_field_suggest(body: dict, *, source: str) -> dict:
|
|
1713
|
+
from core.agents.field_suggester import SuggestionError, suggest_field
|
|
1714
|
+
|
|
1715
|
+
field = (body.get("field") or "").strip()
|
|
1716
|
+
context = body.get("context") or {}
|
|
1717
|
+
count = body.get("count") or 5
|
|
1718
|
+
try:
|
|
1719
|
+
res = suggest_field(field, context, count=int(count))
|
|
1720
|
+
except SuggestionError as exc:
|
|
1721
|
+
return {"error": str(exc)}
|
|
1722
|
+
return {
|
|
1723
|
+
"suggestions": res.suggestions,
|
|
1724
|
+
"provider_name": res.provider_name,
|
|
1725
|
+
"source": source,
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
|
|
1686
1729
|
if __name__ == "__main__":
|
|
1687
1730
|
import argparse
|
|
1688
1731
|
parser = argparse.ArgumentParser()
|