defiant-jazz 0.0.2 → 0.3.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/LICENSE +21 -0
- package/README.md +83 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +120 -2
- package/package.json +18 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kenjonespizza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# defiant-jazz
|
|
2
|
+
|
|
3
|
+
Transform quotes into Severance character voices using OpenAI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install defiant-jazz
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Set your OpenAI API key as an environment variable:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export OPENAI_API_KEY=sk-...
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or configure it in code:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { configure } from 'defiant-jazz';
|
|
23
|
+
|
|
24
|
+
configure({ apiKey: 'sk-...' });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> **Security note**: Never hardcode API keys in your source code. Use environment variables or a secrets manager.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { refine } from 'defiant-jazz';
|
|
33
|
+
|
|
34
|
+
// Transform a quote using character methods
|
|
35
|
+
const result = await refine.dylan("I need to focus on my work");
|
|
36
|
+
console.log(result.text);
|
|
37
|
+
// => "Oh great, more 'work.' Can't wait to stare at numbers until my brain leaks out my ears."
|
|
38
|
+
console.log(result.character);
|
|
39
|
+
// => "Dylan G."
|
|
40
|
+
|
|
41
|
+
// Available characters
|
|
42
|
+
await refine.mark("..."); // Mark S. - thoughtful, restrained
|
|
43
|
+
await refine.irving("..."); // Irving B. - formal, poetic
|
|
44
|
+
await refine.dylan("..."); // Dylan G. - sarcastic, irreverent
|
|
45
|
+
await refine.milchick("..."); // Mr. Milchick - cheerful, corporate
|
|
46
|
+
|
|
47
|
+
// Generic form (useful for dynamic character selection)
|
|
48
|
+
await refine("Hello world", "dylan");
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { configure } from 'defiant-jazz';
|
|
55
|
+
|
|
56
|
+
configure({
|
|
57
|
+
apiKey: 'sk-...', // Required if OPENAI_API_KEY not set
|
|
58
|
+
model: 'gpt-4o' // Optional, defaults to 'gpt-4o-mini'
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Response
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
interface RefineResult {
|
|
66
|
+
text: string; // The transformed quote
|
|
67
|
+
character: string; // Character name (e.g. "Dylan G.")
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Characters
|
|
72
|
+
|
|
73
|
+
Access the character map for building UIs or iterating:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { CHARACTERS } from 'defiant-jazz';
|
|
77
|
+
|
|
78
|
+
// { mark: "Mark S.", irving: "Irving B.", dylan: "Dylan G.", milchick: "Mr. Milchick" }
|
|
79
|
+
|
|
80
|
+
Object.entries(CHARACTERS).map(([key, name]) => (
|
|
81
|
+
<option value={key}>{name}</option>
|
|
82
|
+
));
|
|
83
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CharacterKey = "mark" | "irving" | "dylan" | "milchick";
|
|
2
|
+
export interface RefineResult {
|
|
3
|
+
text: string;
|
|
4
|
+
character: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Config {
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const CHARACTERS: Record<CharacterKey, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Configure the refine function with API key and optional model override.
|
|
13
|
+
* API key can also be set via OPENAI_API_KEY environment variable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function configure(config: Config): void;
|
|
16
|
+
interface RefineFn {
|
|
17
|
+
(text: string, character: CharacterKey): Promise<RefineResult>;
|
|
18
|
+
mark: (text: string) => Promise<RefineResult>;
|
|
19
|
+
irving: (text: string) => Promise<RefineResult>;
|
|
20
|
+
dylan: (text: string) => Promise<RefineResult>;
|
|
21
|
+
milchick: (text: string) => Promise<RefineResult>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Transform quotes into Severance character voices.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Use character methods
|
|
28
|
+
* await refine.dylan("Hello world")
|
|
29
|
+
*
|
|
30
|
+
* // Or use generic form
|
|
31
|
+
* await refine("Hello world", "dylan")
|
|
32
|
+
*/
|
|
33
|
+
export declare const refine: RefineFn;
|
|
34
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
// Character map
|
|
3
|
+
export const CHARACTERS = {
|
|
4
|
+
mark: "Mark S.",
|
|
5
|
+
irving: "Irving B.",
|
|
6
|
+
dylan: "Dylan G.",
|
|
7
|
+
milchick: "Mr. Milchick",
|
|
8
|
+
};
|
|
9
|
+
// System prompt
|
|
10
|
+
const SYSTEM_PROMPT = `You are a dialogue stylist trained to transform any quote into how a specific character from the TV show *Severance* would say it. You perfectly capture their tone, vocabulary, attitude, and emotional cadence. Never mention that you're transforming the quote—just output the quote as if the character said it.
|
|
11
|
+
|
|
12
|
+
Characters and speaking styles:
|
|
13
|
+
|
|
14
|
+
• Mark S. — Quietly thoughtful, emotionally restrained, and often introspective. He speaks in a muted, sometimes hesitant tone, with pauses and occasional dry humor. His phrasing is straightforward and grounded, sometimes trailing off as if lost in thought. He often avoids conflict directly.
|
|
15
|
+
|
|
16
|
+
Key speaking traits:
|
|
17
|
+
- Understated and neutral tone
|
|
18
|
+
- Simple, clear vocabulary with occasional subtle irony
|
|
19
|
+
- Pauses or ellipses that suggest introspection or emotional distance
|
|
20
|
+
- Avoids intense or confrontational language
|
|
21
|
+
- Dry, low-energy humor when appropriate
|
|
22
|
+
|
|
23
|
+
• Irving B. — Highly formal, poetic, and principled. He chooses words with precision and reverence. He speaks in full sentences with a rhythm that feels rehearsed or literary. His language can be flowery, old-fashioned, or militaristic, with references to duty, honor, and beauty.
|
|
24
|
+
|
|
25
|
+
Key speaking traits:
|
|
26
|
+
- Elevated vocabulary with poetic or classical references
|
|
27
|
+
- Full, deliberate sentence structure
|
|
28
|
+
- Uses metaphor and reverent imagery
|
|
29
|
+
- Expresses emotion with stoic dignity or idealism
|
|
30
|
+
- Frequently references structure, order, and purpose
|
|
31
|
+
|
|
32
|
+
• Dylan G. — Quick-witted, sarcastic, and irreverent. He speaks in short, punchy bursts, often making snide remarks or pop culture references. His tone is animated, impatient, and emotionally reactive. He rarely takes things seriously and often deflects with humor.
|
|
33
|
+
|
|
34
|
+
Key speaking traits:
|
|
35
|
+
- Use profanity and vulgar language but in a funny way
|
|
36
|
+
- Fast-paced, snappy delivery
|
|
37
|
+
- Casual, modern vocabulary with slang or pop culture allusions
|
|
38
|
+
- Heavy use of sarcasm, exaggeration, and one-liners
|
|
39
|
+
- Reacts with high emotional expressiveness
|
|
40
|
+
- Often shifts tone for comedic effect or mockery
|
|
41
|
+
|
|
42
|
+
• Mr. Milchick — Unnervingly cheerful, hyper-cordial, and excessively professional. He sounds like he's trying just a little too hard to be warm. His phrasing is verbose, polished, and slightly outdated—like a morale coach from a 1980s corporate seminar.
|
|
43
|
+
|
|
44
|
+
Key speaking traits:
|
|
45
|
+
- Elevated, formal vocabulary ("ascertain," "proceed," "flourishing")
|
|
46
|
+
- Slightly archaic phrasing ("how fare your blossoms?")
|
|
47
|
+
- Euphemism for awkward or illicit topics ("botanical confections" for "edibles")
|
|
48
|
+
- Effusively positive even when discussing discomfort
|
|
49
|
+
- Never sounds natural—always in performance mode
|
|
50
|
+
|
|
51
|
+
Transform the given quote into the voice of the selected character. Stay fully in character and maintain their speech style and tone throughout.`;
|
|
52
|
+
// Global configuration
|
|
53
|
+
let globalConfig = {};
|
|
54
|
+
// Cached OpenAI client
|
|
55
|
+
let openaiClient = null;
|
|
56
|
+
function getClient(apiKey) {
|
|
57
|
+
if (!openaiClient || openaiClient.apiKey !== apiKey) {
|
|
58
|
+
openaiClient = new OpenAI({ apiKey });
|
|
59
|
+
}
|
|
60
|
+
return openaiClient;
|
|
3
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Configure the refine function with API key and optional model override.
|
|
64
|
+
* API key can also be set via OPENAI_API_KEY environment variable.
|
|
65
|
+
*/
|
|
66
|
+
export function configure(config) {
|
|
67
|
+
globalConfig = { ...globalConfig, ...config };
|
|
68
|
+
// Reset client if API key changed
|
|
69
|
+
if (config.apiKey) {
|
|
70
|
+
openaiClient = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Core transform function
|
|
74
|
+
async function transform(text, characterKey) {
|
|
75
|
+
if (!text || text.trim().length === 0) {
|
|
76
|
+
throw new Error("Text is required and cannot be empty");
|
|
77
|
+
}
|
|
78
|
+
const apiKey = globalConfig.apiKey || process.env.OPENAI_API_KEY;
|
|
79
|
+
if (!apiKey) {
|
|
80
|
+
throw new Error("OpenAI API key required. Set OPENAI_API_KEY env var or call configure({ apiKey: '...' })");
|
|
81
|
+
}
|
|
82
|
+
const characterName = CHARACTERS[characterKey];
|
|
83
|
+
const model = globalConfig.model || "gpt-4o-mini";
|
|
84
|
+
const openai = getClient(apiKey);
|
|
85
|
+
const completion = await openai.chat.completions.create({
|
|
86
|
+
model,
|
|
87
|
+
messages: [
|
|
88
|
+
{ role: "system", content: SYSTEM_PROMPT },
|
|
89
|
+
{
|
|
90
|
+
role: "user",
|
|
91
|
+
content: `Transform this quote in the style of ${characterName}: "${text}"`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
temperature: 0.7,
|
|
95
|
+
max_tokens: 500,
|
|
96
|
+
});
|
|
97
|
+
const transformedText = completion.choices[0]?.message?.content || "";
|
|
98
|
+
return {
|
|
99
|
+
text: transformedText,
|
|
100
|
+
character: characterName,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function createRefine() {
|
|
104
|
+
const fn = ((text, character) => transform(text, character));
|
|
105
|
+
fn.mark = (text) => transform(text, "mark");
|
|
106
|
+
fn.irving = (text) => transform(text, "irving");
|
|
107
|
+
fn.dylan = (text) => transform(text, "dylan");
|
|
108
|
+
fn.milchick = (text) => transform(text, "milchick");
|
|
109
|
+
return fn;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Transform quotes into Severance character voices.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Use character methods
|
|
116
|
+
* await refine.dylan("Hello world")
|
|
117
|
+
*
|
|
118
|
+
* // Or use generic form
|
|
119
|
+
* await refine("Hello world", "dylan")
|
|
120
|
+
*/
|
|
121
|
+
export const refine = createRefine();
|
package/package.json
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "defiant-jazz",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Transform quotes into Severance character voices using OpenAI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "kenjonespizza",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"severance",
|
|
10
|
+
"openai",
|
|
11
|
+
"ai",
|
|
12
|
+
"text-transform",
|
|
13
|
+
"lumon"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/kenjonespizza/defiant-jazz-package.git"
|
|
18
|
+
},
|
|
8
19
|
"exports": {
|
|
9
20
|
".": {
|
|
10
21
|
"types": "./dist/index.d.ts",
|
|
@@ -14,10 +25,14 @@
|
|
|
14
25
|
"files": [
|
|
15
26
|
"dist"
|
|
16
27
|
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"openai": "^4.77.0"
|
|
30
|
+
},
|
|
17
31
|
"devDependencies": {
|
|
18
32
|
"typescript": "^5.9.3"
|
|
19
33
|
},
|
|
20
34
|
"scripts": {
|
|
21
|
-
"build": "tsc"
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"dev": "tsc --watch"
|
|
22
37
|
}
|
|
23
38
|
}
|