livekit-plugins-google 1.0.0rc3__py3-none-any.whl → 1.0.0rc5__py3-none-any.whl

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.
@@ -5,13 +5,13 @@ from typing import Literal, Union
5
5
 
6
6
  from google.genai import types
7
7
 
8
- from ..._utils import _build_gemini_ctx, _build_tools
8
+ # from ..._utils import _build_gemini_ctx, _build_tools
9
9
 
10
10
  LiveAPIModels = Literal["gemini-2.0-flash-exp"]
11
11
 
12
12
  Voice = Literal["Puck", "Charon", "Kore", "Fenrir", "Aoede"]
13
13
 
14
- __all__ = ["_build_tools", "ClientEvents", "_build_gemini_ctx"]
14
+ # __all__ = ["_build_tools", "ClientEvents", "_build_gemini_ctx"]
15
15
 
16
16
  ClientEvents = Union[
17
17
  types.ContentListUnion,
@@ -27,7 +27,6 @@ from google.genai.types import (
27
27
  )
28
28
  from livekit import rtc
29
29
  from livekit.agents import llm, utils
30
- from livekit.agents.llm.function_context import _create_ai_function_info
31
30
  from livekit.agents.utils import images
32
31
 
33
32
  from ...log import logger
@@ -35,9 +34,10 @@ from .api_proto import (
35
34
  ClientEvents,
36
35
  LiveAPIModels,
37
36
  Voice,
38
- _build_gemini_ctx,
39
- _build_tools,
40
37
  )
38
+
39
+ # temporary placeholders
40
+ from .temp import _build_gemini_ctx, _build_tools, _create_ai_function_info
41
41
  from .transcriber import ModelTranscriber, TranscriberSession, TranscriptionContent
42
42
 
43
43
  EventTypes = Literal[
@@ -0,0 +1,10 @@
1
+ def _build_tools():
2
+ pass
3
+
4
+
5
+ def _create_ai_function_info():
6
+ pass
7
+
8
+
9
+ def _build_gemini_ctx():
10
+ pass
@@ -18,7 +18,7 @@ from __future__ import annotations
18
18
  import json
19
19
  import os
20
20
  from dataclasses import dataclass
21
- from typing import Any, Literal, cast
21
+ from typing import Any, cast
22
22
 
23
23
  from google import genai
24
24
  from google.auth._default_async import default_async
@@ -43,7 +43,7 @@ from .utils import to_chat_ctx, to_fnc_ctx
43
43
  class _LLMOptions:
44
44
  model: ChatModels | str
45
45
  temperature: NotGivenOr[float]
46
- tool_choice: NotGivenOr[ToolChoice | Literal["auto", "required", "none"]]
46
+ tool_choice: NotGivenOr[ToolChoice]
47
47
  vertexai: NotGivenOr[bool]
48
48
  project: NotGivenOr[str]
49
49
  location: NotGivenOr[str]
@@ -69,7 +69,7 @@ class LLM(llm.LLM):
69
69
  top_k: NotGivenOr[float] = NOT_GIVEN,
70
70
  presence_penalty: NotGivenOr[float] = NOT_GIVEN,
71
71
  frequency_penalty: NotGivenOr[float] = NOT_GIVEN,
72
- tool_choice: NotGivenOr[ToolChoice | Literal["auto", "required", "none"]] = NOT_GIVEN,
72
+ tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN,
73
73
  ) -> None:
74
74
  """
75
75
  Create a new instance of Google GenAI LLM.
@@ -93,7 +93,7 @@ class LLM(llm.LLM):
93
93
  top_k (int, optional): The top-k sampling value for response generation. Defaults to None.
94
94
  presence_penalty (float, optional): Penalizes the model for generating previously mentioned concepts. Defaults to None.
95
95
  frequency_penalty (float, optional): Penalizes the model for repeating words. Defaults to None.
96
- tool_choice (ToolChoice or Literal["auto", "required", "none"], optional): Specifies whether to use tools during response generation. Defaults to "auto".
96
+ tool_choice (ToolChoice, optional): Specifies whether to use tools during response generation. Defaults to "auto".
97
97
  """ # noqa: E501
98
98
  super().__init__()
99
99
  gcp_project = project if is_given(project) else os.environ.get("GOOGLE_CLOUD_PROJECT")
@@ -147,7 +147,7 @@ class LLM(llm.LLM):
147
147
  tools: list[FunctionTool] | None = None,
148
148
  conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
149
149
  parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN,
150
- tool_choice: NotGivenOr[ToolChoice | Literal["auto", "required", "none"]] = NOT_GIVEN,
150
+ tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN,
151
151
  extra_kwargs: NotGivenOr[dict[str, Any]] = NOT_GIVEN,
152
152
  ) -> LLMStream:
153
153
  extra = {}
@@ -158,7 +158,7 @@ class LLM(llm.LLM):
158
158
  tool_choice = tool_choice if is_given(tool_choice) else self._opts.tool_choice
159
159
  if is_given(tool_choice):
160
160
  gemini_tool_choice: types.ToolConfig
161
- if isinstance(tool_choice, ToolChoice):
161
+ if isinstance(tool_choice, dict) and tool_choice.get("type") == "function":
162
162
  gemini_tool_choice = types.ToolConfig(
163
163
  function_calling_config=types.FunctionCallingConfig(
164
164
  mode="ANY",
@@ -9,6 +9,8 @@ from google.genai import types
9
9
  from livekit.agents import llm
10
10
  from livekit.agents.llm import FunctionTool
11
11
 
12
+ from .log import logger
13
+
12
14
  __all__ = ["to_chat_ctx", "to_fnc_ctx"]
13
15
 
14
16
 
@@ -28,7 +30,7 @@ def to_chat_ctx(
28
30
  if msg.type == "message" and msg.role == "system":
29
31
  sys_parts = []
30
32
  for content in msg.content:
31
- if isinstance(content, str):
33
+ if content and isinstance(content, str):
32
34
  sys_parts.append(types.Part(text=content))
33
35
  system_instruction = types.Content(parts=sys_parts)
34
36
  continue
@@ -49,9 +51,9 @@ def to_chat_ctx(
49
51
 
50
52
  if msg.type == "message":
51
53
  for content in msg.content:
52
- if isinstance(content, str):
54
+ if content and isinstance(content, str):
53
55
  parts.append(types.Part(text=content))
54
- elif isinstance(content, dict):
56
+ elif content and isinstance(content, dict):
55
57
  parts.append(types.Part(text=json.dumps(content)))
56
58
  elif isinstance(content, llm.ImageContent):
57
59
  parts.append(_to_image_part(content, cache_key))
@@ -81,9 +83,16 @@ def to_chat_ctx(
81
83
 
82
84
  def _to_image_part(image: llm.ImageContent, cache_key: Any) -> types.Part:
83
85
  img = llm.utils.serialize_image(image)
86
+ if img.external_url:
87
+ if img.mime_type:
88
+ mime_type = img.mime_type
89
+ else:
90
+ logger.debug("No media type provided for image, defaulting to image/jpeg.")
91
+ mime_type = "image/jpeg"
92
+ return types.Part.from_uri(file_uri=img.external_url, mime_type=mime_type)
84
93
  if cache_key not in image._cache:
85
94
  image._cache[cache_key] = img.data_bytes
86
- return types.Part.from_bytes(data=image._cache[cache_key], mime_type=img.media_type)
95
+ return types.Part.from_bytes(data=image._cache[cache_key], mime_type=img.mime_type)
87
96
 
88
97
 
89
98
  def _build_gemini_fnc(function_tool: FunctionTool) -> types.FunctionDeclaration:
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = '1.0.0.rc3'
15
+ __version__ = '1.0.0.rc5'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-google
3
- Version: 1.0.0rc3
3
+ Version: 1.0.0rc5
4
4
  Summary: Agent Framework plugin for services from Google Cloud
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -22,7 +22,7 @@ Requires-Dist: google-auth<3,>=2
22
22
  Requires-Dist: google-cloud-speech<3,>=2
23
23
  Requires-Dist: google-cloud-texttospeech<3,>=2
24
24
  Requires-Dist: google-genai==1.5.0
25
- Requires-Dist: livekit-agents>=1.0.0.rc3
25
+ Requires-Dist: livekit-agents>=1.0.0.rc5
26
26
  Description-Content-Type: text/markdown
27
27
 
28
28
  # LiveKit Plugins Google
@@ -1,17 +1,18 @@
1
1
  livekit/plugins/google/__init__.py,sha256=e_kSlFNmKhyyeliz7f4WOKc_Y0-y39QjO5nCWuguhss,1171
2
- livekit/plugins/google/llm.py,sha256=oAi4EUitki2EUWIMEcnSVO4AB6EmZzi3vNiDG2mdVvU,14377
2
+ livekit/plugins/google/llm.py,sha256=1yy6DaPxcO5EUN3JORpZ-q5ygdPWWmq6P3x73EbAqK4,14251
3
3
  livekit/plugins/google/log.py,sha256=GI3YWN5YzrafnUccljzPRS_ZALkMNk1i21IRnTl2vNA,69
4
4
  livekit/plugins/google/models.py,sha256=SGjAumdDK97NNLwMFcqZdKR68f1NoGB2Rk1UP2-imG0,1457
5
5
  livekit/plugins/google/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  livekit/plugins/google/stt.py,sha256=fT5JtDM8ck2iMAzRvFKVeyT1oPt_R-bDkqiLa-ysikc,22539
7
7
  livekit/plugins/google/tts.py,sha256=mYm9n4zDzmNEAF3bSOb4-603CJrrdv9YJhrfbp5_k5A,7455
8
- livekit/plugins/google/utils.py,sha256=SfuQLJSXSV708VMn5_TVB93ginUCX2izqT9r2seraSQ,8040
9
- livekit/plugins/google/version.py,sha256=wYcaYw0AmH9qt8_atfIwl-Qo0WMWL73z2vqRF8LOjms,604
8
+ livekit/plugins/google/utils.py,sha256=Ezh8eX6ld_11achNzUQqT4Owe1mKgOfBTl5IInt4Fm4,8411
9
+ livekit/plugins/google/version.py,sha256=G8-S67mIdz56XcVImzUB7osx6o_lG2oShZz-PjWeOeo,604
10
10
  livekit/plugins/google/beta/__init__.py,sha256=AxRYc7NGG62Tv1MmcZVCDHNvlhbC86hM-_yP01Qb28k,47
11
11
  livekit/plugins/google/beta/realtime/__init__.py,sha256=_fW2NMN22F-hnQ4xAJ_g5lPbR7CvM_xXzSWlUQY-E-U,188
12
- livekit/plugins/google/beta/realtime/api_proto.py,sha256=zrAR9aZ3wFpEiIoSi_8xiP6i8k5diPSl-r298imUyf4,684
13
- livekit/plugins/google/beta/realtime/realtime_api.py,sha256=b7shOYZ86b38zxZCJkgzLQQeWESYo3VUZU1-7rNDAmw,22588
12
+ livekit/plugins/google/beta/realtime/api_proto.py,sha256=VO6QqOGOrxzsaOLBqnwNd8c-BId0PjwKicdrPTJisy0,688
13
+ livekit/plugins/google/beta/realtime/realtime_api.py,sha256=ERM6WvcTtrfIyKpukzoSYrkhd3eYxIY-I09mKWp8vLk,22576
14
+ livekit/plugins/google/beta/realtime/temp.py,sha256=an_YueuS_tUw3_QC6xWkkcw5JrJOBQFv2pJh6atpNcc,108
14
15
  livekit/plugins/google/beta/realtime/transcriber.py,sha256=DD7q894xc25GeeuKDar6-GwH-MxStEwhwBiX-KZ-Jo4,9559
15
- livekit_plugins_google-1.0.0rc3.dist-info/METADATA,sha256=rUCv5Xc0YzqUtGPrtI8VOXjJWc0b618Teri1xqE4iZM,3496
16
- livekit_plugins_google-1.0.0rc3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- livekit_plugins_google-1.0.0rc3.dist-info/RECORD,,
16
+ livekit_plugins_google-1.0.0rc5.dist-info/METADATA,sha256=xBEeCvL5uEOhATjWMS0nneUDQDUeGn8Lk8DqbzOz8k4,3496
17
+ livekit_plugins_google-1.0.0rc5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ livekit_plugins_google-1.0.0rc5.dist-info/RECORD,,