@voquill/voice-ai 0.1.3 → 0.2.3
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/dist/cerebras.utils.d.ts +26 -0
- package/dist/cerebras.utils.d.ts.map +1 -0
- package/dist/cerebras.utils.js +111 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/openai.utils.d.ts +4 -3
- package/dist/openai.utils.d.ts.map +1 -1
- package/dist/openai.utils.js +2 -1
- package/dist/openrouter.utils.d.ts +6 -5
- package/dist/openrouter.utils.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonResponse, LlmChatInput, LlmStreamEvent } from "@voquill/types";
|
|
2
|
+
export declare const CEREBRAS_MODELS: readonly ["zai-glm-4.7", "llama3.1-8b", "gpt-oss-120b", "qwen-3-235b-a22b-instruct-2507"];
|
|
3
|
+
export type CerebrasModel = (typeof CEREBRAS_MODELS)[number];
|
|
4
|
+
export type CerebrasGenerateTextArgs = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
model?: CerebrasModel;
|
|
7
|
+
system?: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
jsonResponse?: JsonResponse;
|
|
10
|
+
};
|
|
11
|
+
export type CerebrasGenerateResponseOutput = {
|
|
12
|
+
text: string;
|
|
13
|
+
tokensUsed: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const cerebrasGenerateTextResponse: ({ apiKey, model, system, prompt, jsonResponse, }: CerebrasGenerateTextArgs) => Promise<CerebrasGenerateResponseOutput>;
|
|
16
|
+
export type CerebrasTestIntegrationArgs = {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const cerebrasTestIntegration: ({ apiKey, }: CerebrasTestIntegrationArgs) => Promise<boolean>;
|
|
20
|
+
export type CerebrasStreamChatArgs = {
|
|
21
|
+
apiKey: string;
|
|
22
|
+
model: string;
|
|
23
|
+
input: LlmChatInput;
|
|
24
|
+
};
|
|
25
|
+
export declare function cerebrasStreamChat({ apiKey, model, input, }: CerebrasStreamChatArgs): AsyncGenerator<LlmStreamEvent>;
|
|
26
|
+
//# sourceMappingURL=cerebras.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cerebras.utils.d.ts","sourceRoot":"","sources":["../src/cerebras.utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGjF,eAAO,MAAM,eAAe,2FAKlB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAkC7D,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAU,kDAMhD,wBAAwB,KAAG,OAAO,CAAC,8BAA8B,CAqDnE,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,aAE3C,2BAA2B,KAAG,OAAO,CAAC,OAAO,CAgC/C,CAAC;AAMF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAuB,kBAAkB,CAAC,EACxC,MAAM,EACN,KAAK,EACL,KAAK,GACN,EAAE,sBAAsB,GAAG,cAAc,CAAC,cAAc,CAAC,CAQzD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { retry, countWords } from "@voquill/utilities";
|
|
3
|
+
import { openaiCompatibleStreamChat } from "./openai.utils";
|
|
4
|
+
export const CEREBRAS_MODELS = [
|
|
5
|
+
"zai-glm-4.7",
|
|
6
|
+
"llama3.1-8b",
|
|
7
|
+
"gpt-oss-120b",
|
|
8
|
+
"qwen-3-235b-a22b-instruct-2507",
|
|
9
|
+
];
|
|
10
|
+
const CEREBRAS_BASE_URL = "https://api.cerebras.ai/v1";
|
|
11
|
+
const contentToString = (content) => {
|
|
12
|
+
if (!content) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
if (typeof content === "string") {
|
|
16
|
+
return content;
|
|
17
|
+
}
|
|
18
|
+
return content
|
|
19
|
+
.map((part) => {
|
|
20
|
+
if (part.type === "text") {
|
|
21
|
+
return part.text ?? "";
|
|
22
|
+
}
|
|
23
|
+
return "";
|
|
24
|
+
})
|
|
25
|
+
.join("")
|
|
26
|
+
.trim();
|
|
27
|
+
};
|
|
28
|
+
const createClient = (apiKey) => {
|
|
29
|
+
return new OpenAI({
|
|
30
|
+
apiKey: apiKey.trim(),
|
|
31
|
+
baseURL: CEREBRAS_BASE_URL,
|
|
32
|
+
dangerouslyAllowBrowser: true,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const cerebrasGenerateTextResponse = async ({ apiKey, model = "zai-glm-4.7", system, prompt, jsonResponse, }) => {
|
|
36
|
+
return retry({
|
|
37
|
+
retries: 3,
|
|
38
|
+
fn: async () => {
|
|
39
|
+
const client = createClient(apiKey);
|
|
40
|
+
const messages = [];
|
|
41
|
+
if (system) {
|
|
42
|
+
messages.push({ role: "system", content: system });
|
|
43
|
+
}
|
|
44
|
+
let finalPrompt = prompt;
|
|
45
|
+
if (jsonResponse) {
|
|
46
|
+
finalPrompt = `${prompt}\n\nRespond with valid JSON matching this schema: ${JSON.stringify(jsonResponse.schema)}`;
|
|
47
|
+
}
|
|
48
|
+
const userParts = [];
|
|
49
|
+
userParts.push({ type: "text", text: finalPrompt });
|
|
50
|
+
messages.push({ role: "user", content: userParts });
|
|
51
|
+
const params = {
|
|
52
|
+
messages,
|
|
53
|
+
model,
|
|
54
|
+
temperature: 1,
|
|
55
|
+
max_tokens: 1024,
|
|
56
|
+
top_p: 1,
|
|
57
|
+
response_format: jsonResponse ? { type: "json_object" } : undefined,
|
|
58
|
+
};
|
|
59
|
+
if (model === "zai-glm-4.7") {
|
|
60
|
+
params.reasoning_effort = "none";
|
|
61
|
+
}
|
|
62
|
+
const response = await client.chat.completions.create(params);
|
|
63
|
+
console.log("cerebras llm usage:", response.usage);
|
|
64
|
+
if (!response.choices || response.choices.length === 0) {
|
|
65
|
+
throw new Error("No response from Cerebras");
|
|
66
|
+
}
|
|
67
|
+
const result = response.choices[0].message.content;
|
|
68
|
+
if (!result) {
|
|
69
|
+
throw new Error("Content is empty");
|
|
70
|
+
}
|
|
71
|
+
const content = contentToString(result);
|
|
72
|
+
return {
|
|
73
|
+
text: content,
|
|
74
|
+
tokensUsed: response.usage?.total_tokens ?? countWords(content),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export const cerebrasTestIntegration = async ({ apiKey, }) => {
|
|
80
|
+
const client = createClient(apiKey);
|
|
81
|
+
const response = await client.chat.completions.create({
|
|
82
|
+
messages: [
|
|
83
|
+
{
|
|
84
|
+
role: "user",
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: "text",
|
|
88
|
+
text: `Reply with the single word "Hello."`,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
model: "llama3.1-8b",
|
|
94
|
+
temperature: 0,
|
|
95
|
+
max_tokens: 32,
|
|
96
|
+
top_p: 1,
|
|
97
|
+
});
|
|
98
|
+
if (!response.choices || response.choices.length === 0) {
|
|
99
|
+
throw new Error("No response from Cerebras");
|
|
100
|
+
}
|
|
101
|
+
const first = response.choices[0];
|
|
102
|
+
const content = contentToString(first?.message?.content);
|
|
103
|
+
if (!content) {
|
|
104
|
+
throw new Error("Response content is empty");
|
|
105
|
+
}
|
|
106
|
+
return content.toLowerCase().includes("hello");
|
|
107
|
+
};
|
|
108
|
+
export async function* cerebrasStreamChat({ apiKey, model, input, }) {
|
|
109
|
+
const client = createClient(apiKey);
|
|
110
|
+
yield* openaiCompatibleStreamChat(client, model, input, model === "zai-glm-4.7" ? { reasoning_effort: "none" } : undefined);
|
|
111
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./types";
|
|
1
2
|
export * from "./claude.utils";
|
|
2
3
|
export * from "./groq.utils";
|
|
3
4
|
export * from "./openai.utils";
|
|
@@ -10,5 +11,6 @@ export * from "./azure.utils";
|
|
|
10
11
|
export * from "./azure-openai.utils";
|
|
11
12
|
export * from "./deepseek.utils";
|
|
12
13
|
export * from "./gemini.utils";
|
|
14
|
+
export * from "./cerebras.utils";
|
|
13
15
|
export * from "./speaches.utils";
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./types";
|
|
1
2
|
export * from "./claude.utils";
|
|
2
3
|
export * from "./groq.utils";
|
|
3
4
|
export * from "./openai.utils";
|
|
@@ -10,4 +11,5 @@ export * from "./azure.utils";
|
|
|
10
11
|
export * from "./azure-openai.utils";
|
|
11
12
|
export * from "./deepseek.utils";
|
|
12
13
|
export * from "./gemini.utils";
|
|
14
|
+
export * from "./cerebras.utils";
|
|
13
15
|
export * from "./speaches.utils";
|
package/dist/openai.utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JsonResponse, LlmChatInput, LlmMessage, LlmStreamEvent } from "@voquill/types";
|
|
2
2
|
import OpenAI from "openai";
|
|
3
|
+
import type { CustomFetch } from "./types";
|
|
3
4
|
import type { ChatCompletionMessageParam } from "openai/resources/chat/completions";
|
|
4
5
|
export declare const OPENAI_GENERATE_TEXT_MODELS: readonly ["gpt-4o", "gpt-4o-mini", "gpt-4-turbo", "gpt-3.5-turbo", "gpt-5.2", "gpt-5.3", "gpt-5.4"];
|
|
5
6
|
export type OpenAIGenerateTextModel = (typeof OPENAI_GENERATE_TEXT_MODELS)[number];
|
|
@@ -26,7 +27,7 @@ export type OpenAIGenerateTextArgs = {
|
|
|
26
27
|
prompt: string;
|
|
27
28
|
imageUrls?: string[];
|
|
28
29
|
jsonResponse?: JsonResponse;
|
|
29
|
-
customFetch?:
|
|
30
|
+
customFetch?: CustomFetch;
|
|
30
31
|
};
|
|
31
32
|
export type OpenAIGenerateResponseOutput = {
|
|
32
33
|
text: string;
|
|
@@ -43,13 +44,13 @@ export type OpenAICompatibleTestIntegrationArgs = {
|
|
|
43
44
|
export declare const openaiCompatibleTestIntegration: ({ baseUrl, apiKey, }: OpenAICompatibleTestIntegrationArgs) => Promise<boolean>;
|
|
44
45
|
export declare const openaiTestIntegration: ({ apiKey, }: OpenAITestIntegrationArgs) => Promise<boolean>;
|
|
45
46
|
export declare function llmMessagesToOpenAI(messages: LlmMessage[]): ChatCompletionMessageParam[];
|
|
46
|
-
export declare function openaiCompatibleStreamChat(client: OpenAI, model: string, input: LlmChatInput): AsyncGenerator<LlmStreamEvent>;
|
|
47
|
+
export declare function openaiCompatibleStreamChat(client: OpenAI, model: string, input: LlmChatInput, extraBody?: Record<string, unknown>): AsyncGenerator<LlmStreamEvent>;
|
|
47
48
|
export type OpenAIStreamChatArgs = {
|
|
48
49
|
apiKey: string;
|
|
49
50
|
baseUrl?: string;
|
|
50
51
|
model: string;
|
|
51
52
|
input: LlmChatInput;
|
|
52
|
-
customFetch?:
|
|
53
|
+
customFetch?: CustomFetch;
|
|
53
54
|
};
|
|
54
55
|
export declare function openaiStreamChat({ apiKey, baseUrl, model, input, customFetch, }: OpenAIStreamChatArgs): AsyncGenerator<LlmStreamEvent>;
|
|
55
56
|
//# sourceMappingURL=openai.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.utils.d.ts","sourceRoot":"","sources":["../src/openai.ut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Z,EAAE,oBAAoB,GAAG,cAAc,CAAC,cAAc,CAAC,CAGvD"}
|
package/dist/openai.utils.js
CHANGED
|
@@ -207,7 +207,7 @@ function toFinishReason(raw) {
|
|
|
207
207
|
return "other";
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
export async function* openaiCompatibleStreamChat(client, model, input) {
|
|
210
|
+
export async function* openaiCompatibleStreamChat(client, model, input, extraBody) {
|
|
211
211
|
const stream = await client.chat.completions.create({
|
|
212
212
|
model,
|
|
213
213
|
messages: llmMessagesToOpenAI(input.messages),
|
|
@@ -222,6 +222,7 @@ export async function* openaiCompatibleStreamChat(client, model, input) {
|
|
|
222
222
|
frequency_penalty: input.frequencyPenalty,
|
|
223
223
|
presence_penalty: input.presencePenalty,
|
|
224
224
|
seed: input.seed,
|
|
225
|
+
...extraBody,
|
|
225
226
|
});
|
|
226
227
|
const toolCalls = new Map();
|
|
227
228
|
let finishReason = "other";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JsonResponse, LlmChatInput, LlmStreamEvent, OpenRouterModel, OpenRouterProvider, OpenRouterProviderRouting } from "@voquill/types";
|
|
2
|
+
import type { CustomFetch } from "./types";
|
|
2
3
|
export declare const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
3
4
|
export declare const OPENROUTER_APP_NAME = "Voquill";
|
|
4
5
|
export declare const OPENROUTER_APP_URL = "https://voquill.com";
|
|
@@ -13,7 +14,7 @@ export declare const OPENROUTER_FAVORITE_MODELS: readonly ["openai/gpt-oss-120b"
|
|
|
13
14
|
export declare const OPENROUTER_DEFAULT_MODEL = "openai/gpt-4o-mini";
|
|
14
15
|
export type OpenRouterFetchModelsArgs = {
|
|
15
16
|
apiKey: string;
|
|
16
|
-
customFetch?:
|
|
17
|
+
customFetch?: CustomFetch;
|
|
17
18
|
};
|
|
18
19
|
export type OpenRouterFetchModelsOutput = {
|
|
19
20
|
models: OpenRouterModel[];
|
|
@@ -23,7 +24,7 @@ export type OpenRouterFetchModelsOutput = {
|
|
|
23
24
|
*/
|
|
24
25
|
export declare const openrouterFetchModels: ({ apiKey, customFetch, }: OpenRouterFetchModelsArgs) => Promise<OpenRouterFetchModelsOutput>;
|
|
25
26
|
export type OpenRouterFetchProvidersArgs = {
|
|
26
|
-
customFetch?:
|
|
27
|
+
customFetch?: CustomFetch;
|
|
27
28
|
};
|
|
28
29
|
export type OpenRouterFetchProvidersOutput = {
|
|
29
30
|
providers: OpenRouterProvider[];
|
|
@@ -40,7 +41,7 @@ export type OpenRouterGenerateTextArgs = {
|
|
|
40
41
|
prompt: string;
|
|
41
42
|
jsonResponse?: JsonResponse;
|
|
42
43
|
providerRouting?: OpenRouterProviderRouting;
|
|
43
|
-
customFetch?:
|
|
44
|
+
customFetch?: CustomFetch;
|
|
44
45
|
};
|
|
45
46
|
export type OpenRouterGenerateTextOutput = {
|
|
46
47
|
text: string;
|
|
@@ -53,7 +54,7 @@ export type OpenRouterGenerateTextOutput = {
|
|
|
53
54
|
export declare const openrouterGenerateTextResponse: ({ apiKey, model, system, prompt, jsonResponse, providerRouting, customFetch, }: OpenRouterGenerateTextArgs) => Promise<OpenRouterGenerateTextOutput>;
|
|
54
55
|
export type OpenRouterTestIntegrationArgs = {
|
|
55
56
|
apiKey: string;
|
|
56
|
-
customFetch?:
|
|
57
|
+
customFetch?: CustomFetch;
|
|
57
58
|
};
|
|
58
59
|
/**
|
|
59
60
|
* Test if an OpenRouter API key is valid by making a simple chat completion.
|
|
@@ -63,7 +64,7 @@ export type OpenRouterStreamChatArgs = {
|
|
|
63
64
|
apiKey: string;
|
|
64
65
|
model: string;
|
|
65
66
|
input: LlmChatInput;
|
|
66
|
-
customFetch?:
|
|
67
|
+
customFetch?: CustomFetch;
|
|
67
68
|
};
|
|
68
69
|
export declare function openrouterStreamChat({ apiKey, model, input, customFetch, }: OpenRouterStreamChatArgs): AsyncGenerator<LlmStreamEvent>;
|
|
69
70
|
//# sourceMappingURL=openrouter.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.utils.d.ts","sourceRoot":"","sources":["../src/openrouter.utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"openrouter.utils.d.ts","sourceRoot":"","sources":["../src/openrouter.utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,wDAG7B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAyB7D,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,0BAGzC,yBAAyB,KAAG,OAAO,CAAC,2BAA2B,CAmBjE,CAAC;AAMF,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,kBAAkB,EAAE,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GAAU,mBAE5C,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AAG,GAAG,GAAG,OAAO,EAC7B,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voquill/voice-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Shared Groq voice transcription helpers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"wavefile": "^11.0.0",
|
|
23
23
|
"zod": "^3.25.76",
|
|
24
24
|
"zod-to-json-schema": "^3.24.6",
|
|
25
|
-
"@voquill/
|
|
26
|
-
"@voquill/
|
|
25
|
+
"@voquill/types": "0.2.3",
|
|
26
|
+
"@voquill/utilities": "0.2.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "5.9.2",
|
|
30
|
-
"@voquill/typescript-config": "0.
|
|
30
|
+
"@voquill/typescript-config": "0.2.3"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|