refactor: remove personas
Personas were a misread requirement: SOUL is the chat identity and identities are per action. The selected persona's prompt never reached the model. Drops the resource, /personality, the chat selector, the settings page and ChatService.SetPersona, and deletes stored persona documents.
This commit is contained in:
46 files changed
+384
-1416
No files matched your search
@@ -2,35 +2,25 @@
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { selectorData, setModel, setPersona } from "./state";
|
||||
import { selectorData, setModel } from "./state";
|
||||
|
||||
const props = defineProps<{ choose: "model" | "personality" }>();
|
||||
defineProps<{ choose: "model" }>();
|
||||
|
||||
const options = computed(() =>
|
||||
props.choose === "model" ? (selectorData.value.models ?? []) : (selectorData.value.personas ?? []),
|
||||
);
|
||||
const active = computed(() =>
|
||||
props.choose === "model" ? selectorData.value.active_model : selectorData.value.active_persona,
|
||||
);
|
||||
|
||||
function pick(value: string) {
|
||||
if (props.choose === "model") void setModel(value);
|
||||
else setPersona(value);
|
||||
}
|
||||
const options = computed(() => selectorData.value.models ?? []);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="text-sm">
|
||||
<p class="font-medium">{{ choose === "model" ? "Choose a model" : "Choose a personality" }}</p>
|
||||
<p class="font-medium">Choose a model</p>
|
||||
<p v-if="!options.length" class="mt-1 text-fg-muted">None configured.</p>
|
||||
<div v-else class="mt-2 flex flex-wrap gap-2">
|
||||
<Button
|
||||
v-for="option in options"
|
||||
:key="option"
|
||||
size="sm"
|
||||
:variant="option === active ? 'default' : 'outline'"
|
||||
:variant="option === selectorData.active_model ? 'default' : 'outline'"
|
||||
class="font-mono"
|
||||
@click="pick(option)"
|
||||
@click="void setModel(option)"
|
||||
>{{ option }}</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -20,11 +20,9 @@ import {
|
||||
import {
|
||||
currentModels,
|
||||
selectedModel,
|
||||
selectedPersona,
|
||||
selectedProvider,
|
||||
selectorData,
|
||||
setModel,
|
||||
setPersona,
|
||||
setProvider,
|
||||
statusText,
|
||||
useEscapeLayer,
|
||||
@@ -49,7 +47,6 @@ const DEFAULT = "__default__";
|
||||
const open = ref(false);
|
||||
useEscapeLayer(open);
|
||||
|
||||
const personaValue = computed(() => selectedPersona.value || DEFAULT);
|
||||
const providerValue = computed(() => selectedProvider.value || DEFAULT);
|
||||
const modelValue = computed(() => selectedModel.value || DEFAULT);
|
||||
|
||||
@@ -73,29 +70,6 @@ function clear(value: unknown): string {
|
||||
<PopoverContent align="end" class="grid w-64 gap-3">
|
||||
<span class="text-xs text-fg-subtle">{{ statusText }}</span>
|
||||
|
||||
<Field class="gap-1">
|
||||
<FieldLabel class="text-xs text-fg-muted">Personality</FieldLabel>
|
||||
<Select
|
||||
:model-value="personaValue"
|
||||
@update:model-value="setPersona(clear($event))"
|
||||
>
|
||||
<SelectTrigger size="sm" class="w-full" aria-label="Personality">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem :value="DEFAULT">Default</SelectItem>
|
||||
<SelectItem
|
||||
v-for="name in selectorData.personas || []"
|
||||
:key="name"
|
||||
:value="name"
|
||||
>{{ name }}</SelectItem
|
||||
>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field v-if="(selectorData.providers || []).length" class="gap-1">
|
||||
<FieldLabel class="text-xs text-fg-muted">Provider</FieldLabel>
|
||||
<Select
|
||||
|
||||
+6
-34
@@ -93,8 +93,8 @@ export interface ChatMessage {
|
||||
MessageID?: string;
|
||||
/** An update check answered in the panel, with its install actions. */
|
||||
update?: ChatUpdate;
|
||||
/** A bare /model or /personality, answered with its choices. */
|
||||
choose?: "model" | "personality";
|
||||
/** A bare /model, answered with its choices. */
|
||||
choose?: "model";
|
||||
}
|
||||
|
||||
/** The update snapshot /update shows, and whether this host can install it. */
|
||||
@@ -126,12 +126,9 @@ export interface ChatAsk {
|
||||
|
||||
/** Everything the selectors on the panel read, from one sessions read. */
|
||||
export interface ChatSelectorData {
|
||||
personas?: string[];
|
||||
providers?: string[];
|
||||
models?: string[];
|
||||
models_by_provider?: Record<string, string[]>;
|
||||
active_persona?: string;
|
||||
active_personas?: Record<string, string>;
|
||||
active_provider?: string;
|
||||
active_model?: string;
|
||||
commands?: Array<ChatCommandSpec | string>;
|
||||
@@ -178,7 +175,6 @@ export const isSending = ref(false);
|
||||
export const streamingTurn = ref<StreamingTurn | null>(null);
|
||||
|
||||
export const selectorData = ref<ChatSelectorData>({});
|
||||
export const selectedPersona = ref("");
|
||||
export const selectedProvider = ref("");
|
||||
export const selectedModel = ref("");
|
||||
|
||||
@@ -235,7 +231,6 @@ export async function refreshSessions(): Promise<void> {
|
||||
sessions.value = sessionList;
|
||||
selectorData.value = data;
|
||||
|
||||
selectedPersona.value = data.active_persona || "";
|
||||
const providers = data.providers || [];
|
||||
selectedProvider.value = data.active_provider || providers[0] || "";
|
||||
selectedModel.value = data.active_model || "";
|
||||
@@ -256,13 +251,10 @@ export async function refreshSessions(): Promise<void> {
|
||||
|
||||
export async function selectSession(id: string): Promise<void> {
|
||||
if (!id) return;
|
||||
const data = selectorData.value;
|
||||
currentSession.value = id;
|
||||
messages.value = [];
|
||||
streamingTurn.value = null;
|
||||
|
||||
selectedPersona.value =
|
||||
data.active_personas?.[id] || data.active_persona || "";
|
||||
|
||||
try {
|
||||
// Resuming is the server's own command, so the transcript read below is of
|
||||
@@ -327,25 +319,6 @@ export function promptSessionCommand(command: string, message: string): void {
|
||||
if (value?.trim()) void runSessionCommand(`${command} ${value.trim()}`);
|
||||
}
|
||||
|
||||
export function setPersona(name: string): void {
|
||||
selectedPersona.value = name;
|
||||
const session = currentSession.value;
|
||||
if (!session || !name) return;
|
||||
api
|
||||
.chatPersona(session, name)
|
||||
.then(() => {
|
||||
const data = selectorData.value;
|
||||
selectorData.value = {
|
||||
...data,
|
||||
active_personas: { ...(data.active_personas || {}), [session]: name },
|
||||
};
|
||||
statusText.value = `Personality: ${name}`;
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
statusText.value = err.message || "Failed to set personality";
|
||||
});
|
||||
}
|
||||
|
||||
export async function setProvider(provider: string): Promise<void> {
|
||||
selectedProvider.value = provider;
|
||||
if (!provider) return;
|
||||
@@ -425,11 +398,10 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
||||
composerText.value = "";
|
||||
}
|
||||
|
||||
// Bare /model and /personality offer their choices as buttons, as Telegram
|
||||
// does; with an argument they go to the gateway like any command.
|
||||
if (!isRetry && (text.trim() === "/model" || text.trim() === "/personality")) {
|
||||
const choose = text.trim() === "/model" ? "model" : "personality";
|
||||
messages.value = [...messages.value, { from: "assistant", text: "", choose }];
|
||||
// A bare /model offers its choices as buttons, as Telegram does; with an
|
||||
// argument it goes to the gateway like any command.
|
||||
if (!isRetry && text.trim() === "/model") {
|
||||
messages.value = [...messages.value, { from: "assistant", text: "", choose: "model" }];
|
||||
isSending.value = false;
|
||||
statusText.value = "Ready";
|
||||
return;
|
||||
|
||||
@@ -416,11 +416,6 @@ export const api = {
|
||||
page: location.pathname + location.search || "/",
|
||||
},
|
||||
}),
|
||||
chatPersona: <T = unknown>(sessionID: string, name: string) =>
|
||||
request<T>("/api/chat/persona", {
|
||||
method: "POST",
|
||||
body: { session_id: sessionID, name },
|
||||
}),
|
||||
// A server-sent event stream cannot be parsed as JSON and outlives a normal
|
||||
// request, so the caller owns the abort controller and the timeout, and
|
||||
// reads the body itself. Only the URL, headers, and failure shape are shared.
|
||||
|
||||
@@ -49,7 +49,6 @@ const settings: NavSpec = {
|
||||
label: "Agents",
|
||||
paths: [
|
||||
"/settings/soul",
|
||||
"/settings/personas",
|
||||
"/settings/agent-profiles",
|
||||
"/settings/models",
|
||||
"/settings/skills",
|
||||
|
||||
+1
-14
@@ -16,7 +16,6 @@ import SchedulingPolicyPage from "@/settings/SchedulingPolicyPage.vue";
|
||||
import ReviewSettingsPage from "@/settings/ReviewSettingsPage.vue";
|
||||
import ToolsPage from "@/settings/ToolsPage.vue";
|
||||
import HistoryPage from "@/settings/HistoryPage.vue";
|
||||
import PersonasPage from "@/settings/PersonasPage.vue";
|
||||
import SoulPage from "@/settings/SoulPage.vue";
|
||||
import SchedulesPage from "@/settings/SchedulesPage.vue";
|
||||
import ExtensionsPage from "@/settings/ExtensionsPage.vue";
|
||||
@@ -259,18 +258,6 @@ const routes = [
|
||||
section: "channels",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/personas",
|
||||
name: "settings-personas",
|
||||
component: PersonasPage,
|
||||
meta: {
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Personas",
|
||||
description: "Chat system prompts and the default.",
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/soul",
|
||||
name: "settings-soul",
|
||||
@@ -417,7 +404,7 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: "/settings",
|
||||
redirect: "/settings/personas",
|
||||
redirect: "/settings/soul",
|
||||
meta: {
|
||||
label: "Settings",
|
||||
},
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { Copy, Plus, Trash2 } from "@lucide/vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
||||
import HistoryLink from "./HistoryLink.vue";
|
||||
import {
|
||||
duplicatePersona,
|
||||
removePersona,
|
||||
renamePersona,
|
||||
type PersonaCollection,
|
||||
} from "./personas";
|
||||
|
||||
const KIND = "personas";
|
||||
|
||||
const store = useSettingsStore();
|
||||
const { catalog, catalogError } = storeToRefs(store);
|
||||
onMounted(store.load);
|
||||
|
||||
const resources = computed(() => resourcesForPage(catalog.value, "personas"));
|
||||
const collection = computed(() => store.drafts[KIND]?.value as PersonaCollection | undefined);
|
||||
const error = computed(() => store.pageErrorFor(KIND));
|
||||
|
||||
const filter = ref("");
|
||||
const selected = ref(0);
|
||||
const shown = computed(() =>
|
||||
(collection.value?.personas ?? [])
|
||||
.map((persona, index) => ({ persona, index }))
|
||||
.filter(({ persona }) => persona.name.toLowerCase().includes(filter.value.trim().toLowerCase())),
|
||||
);
|
||||
const current = computed(() => collection.value?.personas[selected.value]);
|
||||
const isDefault = computed(() => !!current.value && collection.value?.default === current.value.name);
|
||||
const chars = computed(() => current.value?.prompt.length ?? 0);
|
||||
|
||||
function add() {
|
||||
const c = collection.value;
|
||||
if (!c) return;
|
||||
const taken = new Set(c.personas.map((p) => p.name));
|
||||
let name = "new-persona";
|
||||
for (let n = 2; taken.has(name); n++) name = `new-persona-${n}`;
|
||||
c.personas.push({ name, prompt: "" });
|
||||
selected.value = c.personas.length - 1;
|
||||
}
|
||||
function duplicate() {
|
||||
if (collection.value) selected.value = duplicatePersona(collection.value, selected.value);
|
||||
}
|
||||
function remove() {
|
||||
if (collection.value && removePersona(collection.value, selected.value))
|
||||
selected.value = Math.max(0, selected.value - 1);
|
||||
}
|
||||
function rename(name: string | number) {
|
||||
if (collection.value) renamePersona(collection.value, selected.value, String(name));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Personas">
|
||||
<HistoryLink :kinds="resources.map((r) => r.kind)" />
|
||||
</PageHeader>
|
||||
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
|
||||
|
||||
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">
|
||||
{{ catalogError || error }}
|
||||
</p>
|
||||
|
||||
<div v-if="collection" class="grid gap-6 md:grid-cols-[16rem_1fr]">
|
||||
<div class="flex min-w-0 flex-col gap-2">
|
||||
<div class="flex gap-2">
|
||||
<Input v-model="filter" placeholder="Filter" aria-label="Filter personas" />
|
||||
<Button variant="outline" size="icon" aria-label="New persona" @click="add"><Plus /></Button>
|
||||
</div>
|
||||
<ul class="flex flex-col gap-0.5" aria-label="Personas">
|
||||
<li v-for="{ persona, index } in shown" :key="index">
|
||||
<button
|
||||
type="button"
|
||||
:aria-current="index === selected ? 'true' : undefined"
|
||||
:class="
|
||||
cn(
|
||||
'w-full rounded-md px-3 py-2 text-left transition-colors hover:bg-secondary',
|
||||
index === selected && 'bg-secondary',
|
||||
)
|
||||
"
|
||||
@click="selected = index"
|
||||
>
|
||||
<span class="flex items-center gap-2">
|
||||
<span class="truncate font-mono text-[13px]" :class="index === selected && 'font-medium'">{{
|
||||
persona.name || "unnamed"
|
||||
}}</span>
|
||||
<Badge v-if="collection.default === persona.name" variant="outline">Default</Badge>
|
||||
</span>
|
||||
<span class="block truncate text-xs text-fg-subtle">{{ persona.prompt || "No prompt yet" }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<section v-if="current" class="min-w-0 rounded-lg border border-border bg-card px-5 pt-4 pb-2" aria-label="Persona">
|
||||
<header class="flex items-center gap-2">
|
||||
<h2 class="min-w-0 flex-1 truncate font-mono text-[15px] font-medium">{{ current.name || "unnamed" }}</h2>
|
||||
<Button variant="ghost" size="sm" @click="duplicate"><Copy data-icon="inline-start" />Duplicate</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="text-danger"
|
||||
:disabled="collection.personas.length <= 1"
|
||||
@click="remove"
|
||||
><Trash2 data-icon="inline-start" />Delete</Button
|
||||
>
|
||||
</header>
|
||||
<SettingRow label="Name" for="persona-name">
|
||||
<Input id="persona-name" :model-value="current.name" class="max-w-sm font-mono" @update:model-value="rename" />
|
||||
</SettingRow>
|
||||
<SettingRow label="Default persona">
|
||||
<Switch
|
||||
:model-value="isDefault"
|
||||
:disabled="isDefault"
|
||||
aria-label="Default persona"
|
||||
@update:model-value="(on: boolean) => on && (collection!.default = current!.name)"
|
||||
/>
|
||||
</SettingRow>
|
||||
<div class="border-t border-border py-4">
|
||||
<label for="persona-prompt" class="text-[13px] font-medium">System prompt</label>
|
||||
<Textarea id="persona-prompt" v-model="current.prompt" :rows="12" class="mt-2 font-mono text-[13px]" />
|
||||
<p class="mt-1.5 text-xs text-fg-subtle">{{ chars.toLocaleString() }} chars · ~{{ Math.round(chars / 4).toLocaleString() }} tokens</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,34 +0,0 @@
|
||||
/** The personas resource document. */
|
||||
export interface PersonaCollection {
|
||||
default: string;
|
||||
personas: { name: string; prompt: string }[];
|
||||
}
|
||||
|
||||
// The collection must always name a default that exists (the server refuses
|
||||
// one that does not), so every edit that touches a name keeps it valid.
|
||||
|
||||
export function renamePersona(c: PersonaCollection, index: number, name: string): void {
|
||||
const persona = c.personas[index];
|
||||
if (!persona) return;
|
||||
if (c.default === persona.name) c.default = name;
|
||||
persona.name = name;
|
||||
}
|
||||
|
||||
/** removePersona deletes one persona; the last one cannot go. */
|
||||
export function removePersona(c: PersonaCollection, index: number): boolean {
|
||||
if (c.personas.length <= 1 || !c.personas[index]) return false;
|
||||
const [removed] = c.personas.splice(index, 1);
|
||||
if (removed!.name === c.default) c.default = c.personas[0]!.name;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** duplicatePersona copies one persona under a free name and returns its index. */
|
||||
export function duplicatePersona(c: PersonaCollection, index: number): number {
|
||||
const source = c.personas[index];
|
||||
if (!source) return -1;
|
||||
const taken = new Set(c.personas.map((p) => p.name));
|
||||
let name = `${source.name}-copy`;
|
||||
for (let n = 2; taken.has(name); n++) name = `${source.name}-copy-${n}`;
|
||||
c.personas.splice(index + 1, 0, { name, prompt: source.prompt });
|
||||
return index + 1;
|
||||
}
|
||||
@@ -181,7 +181,6 @@ export type ControlPlanePage =
|
||||
| "channels"
|
||||
| "scheduling"
|
||||
| "tools"
|
||||
| "personas"
|
||||
| "soul"
|
||||
| "schedules"
|
||||
| "plugins"
|
||||
@@ -195,7 +194,6 @@ const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
|
||||
channels: ["channel-settings"],
|
||||
scheduling: ["scheduling-policy"],
|
||||
tools: ["tool-settings"],
|
||||
personas: ["personas"],
|
||||
soul: ["soul"],
|
||||
schedules: ["schedules"],
|
||||
plugins: ["plugin-settings"],
|
||||
|
||||
Reference in new issue
Block a user