agora-agents 2.2.0 → 2.4.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/README.md +48 -26
- package/dist/cjs/AgoraPoolClient.d.ts +9 -6
- package/dist/cjs/AgoraPoolClient.js +1 -0
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.js +8 -16
- package/dist/cjs/agentkit/Agent.d.ts +52 -51
- package/dist/cjs/agentkit/Agent.js +46 -44
- package/dist/cjs/agentkit/AgentSession.d.ts +11 -10
- package/dist/cjs/agentkit/AgentSession.js +12 -6
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +1 -0
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +57 -0
- package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +1 -0
- package/dist/cjs/agentkit/__tests__/readme-examples.test.js +126 -0
- package/dist/cjs/agentkit/__tests__/type-safety.test.js +24 -17
- package/dist/cjs/agentkit/area.d.ts +4 -0
- package/dist/cjs/agentkit/area.js +2 -0
- package/dist/cjs/agentkit/avatar-types.d.ts +43 -4
- package/dist/cjs/agentkit/avatar-types.js +52 -2
- package/dist/cjs/agentkit/index.d.ts +12 -9
- package/dist/cjs/agentkit/index.js +32 -2
- package/dist/cjs/agentkit/region-vendors.d.ts +15 -0
- package/dist/cjs/agentkit/region-vendors.js +2 -0
- package/dist/cjs/agentkit/token.d.ts +3 -2
- package/dist/cjs/agentkit/token.js +3 -2
- package/dist/cjs/agentkit/types.d.ts +47 -9
- package/dist/cjs/agentkit/vendors/avatar.d.ts +9 -6
- package/dist/cjs/agentkit/vendors/avatar.js +9 -6
- package/dist/cjs/agentkit/vendors/base.d.ts +42 -5
- package/dist/cjs/agentkit/vendors/base.js +64 -6
- package/dist/cjs/agentkit/vendors/cn.d.ts +269 -0
- package/dist/cjs/agentkit/vendors/cn.js +313 -0
- package/dist/cjs/agentkit/vendors/llm.d.ts +1 -1
- package/dist/cjs/agentkit/vendors/llm.js +13 -3
- package/dist/cjs/agentkit/vendors/mllm.d.ts +8 -4
- package/dist/cjs/agentkit/vendors/mllm.js +10 -6
- package/dist/cjs/agentkit/vendors/stt.d.ts +31 -0
- package/dist/cjs/agentkit/vendors/stt.js +31 -1
- package/dist/cjs/agentkit/vendors/tts.d.ts +63 -3
- package/dist/cjs/agentkit/vendors/tts.js +42 -1
- package/dist/cjs/api/resources/agents/client/requests/ListAgentsRequest.d.ts +2 -3
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +23 -3
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +12 -0
- package/dist/cjs/api/resources/agents/types/GetHistoryAgentsResponse.d.ts +6 -0
- package/dist/cjs/api/resources/agents/types/index.d.ts +0 -1
- package/dist/cjs/api/resources/agents/types/index.js +0 -1
- package/dist/cjs/api/types/Asr.d.ts +19 -1
- package/dist/cjs/api/types/BytedanceDuplexTts.d.ts +9 -0
- package/dist/cjs/api/types/BytedanceDuplexTts.js +3 -0
- package/dist/cjs/api/types/BytedanceDuplexTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/BytedanceDuplexTtsParams.js +3 -0
- package/dist/cjs/api/types/BytedanceTts.d.ts +9 -0
- package/dist/cjs/api/types/BytedanceTts.js +3 -0
- package/dist/cjs/api/types/BytedanceTtsParams.d.ts +23 -0
- package/dist/cjs/api/types/BytedanceTtsParams.js +3 -0
- package/dist/cjs/api/types/CosyvoiceTts.d.ts +9 -0
- package/dist/cjs/api/types/CosyvoiceTts.js +3 -0
- package/dist/cjs/api/types/CosyvoiceTtsParams.d.ts +15 -0
- package/dist/cjs/api/types/CosyvoiceTtsParams.js +3 -0
- package/dist/cjs/api/types/FengmingAsr.d.ts +11 -0
- package/dist/cjs/api/types/FengmingAsr.js +3 -0
- package/dist/cjs/api/types/GenericTts.d.ts +13 -0
- package/dist/cjs/api/types/GenericTts.js +3 -0
- package/dist/cjs/api/types/GenericTtsParams.d.ts +21 -0
- package/dist/cjs/api/types/GenericTtsParams.js +3 -0
- package/dist/cjs/api/types/Llm.d.ts +24 -1
- package/dist/cjs/api/types/Llm.js +8 -0
- package/dist/cjs/api/types/MinimaxTtsParams.d.ts +52 -3
- package/dist/cjs/api/types/OpenAiTtsParams.d.ts +1 -1
- package/dist/cjs/api/types/SensetimeAvatarParams.d.ts +48 -0
- package/dist/cjs/api/types/SensetimeAvatarParams.js +3 -0
- package/dist/cjs/api/types/SpatiusAvatarParams.d.ts +23 -0
- package/dist/cjs/api/types/SpatiusAvatarParams.js +3 -0
- package/dist/cjs/api/types/StepfunTts.d.ts +9 -0
- package/dist/cjs/api/types/StepfunTts.js +3 -0
- package/dist/cjs/api/types/StepfunTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/StepfunTtsParams.js +3 -0
- package/dist/cjs/api/types/TencentAsr.d.ts +10 -0
- package/dist/cjs/api/types/TencentAsr.js +3 -0
- package/dist/cjs/api/types/TencentAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/TencentAsrParams.js +3 -0
- package/dist/cjs/api/types/TencentTts.d.ts +9 -0
- package/dist/cjs/api/types/TencentTts.js +3 -0
- package/dist/cjs/api/types/TencentTtsParams.d.ts +23 -0
- package/dist/cjs/api/types/TencentTtsParams.js +3 -0
- package/dist/cjs/api/types/Tts.d.ts +22 -1
- package/dist/cjs/api/types/XAiAsr.d.ts +10 -0
- package/dist/cjs/api/types/XAiAsr.js +3 -0
- package/dist/cjs/api/types/XAiAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XAiAsrParams.js +3 -0
- package/dist/cjs/api/types/XAiTts.d.ts +9 -0
- package/dist/cjs/api/types/XAiTts.js +3 -0
- package/dist/cjs/api/types/XAiTtsParams.d.ts +15 -0
- package/dist/cjs/api/types/XAiTtsParams.js +3 -0
- package/dist/cjs/api/types/XfyunAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunAsr.js +3 -0
- package/dist/cjs/api/types/XfyunAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XfyunAsrParams.js +3 -0
- package/dist/cjs/api/types/XfyunBigmodelAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunBigmodelAsr.js +3 -0
- package/dist/cjs/api/types/XfyunBigmodelAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/XfyunBigmodelAsrParams.js +3 -0
- package/dist/cjs/api/types/XfyunDialectAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunDialectAsr.js +3 -0
- package/dist/cjs/api/types/XfyunDialectAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XfyunDialectAsrParams.js +3 -0
- package/dist/cjs/api/types/index.d.ts +27 -0
- package/dist/cjs/api/types/index.js +27 -0
- package/dist/cjs/core/base64.js +1 -5
- package/dist/cjs/core/domain/index.d.ts +2 -1
- package/dist/cjs/core/domain/index.js +5 -3
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +31 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/AgoraPoolClient.d.mts +9 -6
- package/dist/esm/AgoraPoolClient.mjs +1 -0
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.mjs +8 -16
- package/dist/esm/agentkit/Agent.d.mts +52 -51
- package/dist/esm/agentkit/Agent.mjs +46 -44
- package/dist/esm/agentkit/AgentSession.d.mts +11 -10
- package/dist/esm/agentkit/AgentSession.mjs +13 -7
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +1 -0
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +55 -0
- package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +1 -0
- package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +124 -0
- package/dist/esm/agentkit/__tests__/type-safety.test.mjs +24 -17
- package/dist/esm/agentkit/area.d.mts +4 -0
- package/dist/esm/agentkit/area.mjs +1 -0
- package/dist/esm/agentkit/avatar-types.d.mts +43 -4
- package/dist/esm/agentkit/avatar-types.mjs +50 -2
- package/dist/esm/agentkit/index.d.mts +12 -9
- package/dist/esm/agentkit/index.mjs +5 -4
- package/dist/esm/agentkit/region-vendors.d.mts +15 -0
- package/dist/esm/agentkit/region-vendors.mjs +1 -0
- package/dist/esm/agentkit/token.d.mts +3 -2
- package/dist/esm/agentkit/token.mjs +3 -2
- package/dist/esm/agentkit/types.d.mts +47 -9
- package/dist/esm/agentkit/vendors/avatar.d.mts +9 -6
- package/dist/esm/agentkit/vendors/avatar.mjs +9 -6
- package/dist/esm/agentkit/vendors/base.d.mts +42 -5
- package/dist/esm/agentkit/vendors/base.mjs +59 -5
- package/dist/esm/agentkit/vendors/cn.d.mts +269 -0
- package/dist/esm/agentkit/vendors/cn.mjs +291 -0
- package/dist/esm/agentkit/vendors/llm.d.mts +1 -1
- package/dist/esm/agentkit/vendors/llm.mjs +13 -3
- package/dist/esm/agentkit/vendors/mllm.d.mts +8 -4
- package/dist/esm/agentkit/vendors/mllm.mjs +10 -6
- package/dist/esm/agentkit/vendors/stt.d.mts +31 -0
- package/dist/esm/agentkit/vendors/stt.mjs +29 -0
- package/dist/esm/agentkit/vendors/tts.d.mts +63 -3
- package/dist/esm/agentkit/vendors/tts.mjs +39 -0
- package/dist/esm/api/resources/agents/client/requests/ListAgentsRequest.d.mts +2 -3
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +23 -3
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +12 -0
- package/dist/esm/api/resources/agents/types/GetHistoryAgentsResponse.d.mts +6 -0
- package/dist/esm/api/resources/agents/types/index.d.mts +0 -1
- package/dist/esm/api/resources/agents/types/index.mjs +0 -1
- package/dist/esm/api/types/Asr.d.mts +19 -1
- package/dist/esm/api/types/BytedanceDuplexTts.d.mts +9 -0
- package/dist/esm/api/types/BytedanceDuplexTts.mjs +2 -0
- package/dist/esm/api/types/BytedanceDuplexTtsParams.d.mts +13 -0
- package/dist/esm/api/types/BytedanceDuplexTtsParams.mjs +2 -0
- package/dist/esm/api/types/BytedanceTts.d.mts +9 -0
- package/dist/esm/api/types/BytedanceTts.mjs +2 -0
- package/dist/esm/api/types/BytedanceTtsParams.d.mts +23 -0
- package/dist/esm/api/types/BytedanceTtsParams.mjs +2 -0
- package/dist/esm/api/types/CosyvoiceTts.d.mts +9 -0
- package/dist/esm/api/types/CosyvoiceTts.mjs +2 -0
- package/dist/esm/api/types/CosyvoiceTtsParams.d.mts +15 -0
- package/dist/esm/api/types/CosyvoiceTtsParams.mjs +2 -0
- package/dist/esm/api/types/FengmingAsr.d.mts +11 -0
- package/dist/esm/api/types/FengmingAsr.mjs +2 -0
- package/dist/esm/api/types/GenericTts.d.mts +13 -0
- package/dist/esm/api/types/GenericTts.mjs +2 -0
- package/dist/esm/api/types/GenericTtsParams.d.mts +21 -0
- package/dist/esm/api/types/GenericTtsParams.mjs +2 -0
- package/dist/esm/api/types/Llm.d.mts +24 -1
- package/dist/esm/api/types/Llm.mjs +8 -0
- package/dist/esm/api/types/MinimaxTtsParams.d.mts +52 -3
- package/dist/esm/api/types/OpenAiTtsParams.d.mts +1 -1
- package/dist/esm/api/types/SensetimeAvatarParams.d.mts +48 -0
- package/dist/esm/api/types/SensetimeAvatarParams.mjs +2 -0
- package/dist/esm/api/types/SpatiusAvatarParams.d.mts +23 -0
- package/dist/esm/api/types/SpatiusAvatarParams.mjs +2 -0
- package/dist/esm/api/types/StepfunTts.d.mts +9 -0
- package/dist/esm/api/types/StepfunTts.mjs +2 -0
- package/dist/esm/api/types/StepfunTtsParams.d.mts +13 -0
- package/dist/esm/api/types/StepfunTtsParams.mjs +2 -0
- package/dist/esm/api/types/TencentAsr.d.mts +10 -0
- package/dist/esm/api/types/TencentAsr.mjs +2 -0
- package/dist/esm/api/types/TencentAsrParams.d.mts +17 -0
- package/dist/esm/api/types/TencentAsrParams.mjs +2 -0
- package/dist/esm/api/types/TencentTts.d.mts +9 -0
- package/dist/esm/api/types/TencentTts.mjs +2 -0
- package/dist/esm/api/types/TencentTtsParams.d.mts +23 -0
- package/dist/esm/api/types/TencentTtsParams.mjs +2 -0
- package/dist/esm/api/types/Tts.d.mts +22 -1
- package/dist/esm/api/types/XAiAsr.d.mts +10 -0
- package/dist/esm/api/types/XAiAsr.mjs +2 -0
- package/dist/esm/api/types/XAiAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XAiAsrParams.mjs +2 -0
- package/dist/esm/api/types/XAiTts.d.mts +9 -0
- package/dist/esm/api/types/XAiTts.mjs +2 -0
- package/dist/esm/api/types/XAiTtsParams.d.mts +15 -0
- package/dist/esm/api/types/XAiTtsParams.mjs +2 -0
- package/dist/esm/api/types/XfyunAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XfyunAsrParams.mjs +2 -0
- package/dist/esm/api/types/XfyunBigmodelAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunBigmodelAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunBigmodelAsrParams.d.mts +17 -0
- package/dist/esm/api/types/XfyunBigmodelAsrParams.mjs +2 -0
- package/dist/esm/api/types/XfyunDialectAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunDialectAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunDialectAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XfyunDialectAsrParams.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +27 -0
- package/dist/esm/api/types/index.mjs +27 -0
- package/dist/esm/core/base64.mjs +1 -5
- package/dist/esm/core/domain/index.d.mts +2 -1
- package/dist/esm/core/domain/index.mjs +4 -2
- package/dist/esm/index.d.mts +3 -2
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/api/resources/agents/types/ListAgentsRequestState.d.ts +0 -10
- package/dist/cjs/api/resources/agents/types/ListAgentsRequestState.js +0 -13
- package/dist/esm/api/resources/agents/types/ListAgentsRequestState.d.mts +0 -10
- package/dist/esm/api/resources/agents/types/ListAgentsRequestState.mjs +0 -10
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
* Agent class - A reusable agent definition.
|
|
4
4
|
*
|
|
5
5
|
* This class represents an agent configuration that can be used to create
|
|
6
|
-
* multiple sessions.
|
|
6
|
+
* multiple sessions. Set the unique agent instance `name` in
|
|
7
|
+
* {@link Agent.createSession}, not on the Agent itself.
|
|
7
8
|
*/
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
10
|
exports.Agent = void 0;
|
|
11
|
+
const index_js_1 = require("../core/domain/index.js");
|
|
10
12
|
const AgentSession_js_1 = require("./AgentSession.js");
|
|
13
|
+
const constants_js_1 = require("./constants.js");
|
|
11
14
|
const token_js_1 = require("./token.js");
|
|
12
15
|
const DEFAULT_TURN_DETECTION_LANGUAGE = "en-US";
|
|
13
16
|
const INTERACTION_LANGUAGES = new Set([
|
|
@@ -62,15 +65,22 @@ function assertTurnDetectionLanguage(value) {
|
|
|
62
65
|
* import { Agent, OpenAI, MicrosoftTTS, DeepgramSTT } from 'agora-agents';
|
|
63
66
|
*
|
|
64
67
|
* // Use the fluent builder pattern to configure vendors
|
|
65
|
-
* const agent = new Agent({ instructions: 'You are helpful.' })
|
|
68
|
+
* const agent = new Agent({ client, instructions: 'You are helpful.' })
|
|
66
69
|
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
67
70
|
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
68
71
|
* .withStt(new DeepgramSTT({ apiKey: '...', model: 'nova-2' }));
|
|
72
|
+
*
|
|
73
|
+
* const session = agent.createSession({
|
|
74
|
+
* name: `conversation-${Date.now()}`,
|
|
75
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
76
|
+
* agentUid: '1',
|
|
77
|
+
* remoteUids: ['100'],
|
|
78
|
+
* });
|
|
69
79
|
* ```
|
|
70
80
|
*/
|
|
71
81
|
class Agent {
|
|
72
|
-
constructor(options
|
|
73
|
-
this.
|
|
82
|
+
constructor(options) {
|
|
83
|
+
this._client = options.client;
|
|
74
84
|
this._pipelineId = options.pipelineId;
|
|
75
85
|
this._instructions = options.instructions;
|
|
76
86
|
this._greeting = options.greeting;
|
|
@@ -205,7 +215,8 @@ class Agent {
|
|
|
205
215
|
* ```typescript
|
|
206
216
|
* import { HeyGenAvatar, ElevenLabsTTS } from 'agora-agents';
|
|
207
217
|
*
|
|
208
|
-
* const
|
|
218
|
+
* const client = new AgoraClient({ area: Area.US, appId: '...', appCertificate: '...' });
|
|
219
|
+
* const agent = new Agent({ client })
|
|
209
220
|
* .withTts(new ElevenLabsTTS({
|
|
210
221
|
* key: '...',
|
|
211
222
|
* modelId: '...',
|
|
@@ -276,14 +287,6 @@ class Agent {
|
|
|
276
287
|
newAgent._greetingConfigs = configs;
|
|
277
288
|
return newAgent;
|
|
278
289
|
}
|
|
279
|
-
/**
|
|
280
|
-
* Returns a new Agent with the specified name.
|
|
281
|
-
*/
|
|
282
|
-
withName(name) {
|
|
283
|
-
const newAgent = this._clone();
|
|
284
|
-
newAgent._name = name;
|
|
285
|
-
return newAgent;
|
|
286
|
-
}
|
|
287
290
|
/**
|
|
288
291
|
* Returns a new Agent with the specified SAL (Selective Attention Locking) configuration.
|
|
289
292
|
*/
|
|
@@ -389,12 +392,6 @@ class Agent {
|
|
|
389
392
|
newAgent._fillerWords = fillerWords;
|
|
390
393
|
return newAgent;
|
|
391
394
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Get the agent name.
|
|
394
|
-
*/
|
|
395
|
-
get name() {
|
|
396
|
-
return this._name;
|
|
397
|
-
}
|
|
398
395
|
/**
|
|
399
396
|
* Get the AI Studio pipeline ID used as this agent's base configuration.
|
|
400
397
|
*/
|
|
@@ -522,7 +519,7 @@ class Agent {
|
|
|
522
519
|
*/
|
|
523
520
|
get config() {
|
|
524
521
|
return {
|
|
525
|
-
|
|
522
|
+
client: this._client,
|
|
526
523
|
pipelineId: this._pipelineId,
|
|
527
524
|
instructions: this._instructions,
|
|
528
525
|
turnDetection: this._turnDetection,
|
|
@@ -548,18 +545,19 @@ class Agent {
|
|
|
548
545
|
/**
|
|
549
546
|
* Creates a new session from this agent configuration.
|
|
550
547
|
*
|
|
551
|
-
* @param client - The Agora client instance (must have appId and appCertificate properties)
|
|
552
548
|
* @param options - Session connection options
|
|
553
549
|
* @returns A new AgentSession instance ready to start
|
|
554
550
|
*
|
|
555
551
|
* @example
|
|
556
552
|
* ```typescript
|
|
557
|
-
* const
|
|
558
|
-
*
|
|
559
|
-
* .
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
553
|
+
* const client = new AgoraClient({ area: Area.US, appId: '...', appCertificate: '...' });
|
|
554
|
+
* const agent = new Agent({ client })
|
|
555
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
556
|
+
* .withTts(new MiniMaxTTS({ model: 'speech_2_6_turbo', voiceId: 'English_captivating_female1' }));
|
|
557
|
+
*
|
|
558
|
+
* const session = agent.createSession({
|
|
559
|
+
* name: `conversation-${Date.now()}`,
|
|
560
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
563
561
|
* agentUid: '1',
|
|
564
562
|
* remoteUids: ['100'],
|
|
565
563
|
* idleTimeout: 120,
|
|
@@ -568,10 +566,10 @@ class Agent {
|
|
|
568
566
|
* const agentId = await session.start();
|
|
569
567
|
* ```
|
|
570
568
|
*/
|
|
571
|
-
createSession(
|
|
572
|
-
var _a
|
|
573
|
-
const name = (
|
|
574
|
-
return new AgentSession_js_1.AgentSession(Object.assign(Object.assign({ client, agent: this, appId:
|
|
569
|
+
createSession(options) {
|
|
570
|
+
var _a;
|
|
571
|
+
const name = (_a = options.name) !== null && _a !== void 0 ? _a : `agent-${Date.now()}`;
|
|
572
|
+
return new AgentSession_js_1.AgentSession(Object.assign(Object.assign({ client: this._client, agent: this, appId: this._client.appId, appCertificate: this._client.appCertificate }, options), { name }));
|
|
575
573
|
}
|
|
576
574
|
/**
|
|
577
575
|
* Converts the Agent configuration to the Fern request properties format.
|
|
@@ -581,7 +579,7 @@ class Agent {
|
|
|
581
579
|
* and RTM privileges (required for RTM-enabled sessions).
|
|
582
580
|
*/
|
|
583
581
|
toProperties(opts) {
|
|
584
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
582
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
585
583
|
// In MLLM mode the backend handles audio end-to-end; LLM, TTS, and ASR
|
|
586
584
|
// are not required.
|
|
587
585
|
const isMllmMode = ((_a = this._mllm) === null || _a === void 0 ? void 0 : _a.enable) === true || this._mllm !== undefined;
|
|
@@ -614,8 +612,13 @@ class Agent {
|
|
|
614
612
|
// When RTM is enabled, data_channel must also be 'rtm' for the client
|
|
615
613
|
// to receive transcripts and state events. Default it automatically so
|
|
616
614
|
// callers only need to set advancedFeatures.enable_rtm: true.
|
|
617
|
-
|
|
618
|
-
|
|
615
|
+
let resolvedParameters = this._parameters;
|
|
616
|
+
if (((_b = this._advancedFeatures) === null || _b === void 0 ? void 0 : _b.enable_rtm) && !(resolvedParameters === null || resolvedParameters === void 0 ? void 0 : resolvedParameters.data_channel)) {
|
|
617
|
+
resolvedParameters = Object.assign(Object.assign({}, resolvedParameters), { data_channel: "rtm" });
|
|
618
|
+
}
|
|
619
|
+
if ((resolvedParameters === null || resolvedParameters === void 0 ? void 0 : resolvedParameters.audio_scenario) === undefined) {
|
|
620
|
+
resolvedParameters = Object.assign(Object.assign({}, resolvedParameters), { audio_scenario: constants_js_1.AudioScenario.Default });
|
|
621
|
+
}
|
|
619
622
|
const base = {
|
|
620
623
|
channel: opts.channel,
|
|
621
624
|
token,
|
|
@@ -649,8 +652,8 @@ class Agent {
|
|
|
649
652
|
}
|
|
650
653
|
return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
|
|
651
654
|
}
|
|
652
|
-
const skipCategories = new Set((
|
|
653
|
-
const allowMissingCategories = new Set((
|
|
655
|
+
const skipCategories = new Set((_c = opts.skipVendorValidationCategories) !== null && _c !== void 0 ? _c : []);
|
|
656
|
+
const allowMissingCategories = new Set((_d = opts.allowMissingVendorCategories) !== null && _d !== void 0 ? _d : []);
|
|
654
657
|
if (opts.skipVendorValidation) {
|
|
655
658
|
for (const category of ["asr", "llm", "tts"]) {
|
|
656
659
|
skipCategories.add(category);
|
|
@@ -673,7 +676,7 @@ class Agent {
|
|
|
673
676
|
? this._llm.system_messages
|
|
674
677
|
: this._instructions
|
|
675
678
|
? [{ role: "system", content: this._instructions }]
|
|
676
|
-
: undefined, greeting_message: (
|
|
679
|
+
: undefined, greeting_message: (_e = this._llm.greeting_message) !== null && _e !== void 0 ? _e : this._greeting, greeting_configs: (_f = this._llm.greeting_configs) !== null && _f !== void 0 ? _f : this._greetingConfigs, failure_message: (_g = this._llm.failure_message) !== null && _g !== void 0 ? _g : this._failureMessage, max_history: (_h = this._llm.max_history) !== null && _h !== void 0 ? _h : this._maxHistory }) : undefined;
|
|
677
680
|
const turnDetectionConfig = this._resolveTurnDetectionConfig();
|
|
678
681
|
const asrConfig = this._stt !== undefined || !allowMissingAsr
|
|
679
682
|
? this._resolveAsrConfig(turnDetectionConfig)
|
|
@@ -691,8 +694,7 @@ class Agent {
|
|
|
691
694
|
* If a new private field is added to Agent, it MUST also be added here.
|
|
692
695
|
*/
|
|
693
696
|
_clone() {
|
|
694
|
-
const newAgent = new Agent();
|
|
695
|
-
newAgent._name = this._name;
|
|
697
|
+
const newAgent = new Agent({ client: this._client });
|
|
696
698
|
newAgent._pipelineId = this._pipelineId;
|
|
697
699
|
newAgent._llm = this._llm;
|
|
698
700
|
newAgent._tts = this._tts;
|
|
@@ -716,11 +718,11 @@ class Agent {
|
|
|
716
718
|
return newAgent;
|
|
717
719
|
}
|
|
718
720
|
_resolveAsrConfig(turnDetectionConfig) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
721
|
+
const asrConfig = this._stt !== undefined
|
|
722
|
+
? Object.assign({}, this._stt)
|
|
723
|
+
: {
|
|
724
|
+
vendor: this._client.area === index_js_1.Area.CN ? "fengming" : "ares",
|
|
725
|
+
};
|
|
724
726
|
asrConfig.language = turnDetectionConfig.language;
|
|
725
727
|
return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
|
|
726
728
|
}
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* This class provides a high-level interface for managing agent sessions,
|
|
5
5
|
* including starting, stopping, and interacting with the agent.
|
|
6
6
|
*/
|
|
7
|
+
import type { AgoraClient } from "../AgoraPoolClient.js";
|
|
7
8
|
import type { AgentManagementClient } from "../api/resources/agentManagement/client/Client.js";
|
|
8
9
|
import type { AgentsClient } from "../api/resources/agents/client/Client.js";
|
|
9
|
-
import type { AgoraClient } from "../Client.js";
|
|
10
10
|
import type { Agent } from "./Agent.js";
|
|
11
|
+
import type { AgoraArea } from "./area.js";
|
|
11
12
|
import { type PresetInput } from "./presets.js";
|
|
12
13
|
import type { AgentConfigUpdate, ConversationHistory, ConversationTurns, GetTurnsOptions, SayOptions, SessionInfo, ThinkOptions, ThinkResponse } from "./types.js";
|
|
13
14
|
/**
|
|
@@ -23,14 +24,14 @@ export type AgentSessionEventHandler<T = unknown> = (data: T) => void;
|
|
|
23
24
|
*/
|
|
24
25
|
export interface AgentSessionOptions {
|
|
25
26
|
/** The Agora client instance */
|
|
26
|
-
client: AgoraClient
|
|
27
|
+
client: AgoraClient<AgoraArea>;
|
|
27
28
|
/** The agent configuration */
|
|
28
|
-
agent: Agent
|
|
29
|
+
agent: Agent<number, AgoraArea>;
|
|
29
30
|
/** The App ID */
|
|
30
31
|
appId: string;
|
|
31
32
|
/** The App Certificate — enables automatic RTC token generation when starting sessions */
|
|
32
33
|
appCertificate?: string;
|
|
33
|
-
/** Unique name
|
|
34
|
+
/** Unique agent instance name (set via {@link Agent.createSession}) */
|
|
34
35
|
name: string;
|
|
35
36
|
/** The channel to join */
|
|
36
37
|
channel: string;
|
|
@@ -73,18 +74,18 @@ export interface AgentSessionOptions {
|
|
|
73
74
|
*
|
|
74
75
|
* const client = new AgoraClient({
|
|
75
76
|
* area: Area.US,
|
|
76
|
-
|
|
77
77
|
* appId: '...',
|
|
78
78
|
* appCertificate: '...',
|
|
79
79
|
* });
|
|
80
80
|
*
|
|
81
|
-
* const agent = new Agent({
|
|
81
|
+
* const agent = new Agent({ client, instructions: 'You are a helpful voice assistant.' })
|
|
82
82
|
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
83
83
|
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
84
84
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
85
85
|
*
|
|
86
|
-
* const session = agent.createSession(
|
|
87
|
-
*
|
|
86
|
+
* const session = agent.createSession({
|
|
87
|
+
* name: `conversation-${Date.now()}`,
|
|
88
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
88
89
|
* agentUid: '1',
|
|
89
90
|
* remoteUids: ['100'],
|
|
90
91
|
* });
|
|
@@ -137,7 +138,7 @@ export declare class AgentSession {
|
|
|
137
138
|
/**
|
|
138
139
|
* The agent configuration.
|
|
139
140
|
*/
|
|
140
|
-
get agent(): Agent
|
|
141
|
+
get agent(): Agent<number, AgoraArea>;
|
|
141
142
|
/**
|
|
142
143
|
* The App ID for this session.
|
|
143
144
|
*/
|
|
@@ -184,7 +185,7 @@ export declare class AgentSession {
|
|
|
184
185
|
* Fills session-derived avatar fields and generates avatar ConvoAI tokens.
|
|
185
186
|
*
|
|
186
187
|
* Token management is gated to vendors that publish a separate RTC video
|
|
187
|
-
* identity (HeyGen, LiveAvatar, Generic). Other vendors (Akool, Anam) do
|
|
188
|
+
* identity (HeyGen, LiveAvatar, Generic, SenseTime). Other vendors (Akool, Anam) do
|
|
188
189
|
* not run a separate publisher and never receive an auto-generated token.
|
|
189
190
|
*/
|
|
190
191
|
private _enrichAvatarParams;
|
|
@@ -31,18 +31,18 @@ const token_js_1 = require("./token.js");
|
|
|
31
31
|
*
|
|
32
32
|
* const client = new AgoraClient({
|
|
33
33
|
* area: Area.US,
|
|
34
|
-
|
|
35
34
|
* appId: '...',
|
|
36
35
|
* appCertificate: '...',
|
|
37
36
|
* });
|
|
38
37
|
*
|
|
39
|
-
* const agent = new Agent({
|
|
38
|
+
* const agent = new Agent({ client, instructions: 'You are a helpful voice assistant.' })
|
|
40
39
|
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
41
40
|
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
42
41
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
43
42
|
*
|
|
44
|
-
* const session = agent.createSession(
|
|
45
|
-
*
|
|
43
|
+
* const session = agent.createSession({
|
|
44
|
+
* name: `conversation-${Date.now()}`,
|
|
45
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
46
46
|
* agentUid: '1',
|
|
47
47
|
* remoteUids: ['100'],
|
|
48
48
|
* });
|
|
@@ -194,6 +194,8 @@ class AgentSession {
|
|
|
194
194
|
// are filled by `_enrichAvatarParams()` and validated separately.
|
|
195
195
|
if ((0, avatar_types_js_1.isHeyGenAvatar)(strictAvatar) ||
|
|
196
196
|
(0, avatar_types_js_1.isLiveAvatarAvatar)(strictAvatar) ||
|
|
197
|
+
(0, avatar_types_js_1.isSensetimeAvatar)(strictAvatar) ||
|
|
198
|
+
(0, avatar_types_js_1.isSpatiusAvatar)(strictAvatar) ||
|
|
197
199
|
(0, avatar_types_js_1.isAkoolAvatar)(strictAvatar) ||
|
|
198
200
|
(0, avatar_types_js_1.isAnamAvatar)(strictAvatar) ||
|
|
199
201
|
(0, avatar_types_js_1.isGenericAvatar)(strictAvatar)) {
|
|
@@ -229,7 +231,7 @@ class AgentSession {
|
|
|
229
231
|
* Fills session-derived avatar fields and generates avatar ConvoAI tokens.
|
|
230
232
|
*
|
|
231
233
|
* Token management is gated to vendors that publish a separate RTC video
|
|
232
|
-
* identity (HeyGen, LiveAvatar, Generic). Other vendors (Akool, Anam) do
|
|
234
|
+
* identity (HeyGen, LiveAvatar, Generic, SenseTime). Other vendors (Akool, Anam) do
|
|
233
235
|
* not run a separate publisher and never receive an auto-generated token.
|
|
234
236
|
*/
|
|
235
237
|
_enrichAvatarParams(properties, expirySeconds) {
|
|
@@ -280,10 +282,14 @@ class AgentSession {
|
|
|
280
282
|
const strictAvatar = avatar;
|
|
281
283
|
if ((0, avatar_types_js_1.isHeyGenAvatar)(strictAvatar) ||
|
|
282
284
|
(0, avatar_types_js_1.isLiveAvatarAvatar)(strictAvatar) ||
|
|
285
|
+
(0, avatar_types_js_1.isSensetimeAvatar)(strictAvatar) ||
|
|
286
|
+
(0, avatar_types_js_1.isSpatiusAvatar)(strictAvatar) ||
|
|
283
287
|
(0, avatar_types_js_1.isAkoolAvatar)(strictAvatar) ||
|
|
284
288
|
(0, avatar_types_js_1.isAnamAvatar)(strictAvatar) ||
|
|
285
289
|
(0, avatar_types_js_1.isGenericAvatar)(strictAvatar)) {
|
|
286
|
-
(0, avatar_types_js_1.validateAvatarConfig)(strictAvatar, {
|
|
290
|
+
(0, avatar_types_js_1.validateAvatarConfig)(strictAvatar, {
|
|
291
|
+
requireSessionFields: (0, avatar_types_js_1.isGenericAvatar)(strictAvatar),
|
|
292
|
+
});
|
|
287
293
|
}
|
|
288
294
|
if (!(0, avatar_types_js_1.isAvatarTokenManaged)(strictAvatar)) {
|
|
289
295
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AgoraPoolClient_js_1 = require("../../AgoraPoolClient.js");
|
|
4
|
+
const index_js_1 = require("../../core/domain/index.js");
|
|
5
|
+
const Agent_js_1 = require("../Agent.js");
|
|
6
|
+
const cn_js_1 = require("../vendors/cn.js");
|
|
7
|
+
const llm_js_1 = require("../vendors/llm.js");
|
|
8
|
+
const stt_js_1 = require("../vendors/stt.js");
|
|
9
|
+
const tts_js_1 = require("../vendors/tts.js");
|
|
10
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
11
|
+
area: index_js_1.Area.US,
|
|
12
|
+
appId: "app-id",
|
|
13
|
+
appCertificate: "app-certificate",
|
|
14
|
+
});
|
|
15
|
+
new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
|
|
16
|
+
.withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }))
|
|
17
|
+
.withLlm(new llm_js_1.OpenAI({ model: "gpt-5-mini" }))
|
|
18
|
+
.withTts(new tts_js_1.MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }))
|
|
19
|
+
.createSession({
|
|
20
|
+
name: "assistant",
|
|
21
|
+
channel: "test-room",
|
|
22
|
+
agentUid: "1",
|
|
23
|
+
remoteUids: ["100"],
|
|
24
|
+
});
|
|
25
|
+
// Area and provider may differ.
|
|
26
|
+
new Agent_js_1.Agent({ client }).withStt(new cn_js_1.FengmingSTT());
|
|
27
|
+
new Agent_js_1.Agent({ client }).withLlm(new cn_js_1.AliyunLLM({ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", model: "qwen-plus" }));
|
|
28
|
+
new Agent_js_1.Agent({ client }).withTts(new cn_js_1.MiniMaxCNTTS({ key: "minimax-key", model: "speech-01-turbo", voiceSetting: { voice_id: "female-shaonv" } }));
|
|
29
|
+
{
|
|
30
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
31
|
+
area: index_js_1.Area.CN,
|
|
32
|
+
appId: "app-id",
|
|
33
|
+
appCertificate: "app-certificate",
|
|
34
|
+
});
|
|
35
|
+
new Agent_js_1.Agent({ client, turnDetection: { language: "zh-CN" } })
|
|
36
|
+
.withStt(new cn_js_1.FengmingSTT())
|
|
37
|
+
.withLlm(new cn_js_1.AliyunLLM({
|
|
38
|
+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
39
|
+
model: "qwen-plus",
|
|
40
|
+
}))
|
|
41
|
+
.withTts(new cn_js_1.MiniMaxCNTTS({
|
|
42
|
+
key: "minimax-key",
|
|
43
|
+
model: "speech-01-turbo",
|
|
44
|
+
voiceSetting: { voice_id: "female-shaonv" },
|
|
45
|
+
audioSetting: { sample_rate: 16000 },
|
|
46
|
+
}))
|
|
47
|
+
.createSession({
|
|
48
|
+
name: "assistant",
|
|
49
|
+
channel: "cn-room",
|
|
50
|
+
agentUid: "1",
|
|
51
|
+
remoteUids: ["100"],
|
|
52
|
+
});
|
|
53
|
+
new Agent_js_1.Agent({ client }).withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
54
|
+
new Agent_js_1.Agent({ client }).withLlm(new llm_js_1.OpenAI({ model: "gpt-5-mini" }));
|
|
55
|
+
new Agent_js_1.Agent({ client }).withTts(new tts_js_1.MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }));
|
|
56
|
+
}
|
|
57
|
+
new Agent_js_1.Agent({ client }).withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AgoraPoolClient_js_1 = require("../../AgoraPoolClient.js");
|
|
4
|
+
const index_js_1 = require("../../core/domain/index.js");
|
|
5
|
+
const Agent_js_1 = require("../Agent.js");
|
|
6
|
+
const cn_js_1 = require("../vendors/cn.js");
|
|
7
|
+
const llm_js_1 = require("../vendors/llm.js");
|
|
8
|
+
const stt_js_1 = require("../vendors/stt.js");
|
|
9
|
+
const tts_js_1 = require("../vendors/tts.js");
|
|
10
|
+
const AGENT_PROMPT = "You are a concise, technically credible voice assistant. Keep replies short unless the user asks for detail.";
|
|
11
|
+
const GREETING = "Hi there! I am your Agora voice assistant. How can I help?";
|
|
12
|
+
const SUPPORT_PROMPT = "You are a concise support assistant.";
|
|
13
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
14
|
+
area: index_js_1.Area.US,
|
|
15
|
+
appId: "app-id",
|
|
16
|
+
appCertificate: "app-certificate",
|
|
17
|
+
});
|
|
18
|
+
new Agent_js_1.Agent({
|
|
19
|
+
client,
|
|
20
|
+
turnDetection: {
|
|
21
|
+
language: "en-US",
|
|
22
|
+
config: {
|
|
23
|
+
speech_threshold: 0.5,
|
|
24
|
+
start_of_speech: {
|
|
25
|
+
mode: "vad",
|
|
26
|
+
vad_config: {
|
|
27
|
+
interrupt_duration_ms: 160,
|
|
28
|
+
prefix_padding_ms: 300,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
end_of_speech: {
|
|
32
|
+
mode: "vad",
|
|
33
|
+
vad_config: {
|
|
34
|
+
silence_duration_ms: 480,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
advancedFeatures: {
|
|
40
|
+
enable_rtm: true,
|
|
41
|
+
enable_tools: true,
|
|
42
|
+
},
|
|
43
|
+
parameters: {
|
|
44
|
+
data_channel: "rtm",
|
|
45
|
+
enable_error_message: true,
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
.withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en" }))
|
|
49
|
+
.withLlm(new llm_js_1.OpenAI({
|
|
50
|
+
model: "gpt-4o-mini",
|
|
51
|
+
systemMessages: [{ role: "system", content: AGENT_PROMPT }],
|
|
52
|
+
greetingMessage: GREETING,
|
|
53
|
+
failureMessage: "Please wait a moment.",
|
|
54
|
+
maxHistory: 50,
|
|
55
|
+
params: {
|
|
56
|
+
max_tokens: 1024,
|
|
57
|
+
temperature: 0.7,
|
|
58
|
+
top_p: 0.95,
|
|
59
|
+
},
|
|
60
|
+
}))
|
|
61
|
+
.withTts(new tts_js_1.MiniMaxTTS({
|
|
62
|
+
model: "speech_2_6_turbo",
|
|
63
|
+
voiceId: "English_captivating_female1",
|
|
64
|
+
}))
|
|
65
|
+
.createSession({
|
|
66
|
+
name: `conversation-${Date.now()}`,
|
|
67
|
+
channel: `demo-channel-${Date.now()}`,
|
|
68
|
+
agentUid: "123456",
|
|
69
|
+
remoteUids: ["*"],
|
|
70
|
+
idleTimeout: 30,
|
|
71
|
+
});
|
|
72
|
+
{
|
|
73
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
74
|
+
area: index_js_1.Area.CN,
|
|
75
|
+
appId: "app-id",
|
|
76
|
+
appCertificate: "app-certificate",
|
|
77
|
+
});
|
|
78
|
+
new Agent_js_1.Agent({
|
|
79
|
+
client,
|
|
80
|
+
turnDetection: { language: "zh-CN" },
|
|
81
|
+
})
|
|
82
|
+
.withStt(new cn_js_1.FengmingSTT())
|
|
83
|
+
.withLlm(new cn_js_1.AliyunLLM({
|
|
84
|
+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
85
|
+
model: "qwen-plus",
|
|
86
|
+
}))
|
|
87
|
+
.withTts(new cn_js_1.MiniMaxCNTTS({
|
|
88
|
+
key: "minimax-key",
|
|
89
|
+
model: "speech-01-turbo",
|
|
90
|
+
voiceSetting: { voice_id: "female-shaonv" },
|
|
91
|
+
audioSetting: { sample_rate: 16000 },
|
|
92
|
+
}))
|
|
93
|
+
.createSession({
|
|
94
|
+
name: `conversation-${Date.now()}`,
|
|
95
|
+
channel: `demo-channel-${Date.now()}`,
|
|
96
|
+
agentUid: "1001",
|
|
97
|
+
remoteUids: ["100"],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
{
|
|
101
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
102
|
+
area: index_js_1.Area.US,
|
|
103
|
+
appId: "app-id",
|
|
104
|
+
appCertificate: "app-certificate",
|
|
105
|
+
});
|
|
106
|
+
new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
|
|
107
|
+
.withStt(new stt_js_1.DeepgramSTT({
|
|
108
|
+
apiKey: "deepgram-key",
|
|
109
|
+
model: "nova-3",
|
|
110
|
+
language: "en",
|
|
111
|
+
}))
|
|
112
|
+
.withLlm(new llm_js_1.OpenAI({
|
|
113
|
+
apiKey: "openai-key",
|
|
114
|
+
url: "https://api.openai.com/v1/chat/completions",
|
|
115
|
+
model: "gpt-4o-mini",
|
|
116
|
+
systemMessages: [{ role: "system", content: SUPPORT_PROMPT }],
|
|
117
|
+
greetingMessage: GREETING,
|
|
118
|
+
maxTokens: 1024,
|
|
119
|
+
temperature: 0.7,
|
|
120
|
+
topP: 0.95,
|
|
121
|
+
}))
|
|
122
|
+
.withTts(new tts_js_1.MiniMaxTTS({
|
|
123
|
+
model: "speech_2_6_turbo",
|
|
124
|
+
voiceId: "English_captivating_female1",
|
|
125
|
+
}));
|
|
126
|
+
}
|