livekit-plugins-volcengine 1.2.8__tar.gz → 1.2.9__tar.gz

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.
Files changed (15) hide show
  1. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/PKG-INFO +3 -3
  2. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/realtime.py +75 -8
  3. livekit_plugins_volcengine-1.2.9/livekit/plugins/volcengine/version.py +1 -0
  4. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/pyproject.toml +2 -2
  5. livekit_plugins_volcengine-1.2.8/livekit/plugins/volcengine/version.py +0 -1
  6. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/.gitignore +0 -0
  7. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/README.md +0 -0
  8. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/__init__.py +0 -0
  9. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/bigmodel_stt.py +0 -0
  10. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/llm.py +0 -0
  11. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/log.py +0 -0
  12. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/py.typed +0 -0
  13. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/stt.py +0 -0
  14. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/tts.py +0 -0
  15. {livekit_plugins_volcengine-1.2.8 → livekit_plugins_volcengine-1.2.9}/livekit/plugins/volcengine/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-volcengine
3
- Version: 1.2.8
3
+ Version: 1.2.9
4
4
  Summary: LiveKit Agent Plugins for Volcengine
5
5
  Author-email: wangmengdi <790990241@qq.com>
6
6
  Keywords: audio,livekit,realtime,video,webrtc
@@ -14,10 +14,10 @@ Classifier: Topic :: Multimedia :: Sound/Audio
14
14
  Classifier: Topic :: Multimedia :: Video
15
15
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
16
  Requires-Python: >=3.9
17
- Requires-Dist: livekit-agents>=1.2.8
17
+ Requires-Dist: livekit-agents>=1.2.9
18
18
  Requires-Dist: numpy
19
19
  Requires-Dist: openai>=1.75.0
20
- Requires-Dist: osc-data>=0.2.2
20
+ Requires-Dist: osc-data==0.2.2
21
21
  Requires-Dist: pydantic
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -11,7 +11,7 @@ import gzip
11
11
  import uuid
12
12
  from collections.abc import Iterator
13
13
  from dataclasses import dataclass
14
- from typing import Literal
14
+ from typing import Literal, Callable
15
15
 
16
16
  import aiohttp
17
17
  import numpy as np
@@ -176,6 +176,13 @@ class _RealtimeOptions:
176
176
  sample_rate: int = 24000
177
177
  num_channels: int = 1
178
178
  format: str = "pcm"
179
+ model: Literal["O", "SC"] = "O"
180
+ character_manifest: str = None
181
+ end_smooth_window_ms: int = 500
182
+ enable_volc_websearch: bool = False
183
+ volc_websearch_type: Literal["web_summary", "web"] = "web_summary"
184
+ volc_websearch_api_key: str = None
185
+ volc_websearch_no_result_message: str = "抱歉,我找不到相关信息。"
179
186
 
180
187
  @property
181
188
  def ws_url(self) -> str:
@@ -193,6 +200,11 @@ class _RealtimeOptions:
193
200
 
194
201
  def get_start_session_reqs(self, dialog_id: str | None) -> dict:
195
202
  start_session_req = {
203
+ "asr": {
204
+ "extra": {
205
+ "end_smooth_window_ms": self.end_smooth_window_ms,
206
+ }
207
+ },
196
208
  "tts": {
197
209
  "audio_config": {
198
210
  "channel": self.num_channels,
@@ -206,7 +218,15 @@ class _RealtimeOptions:
206
218
  "system_role": self.system_role,
207
219
  "dialog_id": dialog_id or str(utils.shortuuid()),
208
220
  "speaking_style": self.speaking_style,
209
- "extra": {"strict_audit": False},
221
+ "character_manifest": self.character_manifest,
222
+ "extra": {
223
+ "strict_audit": False,
224
+ "enable_volc_websearch": self.enable_volc_websearch,
225
+ "volc_websearch_type": self.volc_websearch_type,
226
+ "volc_websearch_api_key": self.volc_websearch_api_key,
227
+ "volc_websearch_no_result_message": self.volc_websearch_no_result_message,
228
+ "model": self.model,
229
+ },
210
230
  },
211
231
  }
212
232
  return start_session_req
@@ -245,6 +265,14 @@ class RealtimeModel(llm.RealtimeModel):
245
265
  app_id: str | None = None,
246
266
  access_token: str | None = None,
247
267
  system_role: str | None = None,
268
+ character_manifest: str = None,
269
+ model: Literal["O", "SC"] = "O",
270
+ end_smooth_window_ms: int = 500,
271
+ enable_volc_websearch: bool = False,
272
+ volc_websearch_type: Literal["web_summary", "web"] = "web_summary",
273
+ volc_websearch_api_key: str = None,
274
+ volc_websearch_no_result_message: str = "抱歉,我找不到相关信息。",
275
+ rag_fn: Callable[[str], str] = None,
248
276
  audio_output: bool = True,
249
277
  modalities: NotGivenOr[list[Literal["text", "audio"]]] = NOT_GIVEN,
250
278
  http_session: aiohttp.ClientSession | None = None,
@@ -259,9 +287,18 @@ class RealtimeModel(llm.RealtimeModel):
259
287
  user_transcription=True,
260
288
  auto_tool_reply_generation=False,
261
289
  audio_output=("audio" in modalities),
290
+ manual_function_calls=True
262
291
  )
263
292
  )
264
-
293
+ logger.info(f"Model: {model}")
294
+ logger.info(f"Character Manifest: {character_manifest}")
295
+ logger.info(f"End Smooth Window MS: {end_smooth_window_ms}")
296
+ logger.info(f"Enable Volc Websearch: {enable_volc_websearch}")
297
+ logger.info(f"Volc Websearch Type: {volc_websearch_type}")
298
+ logger.info(f"Volc Websearch API Key: {volc_websearch_api_key}")
299
+ logger.info(
300
+ f"Volc Websearch No Result Message: {volc_websearch_no_result_message}"
301
+ )
265
302
  app_id = app_id or os.environ.get("VOLCENGINE_REALTIME_APP_ID")
266
303
  if app_id is None:
267
304
  raise ValueError("VOLCENGINE_REALTIME_APP_ID is required")
@@ -273,15 +310,23 @@ class RealtimeModel(llm.RealtimeModel):
273
310
  self._opts = _RealtimeOptions(
274
311
  app_id=app_id,
275
312
  access_token=access_token,
276
- max_session_duration=max_session_duration,
277
- conn_options=conn_options,
278
313
  bot_name=bot_name,
279
314
  system_role=system_role,
280
315
  speaker=speaker,
281
316
  opening=opening,
282
317
  speaking_style=speaking_style,
318
+ character_manifest=character_manifest,
319
+ model=model,
320
+ end_smooth_window_ms=end_smooth_window_ms,
321
+ enable_volc_websearch=enable_volc_websearch,
322
+ volc_websearch_type=volc_websearch_type,
323
+ volc_websearch_api_key=volc_websearch_api_key,
324
+ volc_websearch_no_result_message=volc_websearch_no_result_message,
283
325
  modalities=modalities,
326
+ max_session_duration=max_session_duration,
327
+ conn_options=conn_options,
284
328
  )
329
+ self._rag_fn = rag_fn
285
330
  self._http_session = http_session
286
331
  self._sessions = weakref.WeakSet[RealtimeSession]()
287
332
 
@@ -441,7 +486,9 @@ class RealtimeSession(
441
486
  )
442
487
  self.emit("generation_created", generation_ev)
443
488
  item_id = utils.shortuuid()
444
- modalities_fut: asyncio.Future[list[Literal["text", "audio"]]] = asyncio.Future()
489
+ modalities_fut: asyncio.Future[list[Literal["text", "audio"]]] = (
490
+ asyncio.Future()
491
+ )
445
492
  self._current_item = _MessageGeneration(
446
493
  message_id=item_id,
447
494
  text_ch=utils.aio.Chan(),
@@ -536,7 +583,9 @@ class RealtimeSession(
536
583
 
537
584
  self.emit("generation_created", generation_ev)
538
585
  item_id = utils.shortuuid()
539
- modalities_fut: asyncio.Future[list[Literal["text", "audio"]]] = asyncio.Future()
586
+ modalities_fut: asyncio.Future[
587
+ list[Literal["text", "audio"]]
588
+ ] = asyncio.Future()
540
589
  self._current_item = _MessageGeneration(
541
590
  message_id=item_id,
542
591
  text_ch=utils.aio.Chan(),
@@ -547,7 +596,9 @@ class RealtimeSession(
547
596
  self._current_item.audio_ch.close()
548
597
  self._current_item.modalities.set_result(["text"]) # type: ignore[union-attr]
549
598
  else:
550
- self._current_item.modalities.set_result(["audio", "text"]) # type: ignore[union-attr]
599
+ self._current_item.modalities.set_result(
600
+ ["audio", "text"]
601
+ ) # type: ignore[union-attr]
551
602
  self._current_generation.message_ch.send_nowait(
552
603
  llm.MessageGeneration(
553
604
  message_id=item_id,
@@ -565,6 +616,22 @@ class RealtimeSession(
565
616
  user_transcription_enabled=False
566
617
  ),
567
618
  )
619
+ if self._realtime_model._rag_fn is not None:
620
+ logger.info("rag start")
621
+ rag_result = self._realtime_model._rag_fn(transcription)
622
+ payload = {
623
+ "external_rag": rag_result,
624
+ }
625
+ payload_bytes = str.encode(json.dumps(payload))
626
+ payload_bytes = gzip.compress(payload_bytes)
627
+ chat_rag_text_request = bytearray(generate_header())
628
+ chat_rag_text_request.extend(int(502).to_bytes(4, "big"))
629
+ chat_rag_text_request.extend((len(self.session_id)).to_bytes(4, "big"))
630
+ chat_rag_text_request.extend(str.encode(self.session_id))
631
+ chat_rag_text_request.extend((len(payload_bytes)).to_bytes(4, "big"))
632
+ chat_rag_text_request.extend(payload_bytes)
633
+ await ws_conn.send_bytes(chat_rag_text_request)
634
+ logger.info("rag end")
568
635
  logger.info("llm start")
569
636
  logger.info("tts start")
570
637
 
@@ -0,0 +1 @@
1
+ __version__ = "1.2.9"
@@ -10,10 +10,10 @@ keywords = ["webrtc", "realtime", "audio", "video", "livekit"]
10
10
  requires-python = ">=3.9"
11
11
  dependencies = [
12
12
  "openai>=1.75.0",
13
- "osc-data>=0.2.2",
13
+ "osc-data==0.2.2",
14
14
  "pydantic",
15
15
  "numpy",
16
- "livekit-agents>=1.2.8",
16
+ "livekit-agents>=1.2.9",
17
17
  ]
18
18
 
19
19
  classifiers = [
@@ -1 +0,0 @@
1
- __version__ = "1.2.8"