llm-gemini 0.14__py3-none-any.whl → 0.15__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: llm-gemini
3
- Version: 0.14
3
+ Version: 0.15
4
4
  Summary: LLM plugin to access Google's Gemini family of models
5
5
  Author: Simon Willison
6
6
  License: Apache-2.0
@@ -72,6 +72,7 @@ Other models are:
72
72
  - `gemini-2.0-flash` - Gemini 2.0 Flash
73
73
  - `gemini-2.0-flash-lite` - Gemini 2.0 Flash-Lite
74
74
  - `gemini-2.0-pro-exp-02-05` - experimental release of Gemini 2.0 Pro
75
+ - `gemma-3-27b-it` - [Gemma 3](https://blog.google/technology/developers/gemma-3/) 27B
75
76
 
76
77
  ### Images, audio and video
77
78
 
@@ -0,0 +1,7 @@
1
+ llm_gemini.py,sha256=DdgyLfTuDS5RNt2iaFX9UZnDGUHezObGj-TkyWLJirw,15938
2
+ llm_gemini-0.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
+ llm_gemini-0.15.dist-info/METADATA,sha256=8qhtAEFniW5fn-6Qz1zFFrjaZwqqD_kNXJNheU8SG_M,7643
4
+ llm_gemini-0.15.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
5
+ llm_gemini-0.15.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
6
+ llm_gemini-0.15.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
7
+ llm_gemini-0.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
llm_gemini.py CHANGED
@@ -1,6 +1,8 @@
1
+ import click
1
2
  import copy
2
3
  import httpx
3
4
  import ijson
5
+ import json
4
6
  import llm
5
7
  from pydantic import Field
6
8
  from typing import Optional
@@ -62,6 +64,8 @@ def register_models(register):
62
64
  "gemini-2.0-pro-exp-02-05",
63
65
  # Released 25th Feb 2025:
64
66
  "gemini-2.0-flash-lite",
67
+ # Released 12th March 2025:
68
+ "gemma-3-27b-it",
65
69
  ]:
66
70
  can_google_search = model_id in GOOGLE_SEARCH_MODELS
67
71
  register(
@@ -88,18 +92,24 @@ def resolve_type(attachment):
88
92
  return mime_type
89
93
 
90
94
 
91
- def cleanup_schema(schema):
95
+ def cleanup_schema(schema, in_properties=False):
92
96
  "Gemini supports only a subset of JSON schema"
93
97
  keys_to_remove = ("$schema", "additionalProperties", "title")
94
- # Recursively remove them
98
+
95
99
  if isinstance(schema, dict):
96
- for key in keys_to_remove:
97
- schema.pop(key, None)
98
- for value in schema.values():
99
- cleanup_schema(value)
100
+ # Only remove keys if we're not inside a 'properties' block.
101
+ if not in_properties:
102
+ for key in keys_to_remove:
103
+ schema.pop(key, None)
104
+ for key, value in list(schema.items()):
105
+ # If the key is 'properties', set the flag for its value.
106
+ if key == "properties" and isinstance(value, dict):
107
+ cleanup_schema(value, in_properties=True)
108
+ else:
109
+ cleanup_schema(value, in_properties=in_properties)
100
110
  elif isinstance(schema, list):
101
- for value in schema:
102
- cleanup_schema(value)
111
+ for item in schema:
112
+ cleanup_schema(item, in_properties=in_properties)
103
113
  return schema
104
114
 
105
115
 
@@ -431,3 +441,21 @@ class GeminiEmbeddingModel(llm.EmbeddingModel):
431
441
  if self.truncate:
432
442
  values = [value[: self.truncate] for value in values]
433
443
  return values
444
+
445
+
446
+ @llm.hookimpl
447
+ def register_commands(cli):
448
+ @cli.group()
449
+ def gemini():
450
+ "Commands relating to the llm-gemini plugin"
451
+
452
+ @gemini.command()
453
+ @click.option("--key", help="API key to use")
454
+ def models(key):
455
+ "List of Gemini models pulled from their API"
456
+ key = llm.get_key(key, "gemini", "LLM_GEMINI_KEY")
457
+ response = httpx.get(
458
+ f"https://generativelanguage.googleapis.com/v1beta/models?key={key}",
459
+ )
460
+ response.raise_for_status()
461
+ click.echo(json.dumps(response.json(), indent=2))
@@ -1,7 +0,0 @@
1
- llm_gemini.py,sha256=KgiKMPY6q-GkAMzH0gfQWp0cjBBKizNhlnZ3nX5pXWY,14917
2
- llm_gemini-0.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
3
- llm_gemini-0.14.dist-info/METADATA,sha256=J8oA7hZmNrFsRyH3_s4oesSjWNEaK8pWcT2p-_quPTA,7556
4
- llm_gemini-0.14.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
5
- llm_gemini-0.14.dist-info/entry_points.txt,sha256=n544bpgUPIBc5l_cnwsTxPc3gMGJHPtAyqBNp-CkMWk,26
6
- llm_gemini-0.14.dist-info/top_level.txt,sha256=WUQmG6_2QKbT_8W4HH93qyKl_0SUteL4Ra6_PhyNGKU,11
7
- llm_gemini-0.14.dist-info/RECORD,,