forked from r.muellner/velum-raycast
Initial commit: Velum Raycast extension
Pseudonymize-and-AI workflow for handling PII-sensitive text via the Velum API and Raycast AI. Commands cover end-to-end email summary and reply, briefing/action-items/structured-data extraction, manual pseudonymize/depseudonymize on selection or clipboard, and session management. Includes Raycast 2.0 Beta workarounds for selection capture and rich-text clipboard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
58
src/summarize.ts
Normal file
58
src/summarize.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { AI } from "@raycast/api";
|
||||
|
||||
export type Creativity = "none" | "low" | "medium" | "high";
|
||||
|
||||
export function buildSummaryPrompt(
|
||||
pseudonymizedText: string,
|
||||
instructions?: string,
|
||||
): string {
|
||||
const extra = instructions?.trim()
|
||||
? `\n\nZusätzliche Anweisungen des Nutzers:\n${instructions.trim()}`
|
||||
: "";
|
||||
|
||||
return [
|
||||
"Du erhältst eine pseudonymisierte Email-Konversation.",
|
||||
"Personenbezogene Daten wurden bereits durch Platzhalter wie <PERSON_1>, <EMAIL_2>, <ORG_3>, <PHONE_4>, <ADDRESS_5> ersetzt.",
|
||||
"",
|
||||
"STRENGE REGEL: Gib jeden Platzhalter zeichengetreu (inklusive spitzer Klammern, Großbuchstaben und Unterstrich + Nummer) zurück.",
|
||||
"Du darfst Platzhalter NIEMALS auflösen, raten, übersetzen oder mit erfundenen Namen ersetzen. Schreibe sie exakt so, wie sie in der Eingabe stehen.",
|
||||
"",
|
||||
"Aufgabe: Erstelle eine prägnante deutschsprachige Zusammenfassung der Konversation mit folgenden Abschnitten als Markdown:",
|
||||
"- **Teilnehmer**: Liste der beteiligten Platzhalter, ggf. mit Rolle (Absender/Empfänger).",
|
||||
"- **Anliegen**: Worum geht es im Kern?",
|
||||
"- **Verlauf**: Chronologische Kurzfassung der wichtigsten Punkte.",
|
||||
"- **Offene Punkte / Action Items**: Was ist noch zu tun, von wem, bis wann.",
|
||||
"",
|
||||
"Antworte ausschließlich in Markdown, ohne einleitende Floskeln.",
|
||||
extra,
|
||||
"",
|
||||
"--- Email-Konversation (pseudonymisiert) ---",
|
||||
pseudonymizedText,
|
||||
"--- Ende der Konversation ---",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
export type SummaryStreamOptions = {
|
||||
prompt: string;
|
||||
model: string;
|
||||
creativity: Creativity;
|
||||
signal?: AbortSignal;
|
||||
onChunk: (chunk: string) => void;
|
||||
};
|
||||
|
||||
export async function runSummaryStream(
|
||||
options: SummaryStreamOptions,
|
||||
): Promise<string> {
|
||||
let buffer = "";
|
||||
const stream = AI.ask(options.prompt, {
|
||||
model: options.model as AI.Model,
|
||||
creativity: options.creativity,
|
||||
signal: options.signal,
|
||||
});
|
||||
stream.on("data", (chunk) => {
|
||||
buffer += chunk;
|
||||
options.onChunk(chunk);
|
||||
});
|
||||
await stream;
|
||||
return buffer;
|
||||
}
|
||||
Reference in New Issue
Block a user