@getfamiliar/plugin-transcribe-whisper 0.1.12 → 0.1.15

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.
@@ -1,5 +1,5 @@
1
- import { type CommandDef } from "citty";
2
1
  import type { HostContext } from "@getfamiliar/shared";
2
+ import { type CommandDef } from "citty";
3
3
  /**
4
4
  * Build the citty subcommands exposed under
5
5
  * `familiar transcribe-whisper`. Currently a single smoke-test
@@ -9,6 +9,12 @@
9
9
  * opaque OpenAI auth failure on the next transcription.
10
10
  */
11
11
  export declare function setApiKey(key: string): void;
12
+ /**
13
+ * Forget the installed key, so a config reload that removed
14
+ * `inference.apiKeys.openai` deactivates transcription (calls then fail
15
+ * with the "not initialized" error).
16
+ */
17
+ export declare function clearApiKey(): void;
12
18
  /**
13
19
  * Transcribe a buffered audio file using OpenAI's Whisper API
14
20
  * (model `whisper-1`).
package/build/Whisper.js CHANGED
@@ -26,6 +26,14 @@ export function setApiKey(key) {
26
26
  }
27
27
  apiKey = key;
28
28
  }
29
+ /**
30
+ * Forget the installed key, so a config reload that removed
31
+ * `inference.apiKeys.openai` deactivates transcription (calls then fail
32
+ * with the "not initialized" error).
33
+ */
34
+ export function clearApiKey() {
35
+ apiKey = undefined;
36
+ }
29
37
  /**
30
38
  * Transcribe a buffered audio file using OpenAI's Whisper API
31
39
  * (model `whisper-1`).
package/build/index.d.ts CHANGED
@@ -37,6 +37,7 @@ export { transcribeAudio } from "./Whisper.js";
37
37
  declare const _default: {
38
38
  id: string;
39
39
  host: {
40
+ restartOnConfigChange: string[];
40
41
  prepare: (ctx: import("@getfamiliar/shared").HostContext) => void;
41
42
  commands: (ctx: import("@getfamiliar/shared").HostContext) => readonly import("citty").CommandDef<any>[];
42
43
  };
package/build/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { definePlugin } from "@getfamiliar/shared";
2
2
  import { buildCommands } from "./Commands.js";
3
- import { setApiKey } from "./Whisper.js";
3
+ import { clearApiKey, setApiKey } from "./Whisper.js";
4
+ /** Config key of the OpenAI API key the plugin transcribes with. */
5
+ const OPENAI_API_KEY_CONFIG = "inference.apiKeys.openai";
4
6
  /**
5
7
  * Re-export the plugin's public library API. Sibling plugins
6
8
  * consume it as `import { transcribeAudio } from "@getfamiliar/plugin-transcribe-whisper"`.
@@ -40,12 +42,14 @@ export { transcribeAudio } from "./Whisper.js";
40
42
  export default definePlugin({
41
43
  id: "transcribe-whisper",
42
44
  host: {
45
+ restartOnConfigChange: [OPENAI_API_KEY_CONFIG],
43
46
  prepare: (ctx) => {
44
- const key = ctx.config.getString("inference.apiKeys.openai", null);
47
+ const key = ctx.config.getString(OPENAI_API_KEY_CONFIG, null);
45
48
  if (key !== null) {
46
49
  setApiKey(key);
47
50
  }
48
51
  else {
52
+ clearApiKey();
49
53
  ctx.logger.info("transcribe-whisper inactive: inference.apiKeys.openai not set in config/config.yml");
50
54
  }
51
55
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@getfamiliar/plugin-transcribe-whisper",
3
3
  "type": "module",
4
- "version": "0.1.12",
4
+ "version": "0.1.15",
5
5
  "description": "Familiar plugin: transcribeAudio() backed by OpenAI's Whisper API.",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -29,7 +29,7 @@
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
31
  "citty": "^0.1.6",
32
- "@getfamiliar/shared": "0.1.12",
32
+ "@getfamiliar/shared": "0.1.15",
33
33
  "openai": "^4.77.0"
34
34
  },
35
35
  "devDependencies": {