Name | llm-gemini JSON |
Version |
0.3
JSON |
| download |
home_page | None |
Summary | LLM plugin to access Google's Gemini family of models |
upload_time | 2024-10-29 04:13:53 |
maintainer | None |
docs_url | None |
author | Simon Willison |
requires_python | None |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# llm-gemini
[![PyPI](https://img.shields.io/pypi/v/llm-gemini.svg)](https://pypi.org/project/llm-gemini/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm-gemini?include_prereleases&label=changelog)](https://github.com/simonw/llm-gemini/releases)
[![Tests](https://github.com/simonw/llm-gemini/workflows/Test/badge.svg)](https://github.com/simonw/llm-gemini/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-gemini/blob/main/LICENSE)
API access to Google's Gemini models
## Installation
Install this plugin in the same environment as [LLM](https://llm.datasette.io/).
```bash
llm install llm-gemini
```
## Usage
Configure the model by setting a key called "gemini" to your [API key](https://aistudio.google.com/app/apikey):
```bash
llm keys set gemini
```
```
<paste key here>
```
Now run the model using `-m gemini-1.5-pro-latest`, for example:
```bash
llm -m gemini-1.5-pro-latest "A joke about a pelican and a walrus"
```
> A pelican walks into a seafood restaurant with a huge fish hanging out of its beak. The walrus, sitting at the bar, eyes it enviously.
>
> "Hey," the walrus says, "That looks delicious! What kind of fish is that?"
>
> The pelican taps its beak thoughtfully. "I believe," it says, "it's a billfish."
### Images, audio and video
Gemini models are multi-modal. You can provide images, audio or video files as input like this:
```bash
llm -m gemini-1.5-flash-latest 'extract text' -a image.jpg
```
Or with a URL:
```bash
llm -m gemini-1.5-flash-8b-latest 'describe image' \
-a https://static.simonwillison.net/static/2024/pelicans.jpg
```
Audio works too:
```bash
llm -m gemini-1.5-pro-latest 'transcribe audio' -a audio.mp3
```
And video:
```bash
llm -m gemini-1.5-pro-latest 'describe what happens' -a video.mp4
```
## Code execution
Gemini models can [write and execute code](https://ai.google.dev/gemini-api/docs/code-execution) - they can decide to write Python code, execute it in a secure sandbox and use the result as part of their response.
To enable this feature, use `-o code_execution 1`:
```bash
llm -m gemini-1.5-pro-latest -o code_execution 1 \
'use python to calculate (factorial of 13) * 3'
```
### Chat
To chat interactively with the model, run `llm chat`:
```bash
llm chat -m gemini-1.5-pro-latest
```
Other models are:
- `gemini-1.5-flash-latest`
- gemini-1.5-flash-8b-latest` - the least expensive
### Embeddings
The plugin also adds support for the `text-embedding-004` embedding model.
Run that against a single string like this:
```bash
llm embed -m text-embedding-004 -c 'hello world'
```
This returns a JSON array of 768 numbers.
This command will embed every `README.md` file in child directories of the current directory and store the results in a SQLite database called `embed.db` in a collection called `readmes`:
```bash
llm embed-multi readmes --files . '*/README.md' -d embed.db -m text-embedding-004
```
You can then run similarity searches against that collection like this:
```bash
llm similar readmes -c 'upload csvs to stuff' -d embed.db
```
See the [LLM embeddings documentation](https://llm.datasette.io/en/stable/embeddings/cli.html) for further details.
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd llm-gemini
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
llm install -e '.[test]'
```
To run the tests:
```bash
pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "llm-gemini",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Simon Willison",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/5b/d8/5ba3f9fd6228ab91a96308c6da62414357c9944ed6fa1576975d5c41df66/llm_gemini-0.3.tar.gz",
"platform": null,
"description": "# llm-gemini\n\n[![PyPI](https://img.shields.io/pypi/v/llm-gemini.svg)](https://pypi.org/project/llm-gemini/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/llm-gemini?include_prereleases&label=changelog)](https://github.com/simonw/llm-gemini/releases)\n[![Tests](https://github.com/simonw/llm-gemini/workflows/Test/badge.svg)](https://github.com/simonw/llm-gemini/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-gemini/blob/main/LICENSE)\n\nAPI access to Google's Gemini models\n\n## Installation\n\nInstall this plugin in the same environment as [LLM](https://llm.datasette.io/).\n```bash\nllm install llm-gemini\n```\n## Usage\n\nConfigure the model by setting a key called \"gemini\" to your [API key](https://aistudio.google.com/app/apikey):\n\n```bash\nllm keys set gemini\n```\n```\n<paste key here>\n```\n\nNow run the model using `-m gemini-1.5-pro-latest`, for example:\n\n```bash\nllm -m gemini-1.5-pro-latest \"A joke about a pelican and a walrus\"\n```\n\n> A pelican walks into a seafood restaurant with a huge fish hanging out of its beak. The walrus, sitting at the bar, eyes it enviously.\n>\n> \"Hey,\" the walrus says, \"That looks delicious! What kind of fish is that?\"\n>\n> The pelican taps its beak thoughtfully. \"I believe,\" it says, \"it's a billfish.\"\n\n### Images, audio and video\n\nGemini models are multi-modal. You can provide images, audio or video files as input like this:\n\n```bash\nllm -m gemini-1.5-flash-latest 'extract text' -a image.jpg\n```\nOr with a URL:\n```bash\nllm -m gemini-1.5-flash-8b-latest 'describe image' \\\n -a https://static.simonwillison.net/static/2024/pelicans.jpg\n```\nAudio works too:\n\n```bash\nllm -m gemini-1.5-pro-latest 'transcribe audio' -a audio.mp3\n```\n\nAnd video:\n\n```bash\nllm -m gemini-1.5-pro-latest 'describe what happens' -a video.mp4\n```\n\n## Code execution\n\nGemini models can [write and execute code](https://ai.google.dev/gemini-api/docs/code-execution) - they can decide to write Python code, execute it in a secure sandbox and use the result as part of their response.\n\nTo enable this feature, use `-o code_execution 1`:\n\n```bash\nllm -m gemini-1.5-pro-latest -o code_execution 1 \\\n'use python to calculate (factorial of 13) * 3'\n```\n\n### Chat\n\nTo chat interactively with the model, run `llm chat`:\n\n```bash\nllm chat -m gemini-1.5-pro-latest\n```\n\nOther models are:\n\n- `gemini-1.5-flash-latest`\n- gemini-1.5-flash-8b-latest` - the least expensive\n\n\n### Embeddings\n\nThe plugin also adds support for the `text-embedding-004` embedding model.\n\nRun that against a single string like this:\n```bash\nllm embed -m text-embedding-004 -c 'hello world'\n```\nThis returns a JSON array of 768 numbers.\n\nThis command will embed every `README.md` file in child directories of the current directory and store the results in a SQLite database called `embed.db` in a collection called `readmes`:\n\n```bash\nllm embed-multi readmes --files . '*/README.md' -d embed.db -m text-embedding-004\n```\nYou can then run similarity searches against that collection like this:\n```bash\nllm similar readmes -c 'upload csvs to stuff' -d embed.db\n```\n\nSee the [LLM embeddings documentation](https://llm.datasette.io/en/stable/embeddings/cli.html) for further details.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd llm-gemini\npython3 -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\nllm install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "LLM plugin to access Google's Gemini family of models",
"version": "0.3",
"project_urls": {
"CI": "https://github.com/simonw/llm-gemini/actions",
"Changelog": "https://github.com/simonw/llm-gemini/releases",
"Homepage": "https://github.com/simonw/llm-gemini",
"Issues": "https://github.com/simonw/llm-gemini/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "65807b14867041437955add9ce530be4a6bd955502a411c63e8dd87640fd5d88",
"md5": "3dc757ec10b10077eeeaf865a5bfd4a4",
"sha256": "b795c7c809790f2b1f5337398b89c2bb81576e0f6f6dc48049f63444f64f7757"
},
"downloads": -1,
"filename": "llm_gemini-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3dc757ec10b10077eeeaf865a5bfd4a4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9737,
"upload_time": "2024-10-29T04:13:52",
"upload_time_iso_8601": "2024-10-29T04:13:52.454585Z",
"url": "https://files.pythonhosted.org/packages/65/80/7b14867041437955add9ce530be4a6bd955502a411c63e8dd87640fd5d88/llm_gemini-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5bd85ba3f9fd6228ab91a96308c6da62414357c9944ed6fa1576975d5c41df66",
"md5": "7503f83d4ae62e0fed0a14aca21de243",
"sha256": "5e9fbe25910c61a3ea0434d94f2d07123f7f76468231f6e8a7b8ca17c855e37f"
},
"downloads": -1,
"filename": "llm_gemini-0.3.tar.gz",
"has_sig": false,
"md5_digest": "7503f83d4ae62e0fed0a14aca21de243",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9442,
"upload_time": "2024-10-29T04:13:53",
"upload_time_iso_8601": "2024-10-29T04:13:53.714665Z",
"url": "https://files.pythonhosted.org/packages/5b/d8/5ba3f9fd6228ab91a96308c6da62414357c9944ed6fa1576975d5c41df66/llm_gemini-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-29 04:13:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "llm-gemini",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "llm-gemini"
}