llm-gemini 0.1a0__tar.gz → 0.1a1__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.
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/PKG-INFO +4 -2
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/README.md +3 -1
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/PKG-INFO +4 -2
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.py +12 -6
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/pyproject.toml +1 -1
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/LICENSE +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/SOURCES.txt +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/dependency_links.txt +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/entry_points.txt +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/requires.txt +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/llm_gemini.egg-info/top_level.txt +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/setup.cfg +0 -0
- {llm-gemini-0.1a0 → llm-gemini-0.1a1}/tests/test_gemini.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1a1
|
4
4
|
Summary: LLM plugin to access Google's Gemini family of models
|
5
5
|
Author: Simon Willison
|
6
6
|
License: Apache-2.0
|
@@ -34,7 +34,7 @@ llm install llm-gemini
|
|
34
34
|
```
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
Configure the model by setting a key called "gemini" to your API key:
|
37
|
+
Configure the model by setting a key called "gemini" to your [API key](https://ai.google.dev/):
|
38
38
|
|
39
39
|
```bash
|
40
40
|
llm keys set gemini
|
@@ -59,6 +59,8 @@ To chat interactively with the model, run `llm chat`:
|
|
59
59
|
llm chat -m gemini-pro
|
60
60
|
```
|
61
61
|
|
62
|
+
If you have access to the Gemini 1.5 Pro preview you can use `-m gemini-1.5-pro-latest` to work with that model.
|
63
|
+
|
62
64
|
## Development
|
63
65
|
|
64
66
|
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
|
@@ -15,7 +15,7 @@ llm install llm-gemini
|
|
15
15
|
```
|
16
16
|
## Usage
|
17
17
|
|
18
|
-
Configure the model by setting a key called "gemini" to your API key:
|
18
|
+
Configure the model by setting a key called "gemini" to your [API key](https://ai.google.dev/):
|
19
19
|
|
20
20
|
```bash
|
21
21
|
llm keys set gemini
|
@@ -40,6 +40,8 @@ To chat interactively with the model, run `llm chat`:
|
|
40
40
|
llm chat -m gemini-pro
|
41
41
|
```
|
42
42
|
|
43
|
+
If you have access to the Gemini 1.5 Pro preview you can use `-m gemini-1.5-pro-latest` to work with that model.
|
44
|
+
|
43
45
|
## Development
|
44
46
|
|
45
47
|
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: llm-gemini
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1a1
|
4
4
|
Summary: LLM plugin to access Google's Gemini family of models
|
5
5
|
Author: Simon Willison
|
6
6
|
License: Apache-2.0
|
@@ -34,7 +34,7 @@ llm install llm-gemini
|
|
34
34
|
```
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
Configure the model by setting a key called "gemini" to your API key:
|
37
|
+
Configure the model by setting a key called "gemini" to your [API key](https://ai.google.dev/):
|
38
38
|
|
39
39
|
```bash
|
40
40
|
llm keys set gemini
|
@@ -59,6 +59,8 @@ To chat interactively with the model, run `llm chat`:
|
|
59
59
|
llm chat -m gemini-pro
|
60
60
|
```
|
61
61
|
|
62
|
+
If you have access to the Gemini 1.5 Pro preview you can use `-m gemini-1.5-pro-latest` to work with that model.
|
63
|
+
|
62
64
|
## Development
|
63
65
|
|
64
66
|
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
|
@@ -26,28 +26,34 @@ SAFETY_SETTINGS = [
|
|
26
26
|
|
27
27
|
@llm.hookimpl
|
28
28
|
def register_models(register):
|
29
|
-
register(GeminiPro())
|
29
|
+
register(GeminiPro("gemini-pro"))
|
30
|
+
register(GeminiPro("gemini-1.5-pro-latest"))
|
30
31
|
|
31
32
|
|
32
33
|
class GeminiPro(llm.Model):
|
33
|
-
model_id = "gemini-pro"
|
34
34
|
can_stream = True
|
35
35
|
|
36
|
+
def __init__(self, model_id):
|
37
|
+
self.model_id = model_id
|
38
|
+
|
36
39
|
def build_messages(self, prompt, conversation):
|
37
40
|
if not conversation:
|
38
41
|
return [{"role": "user", "parts": [{"text": prompt.prompt}]}]
|
39
42
|
messages = []
|
40
43
|
for response in conversation.responses:
|
41
|
-
messages.append(
|
44
|
+
messages.append(
|
45
|
+
{"role": "user", "parts": [{"text": response.prompt.prompt}]}
|
46
|
+
)
|
42
47
|
messages.append({"role": "model", "parts": [{"text": response.text()}]})
|
43
48
|
messages.append({"role": "user", "parts": [{"text": prompt.prompt}]})
|
44
49
|
return messages
|
45
50
|
|
46
51
|
def execute(self, prompt, stream, response, conversation):
|
47
52
|
key = llm.get_key("", "gemini", "LLM_GEMINI_KEY")
|
48
|
-
url = (
|
49
|
-
|
50
|
-
|
53
|
+
url = "https://generativelanguage.googleapis.com/v1beta/models/{}:streamGenerateContent?".format(
|
54
|
+
self.model_id
|
55
|
+
) + urllib.parse.urlencode(
|
56
|
+
{"key": key}
|
51
57
|
)
|
52
58
|
gathered = []
|
53
59
|
with httpx.stream(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|