@sahab-platform/agents 0.0.2 → 0.0.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/README.md CHANGED
@@ -20,7 +20,7 @@ pnpm add @sahab/agents
20
20
  ## Quick start
21
21
 
22
22
  ```typescript
23
- import { SahabAgents } from "@sahab/agents";
23
+ import { SahabAgents } from "@sahab-platform/agents";
24
24
 
25
25
  const sahab = new SahabAgents({
26
26
  apiKey: process.env.SAHAB_API_KEY!,
@@ -53,10 +53,7 @@ var internal_agent_default = agents.defineAgent({
53
53
  const session = new agents.voice.AgentSession({
54
54
  stt: new agents.inference.STT(options.stt),
55
55
  llm: new agents.inference.LLM(options.llm),
56
- tts: new agents.inference.TTS({
57
- model: options.tts.model,
58
- ...options.tts
59
- }),
56
+ tts: new agents.inference.TTS(options.tts),
60
57
  turnDetection: new livekit__namespace.turnDetector.MultilingualModel(),
61
58
  vad: ctx.proc.userData.vad,
62
59
  voiceOptions: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/agent-instructions.ts","../src/store.ts","../src/_internal-agent.ts"],"names":["voice","defineAgent","silero","inference","livekit","metrics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,KAAA,GAAN,cAAoBA,YAAA,CAAM,KAAA,CAAM;AAAA,EACrC,YAAY,QAAA,EAAkB;AAC5B,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,QAAQ,CAAA;AAChC,IAAA,KAAA,CAAM;AAAA,MACJ,YAAA,EACE,uIAEA,IAAA,CAAK;AAAA,KACR,CAAA;AAAA,EACH;AACF,CAAA;ACHO,SAAS,UAAA,GAAiC;AAC/C,EAAe;AACb,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAEF;;;ACGA,IAAM,UAAU,UAAA,EAAW;AAE3B,IAAO,yBAAQC,kBAAA,CAAY;AAAA,EACzB,OAAA,EAAS,OAAO,I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Q,IAAI,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,IACjD,CAAA;AAEA,IAAA,GAAA,CAAI,oBAAoB,QAAQ,CAAA;AAEhC,IAAA,MAAM,QAAQ,KAAA,CAAM;AAAA,MAClB,KAAA,EAAO,IAAI,KAAA,CAAM,GAAA,CAAI,IAAI,QAAQ,CAAA;AAAA,MACjC,MAAM,GAAA,CAAI;AAAA,KACX,CAAA;AAED,IAAA,MAAM,IAAI,OAAA,EAAQ;AAElB,IAAA,GAAA,CAAI,IAAA,CAAK,gBAAA,EAAkB,UAAA,CAAW,QAAA,CAAS,IAAI,CAAA;AAAA,EACrD;AACF,CAAC","file":"_internal-agent.js","sourcesContent":["import { voice } from \"@livekit/agents\";\n\nexport class Agent extends voice.Agent {\n constructor(metadata: string) {\n const data = JSON.parse(metadata);\n super({\n instructions:\n \"You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text.\" +\n \"\\n\" +\n data.prompt,\n });\n }\n}\n","import type { LiveKitConfig, SahabAgentsOptions } from \"./types.js\";\n\nlet _options: SahabAgentsOptions | undefined;\nlet _livekitConfig: LiveKitConfig | undefined;\n\nexport function setOptions(options: SahabAgentsOptions): void {\n _options = options;\n}\n\nexport function getOptions(): SahabAgentsOptions {\n if (!_options) {\n throw new Error(\n \"SahabAgents options have not been set. Call initialize() first.\",\n );\n }\n return _options;\n}\n\nexport function setLiveKitConfig(config: LiveKitConfig): void {\n _livekitConfig = config;\n}\n\nexport function getLiveKitConfig(): LiveKitConfig {\n if (!_livekitConfig) {\n throw new Error(\n \"LiveKit config has not been set. Call initialize() first.\",\n );\n }\n return _livekitConfig;\n}\n","/**\n * Internal agent entry file — imported by LiveKit's worker process.\n *\n * Do NOT import this file directly. It is referenced by path in\n * `AgentsResource.initialize()` and dynamically loaded by LiveKit.\n */\nimport {\n defineAgent,\n JobContext,\n JobProcess,\n voice,\n metrics,\n inference,\n} from \"@livekit/agents\";\nimport * as livekit from \"@livekit/agents-plugin-livekit\";\nimport * as silero from \"@livekit/agents-plugin-silero\";\nimport { Agent } from \"./agent-instructions.js\";\nimport { getOptions } from \"./store.js\";\n\nconst options = getOptions();\n\nexport default defineAgent({\n prewarm: async (proc: JobProcess) => {\n proc.userData.vad = await silero.VAD.load();\n },\n entry: async (ctx: JobContext) => {\n const metadata = JSON.parse(ctx.job.metadata);\n\n const session = new voice.AgentSession({\n stt: new inference.STT(options.stt),\n llm: new inference.LLM(options.llm),\n tts: new inference.TTS({\n model: options.tts.model!,\n ...options.tts,\n }),\n turnDetection: new livekit.turnDetector.MultilingualModel(),\n vad: ctx.proc.userData.vad! as silero.VAD,\n voiceOptions: {\n preemptiveGeneration: true,\n },\n });\n\n const usageCollector = new metrics.UsageCollector();\n session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {\n metrics.logMetrics(ev.metrics);\n usageCollector.collect(ev.metrics);\n });\n\n const logUsage = async () => {\n const summary = usageCollector.getSummary();\n console.log(`Usage: ${JSON.stringify(summary)}`);\n };\n\n ctx.addShutdownCallback(logUsage);\n\n await session.start({\n agent: new Agent(ctx.job.metadata),\n room: ctx.room,\n });\n\n await ctx.connect();\n\n ctx.room.localParticipant?.updateName(metadata.name);\n },\n});\n"]}
1
+ {"version":3,"sources":["../src/agent-instructions.ts","../src/store.ts","../src/_internal-agent.ts"],"names":["voice","defineAgent","silero","inference","livekit","metrics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,KAAA,GAAN,cAAoBA,YAAA,CAAM,KAAA,CAAM;AAAA,EACrC,YAAY,QAAA,EAAkB;AAC5B,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,QAAQ,CAAA;AAChC,IAAA,KAAA,CAAM;AAAA,MACJ,YAAA,EACE,uIAEA,IAAA,CAAK;AAAA,KACR,CAAA;AAAA,EACH;AACF,CAAA;ACHO,SAAS,UAAA,GAAiC;AAC/C,EAA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MAAM,WAAW,YAAY;AAC3B,MAAA,MAAM,OAAA,GAAU,eAAe,UAAA,EAAW;AAC1C,MAAA,OAAA,CAAQ,IAAI,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,IACjD,CAAA;AAEA,IAAA,GAAA,CAAI,oBAAoB,QAAQ,CAAA;AAEhC,IAAA,MAAM,QAAQ,KAAA,CAAM;AAAA,MAClB,KAAA,EAAO,IAAI,KAAA,CAAM,GAAA,CAAI,IAAI,QAAQ,CAAA;AAAA,MACjC,MAAM,GAAA,CAAI;AAAA,KACX,CAAA;AAED,IAAA,MAAM,IAAI,OAAA,EAAQ;AAElB,IAAA,GAAA,CAAI,IAAA,CAAK,gBAAA,EAAkB,UAAA,CAAW,QAAA,CAAS,IAAI,CAAA;AAAA,EACrD;AACF,CAAC","file":"_internal-agent.js","sourcesContent":["import { voice } from \"@livekit/agents\";\n\nexport class Agent extends voice.Agent {\n constructor(metadata: string) {\n const data = JSON.parse(metadata);\n super({\n instructions:\n \"You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text.\" +\n \"\\n\" +\n data.prompt,\n });\n }\n}\n","import type { LiveKitConfig, SahabAgentsOptions } from \"./types.js\";\n\nlet _options: SahabAgentsOptions | undefined;\nlet _livekitConfig: LiveKitConfig | undefined;\n\nexport function setOptions(options: SahabAgentsOptions): void {\n _options = options;\n}\n\nexport function getOptions(): SahabAgentsOptions {\n if (!_options) {\n throw new Error(\n \"SahabAgents options have not been set. Call initialize() first.\",\n );\n }\n return _options;\n}\n\nexport function setLiveKitConfig(config: LiveKitConfig): void {\n _livekitConfig = config;\n}\n\nexport function getLiveKitConfig(): LiveKitConfig {\n if (!_livekitConfig) {\n throw new Error(\n \"LiveKit config has not been set. Call initialize() first.\",\n );\n }\n return _livekitConfig;\n}\n","/**\n * Internal agent entry file — imported by LiveKit's worker process.\n *\n * Do NOT import this file directly. It is referenced by path in\n * `AgentsResource.initialize()` and dynamically loaded by LiveKit.\n */\nimport {\n defineAgent,\n JobContext,\n JobProcess,\n voice,\n metrics,\n inference,\n} from \"@livekit/agents\";\nimport * as livekit from \"@livekit/agents-plugin-livekit\";\nimport * as silero from \"@livekit/agents-plugin-silero\";\nimport { Agent } from \"./agent-instructions.js\";\nimport { getOptions } from \"./store.js\";\n\nconst options = getOptions();\n\nexport default defineAgent({\n prewarm: async (proc: JobProcess) => {\n proc.userData.vad = await silero.VAD.load();\n },\n entry: async (ctx: JobContext) => {\n const metadata = JSON.parse(ctx.job.metadata);\n\n const session = new voice.AgentSession({\n stt: new inference.STT(options.stt),\n llm: new inference.LLM(options.llm),\n tts: new inference.TTS(options.tts),\n turnDetection: new livekit.turnDetector.MultilingualModel(),\n vad: ctx.proc.userData.vad! as silero.VAD,\n voiceOptions: {\n preemptiveGeneration: true,\n },\n });\n\n const usageCollector = new metrics.UsageCollector();\n session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {\n metrics.logMetrics(ev.metrics);\n usageCollector.collect(ev.metrics);\n });\n\n const logUsage = async () => {\n const summary = usageCollector.getSummary();\n console.log(`Usage: ${JSON.stringify(summary)}`);\n };\n\n ctx.addShutdownCallback(logUsage);\n\n await session.start({\n agent: new Agent(ctx.job.metadata),\n room: ctx.room,\n });\n\n await ctx.connect();\n\n ctx.room.localParticipant?.updateName(metadata.name);\n },\n});\n"]}
@@ -30,10 +30,7 @@ var internal_agent_default = defineAgent({
30
30
  const session = new voice.AgentSession({
31
31
  stt: new inference.STT(options.stt),
32
32
  llm: new inference.LLM(options.llm),
33
- tts: new inference.TTS({
34
- model: options.tts.model,
35
- ...options.tts
36
- }),
33
+ tts: new inference.TTS(options.tts),
37
34
  turnDetection: new livekit.turnDetector.MultilingualModel(),
38
35
  vad: ctx.proc.userData.vad,
39
36
  voiceOptions: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/agent-instructions.ts","../src/store.ts","../src/_internal-agent.ts"],"names":["voice"],"mappings":";;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EAAc;AAAA,QACZ,oBAAA,EAAsB;AAAA;AACxB,KACD,CAAA;AAED,IAAA,MAAM,cAAA,GAAiB,IAAI,OAAA,CAAQ,cAAA,EAAe;AAClD,IAAA,OAAA,CAAQ,EAAA,CAAGA,KAAAA,CAAM,sBAAA,CAAuB,gBAAA,EAAkB,CAAC,EAAA,KAAO;AAChE,MAAA,OAAA,CAAQ,UAAA,CAAW,GAAG,OAAO,CAAA;AAC7B,MAAA,cAAA,CAAe,OAAA,CAAQ,GAAG,OAAO,CAAA;AAAA,IACnC,CAAC,CAAA;AAED,IAAA,MAAM,WAAW,YAAY;AAC3B,MAAA,MAAM,OAAA,GAAU,eAAe,UAAA,EAAW;AAC1C,MAAA,OAAA,CAAQ,IAAI,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,IACjD,CAAA;AAEA,IAAA,GAAA,CAAI,oBAAoB,QAAQ,CAAA;AAEhC,IAAA,MAAM,QAAQ,KAAA,CAAM;AAAA,MAClB,KAAA,EAAO,IAAI,KAAA,CAAM,GAAA,CAAI,IAAI,QAAQ,CAAA;AAAA,MACjC,MAAM,GAAA,CAAI;AAAA,KACX,CAAA;AAED,IAAA,MAAM,IAAI,OAAA,EAAQ;AAElB,IAAA,GAAA,CAAI,IAAA,CAAK,gBAAA,EAAkB,UAAA,CAAW,QAAA,CAAS,IAAI,CAAA;AAAA,EACrD;AACF,CAAC","file":"_internal-agent.mjs","sourcesContent":["import { voice } from \"@livekit/agents\";\n\nexport class Agent extends voice.Agent {\n constructor(metadata: string) {\n const data = JSON.parse(metadata);\n super({\n instructions:\n \"You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text.\" +\n \"\\n\" +\n data.prompt,\n });\n }\n}\n","import type { LiveKitConfig, SahabAgentsOptions } from \"./types.js\";\n\nlet _options: SahabAgentsOptions | undefined;\nlet _livekitConfig: LiveKitConfig | undefined;\n\nexport function setOptions(options: SahabAgentsOptions): void {\n _options = options;\n}\n\nexport function getOptions(): SahabAgentsOptions {\n if (!_options) {\n throw new Error(\n \"SahabAgents options have not been set. Call initialize() first.\",\n );\n }\n return _options;\n}\n\nexport function setLiveKitConfig(config: LiveKitConfig): void {\n _livekitConfig = config;\n}\n\nexport function getLiveKitConfig(): LiveKitConfig {\n if (!_livekitConfig) {\n throw new Error(\n \"LiveKit config has not been set. Call initialize() first.\",\n );\n }\n return _livekitConfig;\n}\n","/**\n * Internal agent entry file — imported by LiveKit's worker process.\n *\n * Do NOT import this file directly. It is referenced by path in\n * `AgentsResource.initialize()` and dynamically loaded by LiveKit.\n */\nimport {\n defineAgent,\n JobContext,\n JobProcess,\n voice,\n metrics,\n inference,\n} from \"@livekit/agents\";\nimport * as livekit from \"@livekit/agents-plugin-livekit\";\nimport * as silero from \"@livekit/agents-plugin-silero\";\nimport { Agent } from \"./agent-instructions.js\";\nimport { getOptions } from \"./store.js\";\n\nconst options = getOptions();\n\nexport default defineAgent({\n prewarm: async (proc: JobProcess) => {\n proc.userData.vad = await silero.VAD.load();\n },\n entry: async (ctx: JobContext) => {\n const metadata = JSON.parse(ctx.job.metadata);\n\n const session = new voice.AgentSession({\n stt: new inference.STT(options.stt),\n llm: new inference.LLM(options.llm),\n tts: new inference.TTS({\n model: options.tts.model!,\n ...options.tts,\n }),\n turnDetection: new livekit.turnDetector.MultilingualModel(),\n vad: ctx.proc.userData.vad! as silero.VAD,\n voiceOptions: {\n preemptiveGeneration: true,\n },\n });\n\n const usageCollector = new metrics.UsageCollector();\n session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {\n metrics.logMetrics(ev.metrics);\n usageCollector.collect(ev.metrics);\n });\n\n const logUsage = async () => {\n const summary = usageCollector.getSummary();\n console.log(`Usage: ${JSON.stringify(summary)}`);\n };\n\n ctx.addShutdownCallback(logUsage);\n\n await session.start({\n agent: new Agent(ctx.job.metadata),\n room: ctx.room,\n });\n\n await ctx.connect();\n\n ctx.room.localParticipant?.update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GAAA;AAAA,MACvB,YAAA,EAAc;AAAA,QACZ,oBAAA,EAAsB;AAAA;AACxB,KACD,CAAA;AAED,IAAA,MAAM,cAAA,GAAiB,IAAI,OAAA,CAAQ,cAAA,EAAe;AAClD,IAAA,OAAA,CAAQ,EAAA,CAAGA,KAAAA,CAAM,sBAAA,CAAuB,gBAAA,EAAkB,CAAC,EAAA,KAAO;AAChE,MAAA,OAAA,CAAQ,UAAA,CAAW,GAAG,OAAO,CAAA;AAC7B,MAAA,cAAA,CAAe,OAAA,CAAQ,GAAG,OAAO,CAAA;AAAA,IACnC,CAAC,CAAA;AAED,IAAA,MAAM,WAAW,YAAY;AAC3B,MAAA,MAAM,OAAA,GAAU,eAAe,UAAA,EAAW;AAC1C,MAAA,OAAA,CAAQ,IAAI,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,IACjD,CAAA;AAEA,IAAA,GAAA,CAAI,oBAAoB,QAAQ,CAAA;AAEhC,IAAA,MAAM,QAAQ,KAAA,CAAM;AAAA,MAClB,KAAA,EAAO,IAAI,KAAA,CAAM,GAAA,CAAI,IAAI,QAAQ,CAAA;AAAA,MACjC,MAAM,GAAA,CAAI;AAAA,KACX,CAAA;AAED,IAAA,MAAM,IAAI,OAAA,EAAQ;AAElB,IAAA,GAAA,CAAI,IAAA,CAAK,gBAAA,EAAkB,UAAA,CAAW,QAAA,CAAS,IAAI,CAAA;AAAA,EACrD;AACF,CAAC","file":"_internal-agent.mjs","sourcesContent":["import { voice } from \"@livekit/agents\";\n\nexport class Agent extends voice.Agent {\n constructor(metadata: string) {\n const data = JSON.parse(metadata);\n super({\n instructions:\n \"You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text.\" +\n \"\\n\" +\n data.prompt,\n });\n }\n}\n","import type { LiveKitConfig, SahabAgentsOptions } from \"./types.js\";\n\nlet _options: SahabAgentsOptions | undefined;\nlet _livekitConfig: LiveKitConfig | undefined;\n\nexport function setOptions(options: SahabAgentsOptions): void {\n _options = options;\n}\n\nexport function getOptions(): SahabAgentsOptions {\n if (!_options) {\n throw new Error(\n \"SahabAgents options have not been set. Call initialize() first.\",\n );\n }\n return _options;\n}\n\nexport function setLiveKitConfig(config: LiveKitConfig): void {\n _livekitConfig = config;\n}\n\nexport function getLiveKitConfig(): LiveKitConfig {\n if (!_livekitConfig) {\n throw new Error(\n \"LiveKit config has not been set. Call initialize() first.\",\n );\n }\n return _livekitConfig;\n}\n","/**\n * Internal agent entry file — imported by LiveKit's worker process.\n *\n * Do NOT import this file directly. It is referenced by path in\n * `AgentsResource.initialize()` and dynamically loaded by LiveKit.\n */\nimport {\n defineAgent,\n JobContext,\n JobProcess,\n voice,\n metrics,\n inference,\n} from \"@livekit/agents\";\nimport * as livekit from \"@livekit/agents-plugin-livekit\";\nimport * as silero from \"@livekit/agents-plugin-silero\";\nimport { Agent } from \"./agent-instructions.js\";\nimport { getOptions } from \"./store.js\";\n\nconst options = getOptions();\n\nexport default defineAgent({\n prewarm: async (proc: JobProcess) => {\n proc.userData.vad = await silero.VAD.load();\n },\n entry: async (ctx: JobContext) => {\n const metadata = JSON.parse(ctx.job.metadata);\n\n const session = new voice.AgentSession({\n stt: new inference.STT(options.stt),\n llm: new inference.LLM(options.llm),\n tts: new inference.TTS(options.tts),\n turnDetection: new livekit.turnDetector.MultilingualModel(),\n vad: ctx.proc.userData.vad! as silero.VAD,\n voiceOptions: {\n preemptiveGeneration: true,\n },\n });\n\n const usageCollector = new metrics.UsageCollector();\n session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {\n metrics.logMetrics(ev.metrics);\n usageCollector.collect(ev.metrics);\n });\n\n const logUsage = async () => {\n const summary = usageCollector.getSummary();\n console.log(`Usage: ${JSON.stringify(summary)}`);\n };\n\n ctx.addShutdownCallback(logUsage);\n\n await session.start({\n agent: new Agent(ctx.job.metadata),\n room: ctx.room,\n });\n\n await ctx.connect();\n\n ctx.room.localParticipant?.updateName(metadata.name);\n },\n});\n"]}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SahabAgentsOptions, A as ApiErrorBody } from './types-DiUcywed.mjs';
1
+ import { S as SahabAgentsOptions, A as ApiErrorBody } from './types-BbAGABHE.mjs';
2
2
 
3
3
  declare class HttpClient {
4
4
  private readonly baseUrl;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SahabAgentsOptions, A as ApiErrorBody } from './types-DiUcywed.js';
1
+ import { S as SahabAgentsOptions, A as ApiErrorBody } from './types-BbAGABHE.js';
2
2
 
3
3
  declare class HttpClient {
4
4
  private readonly baseUrl;
package/dist/store.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { L as LiveKitConfig, S as SahabAgentsOptions } from './types-DiUcywed.mjs';
1
+ import { L as LiveKitConfig, S as SahabAgentsOptions } from './types-BbAGABHE.mjs';
2
2
 
3
3
  declare function setOptions(options: SahabAgentsOptions): void;
4
4
  declare function getOptions(): SahabAgentsOptions;
package/dist/store.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { L as LiveKitConfig, S as SahabAgentsOptions } from './types-DiUcywed.js';
1
+ import { L as LiveKitConfig, S as SahabAgentsOptions } from './types-BbAGABHE.js';
2
2
 
3
3
  declare function setOptions(options: SahabAgentsOptions): void;
4
4
  declare function getOptions(): SahabAgentsOptions;
@@ -62,14 +62,14 @@ interface APIConnectOptions {
62
62
  timeoutMs: number;
63
63
  }
64
64
  interface InferenceSTTOptions<TModel extends STTModels> {
65
- model?: TModel;
65
+ model: TModel;
66
66
  language?: STTLanguages;
67
- encoding: STTEncoding;
68
- sampleRate: number;
69
- baseURL: string;
67
+ encoding?: STTEncoding;
68
+ sampleRate?: number;
69
+ baseURL?: string;
70
70
  apiKey: string;
71
- apiSecret: string;
72
- modelOptions: STTOptions<TModel>;
71
+ apiSecret?: string;
72
+ modelOptions?: STTOptions<TModel>;
73
73
  fallback?: STTFallbackModel[];
74
74
  connOptions?: APIConnectOptions;
75
75
  }
@@ -109,15 +109,15 @@ interface TTSFallbackModel {
109
109
  extraKwargs?: Record<string, unknown>;
110
110
  }
111
111
  interface InferenceTTSOptions<TModel extends TTSModels> {
112
- model?: TModel;
112
+ model: TModel;
113
113
  voice?: string;
114
114
  language?: string;
115
- encoding: TTSEncoding;
116
- sampleRate: number;
117
- baseURL: string;
115
+ encoding?: TTSEncoding;
116
+ sampleRate?: number;
117
+ baseURL?: string;
118
118
  apiKey: string;
119
- apiSecret: string;
120
- modelOptions: TTSOptions<TModel>;
119
+ apiSecret?: string;
120
+ modelOptions?: TTSOptions<TModel>;
121
121
  fallback?: TTSFallbackModel[];
122
122
  connOptions?: APIConnectOptions;
123
123
  }
@@ -153,10 +153,10 @@ interface ChatCompletionOptions extends Record<string, unknown> {
153
153
  interface InferenceLLMOptions {
154
154
  model: LLMModels;
155
155
  provider?: string;
156
- baseURL: string;
156
+ baseURL?: string;
157
157
  apiKey: string;
158
- apiSecret: string;
159
- modelOptions: ChatCompletionOptions;
158
+ apiSecret?: string;
159
+ modelOptions?: ChatCompletionOptions;
160
160
  strictToolSchema?: boolean;
161
161
  }
162
162
  interface SahabAgentsOptions {
@@ -62,14 +62,14 @@ interface APIConnectOptions {
62
62
  timeoutMs: number;
63
63
  }
64
64
  interface InferenceSTTOptions<TModel extends STTModels> {
65
- model?: TModel;
65
+ model: TModel;
66
66
  language?: STTLanguages;
67
- encoding: STTEncoding;
68
- sampleRate: number;
69
- baseURL: string;
67
+ encoding?: STTEncoding;
68
+ sampleRate?: number;
69
+ baseURL?: string;
70
70
  apiKey: string;
71
- apiSecret: string;
72
- modelOptions: STTOptions<TModel>;
71
+ apiSecret?: string;
72
+ modelOptions?: STTOptions<TModel>;
73
73
  fallback?: STTFallbackModel[];
74
74
  connOptions?: APIConnectOptions;
75
75
  }
@@ -109,15 +109,15 @@ interface TTSFallbackModel {
109
109
  extraKwargs?: Record<string, unknown>;
110
110
  }
111
111
  interface InferenceTTSOptions<TModel extends TTSModels> {
112
- model?: TModel;
112
+ model: TModel;
113
113
  voice?: string;
114
114
  language?: string;
115
- encoding: TTSEncoding;
116
- sampleRate: number;
117
- baseURL: string;
115
+ encoding?: TTSEncoding;
116
+ sampleRate?: number;
117
+ baseURL?: string;
118
118
  apiKey: string;
119
- apiSecret: string;
120
- modelOptions: TTSOptions<TModel>;
119
+ apiSecret?: string;
120
+ modelOptions?: TTSOptions<TModel>;
121
121
  fallback?: TTSFallbackModel[];
122
122
  connOptions?: APIConnectOptions;
123
123
  }
@@ -153,10 +153,10 @@ interface ChatCompletionOptions extends Record<string, unknown> {
153
153
  interface InferenceLLMOptions {
154
154
  model: LLMModels;
155
155
  provider?: string;
156
- baseURL: string;
156
+ baseURL?: string;
157
157
  apiKey: string;
158
- apiSecret: string;
159
- modelOptions: ChatCompletionOptions;
158
+ apiSecret?: string;
159
+ modelOptions?: ChatCompletionOptions;
160
160
  strictToolSchema?: boolean;
161
161
  }
162
162
  interface SahabAgentsOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sahab-platform/agents",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "TypeScript SDK for the Sahab Agents API",
5
5
  "author": "",
6
6
  "license": "MIT",