forked from r.muellner/velum-raycast
feat: choose project or session for text commands
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
Toast,
|
||||
useNavigation,
|
||||
} from "@raycast/api";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
type Creativity,
|
||||
CREATIVITY_OPTIONS,
|
||||
@@ -20,20 +20,15 @@ import {
|
||||
} from "./ai";
|
||||
import { PseudonymizationConfirm } from "./ai-views";
|
||||
import { getSelectedTextSafely } from "./selection";
|
||||
import { ContextPicker, type ContextFormValues } from "./context-picker";
|
||||
import { pseudonymizeInContext } from "./text-context";
|
||||
import {
|
||||
createSession,
|
||||
getActiveSessionId,
|
||||
getSession,
|
||||
listSessions,
|
||||
setActiveSession,
|
||||
updateSessionMapping,
|
||||
} from "./sessions";
|
||||
import type { EntityType, VelumSession } from "./types";
|
||||
import { NEW_SESSION_ID } from "./ui";
|
||||
import {
|
||||
getEntityTypes,
|
||||
normalizePseudonymizeResponse,
|
||||
pseudonymize,
|
||||
} from "./velum";
|
||||
|
||||
function buildActionItemsPrompt(
|
||||
@@ -72,9 +67,8 @@ function buildActionItemsPrompt(
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
type FormValues = {
|
||||
type FormValues = ContextFormValues & {
|
||||
text: string;
|
||||
sessionId: string;
|
||||
entityTypes: string[];
|
||||
model: string;
|
||||
creativity: Creativity;
|
||||
@@ -120,11 +114,6 @@ export default function Command() {
|
||||
load();
|
||||
}, []);
|
||||
|
||||
const defaultSessionId = useMemo(
|
||||
() => activeSessionId || sessions[0]?.id || NEW_SESSION_ID,
|
||||
[activeSessionId, sessions],
|
||||
);
|
||||
|
||||
async function loadSelectedText() {
|
||||
const selected = await getSelectedTextSafely();
|
||||
if (!selected) {
|
||||
@@ -167,23 +156,8 @@ export default function Command() {
|
||||
});
|
||||
|
||||
try {
|
||||
const session =
|
||||
values.sessionId === NEW_SESSION_ID
|
||||
? await createSession()
|
||||
: ((await getSession(values.sessionId)) ?? (await createSession()));
|
||||
await setActiveSession(session.id);
|
||||
|
||||
const rawResult = await pseudonymize(
|
||||
input,
|
||||
session.mapping,
|
||||
values.entityTypes,
|
||||
);
|
||||
const pseudoResult = normalizePseudonymizeResponse(rawResult);
|
||||
const updatedSession = await updateSessionMapping(
|
||||
session.id,
|
||||
pseudoResult.mapping,
|
||||
pseudoResult.selected_entity_types,
|
||||
);
|
||||
const { result: pseudoResult, session: updatedSession } =
|
||||
await pseudonymizeInContext(values, input, values.entityTypes, true);
|
||||
|
||||
toast.style = Toast.Style.Success;
|
||||
toast.title = "Pseudonymisiert";
|
||||
@@ -243,27 +217,8 @@ export default function Command() {
|
||||
onChange={setText}
|
||||
placeholder="Meeting-Notizen, Email-Thread, Transkript …"
|
||||
/>
|
||||
<Form.Dropdown
|
||||
id="sessionId"
|
||||
title="Sitzung"
|
||||
defaultValue={defaultSessionId}
|
||||
>
|
||||
<Form.Dropdown.Item
|
||||
value={NEW_SESSION_ID}
|
||||
title="Neue Sitzung"
|
||||
icon={Icon.Plus}
|
||||
/>
|
||||
{sessions.map((session) => (
|
||||
<Form.Dropdown.Item
|
||||
key={session.id}
|
||||
value={session.id}
|
||||
title={session.name}
|
||||
icon={
|
||||
session.id === activeSessionId ? Icon.CheckCircle : Icon.Circle
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Form.Dropdown>
|
||||
<ContextPicker sessions={sessions} activeSessionId={activeSessionId}
|
||||
availableEntityTypes={entityTypes} onEntityTypesChange={setSelectedEntityTypes} />
|
||||
{entityTypes.length > 0 ? (
|
||||
<Form.TagPicker
|
||||
id="entityTypes"
|
||||
|
||||
Reference in New Issue
Block a user