Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for textual file attachments #34

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Conversation

miclegr
Copy link
Contributor

@miclegr miclegr commented Jan 1, 2025

This PR adds support for attaching textual files with mimetypes text/plain and text/csv.

(text/plain is explicitly supported as for docs, text/csv works as tested by me)

This PR adds support for attaching textual files with mimetypes `text/plain` and `text/csv`.

(`text/plain` is explicitly supported as for [docs](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#blob), `text/csv` works as tested by me)
@simonw
Copy link
Owner

simonw commented Jan 22, 2025

This works:

cat hello.txt 
Say hello in French
llm -m gemini-1.5-pro-latest -a hello.txt

Bonjour

@simonw
Copy link
Owner

simonw commented Jan 22, 2025

Tried it for CSV too, I had to use --at file.csv text/csv to get that to work:

% cat hello.csv 
id,name,description
1,Cleo,Dog
2,Suna,Chicken
% llm -m gemini-1.5-pro-latest -a hello.csv 'tell me about these creatures'
Usage: llm prompt [OPTIONS] [PROMPT]
Try 'llm prompt --help' for help.

Error: Invalid value for '-a' / '--attachment': Could not determine mimetype of hello.csv
% llm -m gemini-1.5-pro-latest --at hello.csv text/csv 'tell me about these creatures'
Here's a breakdown of the creatures you provided:

* **ID: 1**
    * **Name:** Cleo
    * **Description:** Dog.  This likely refers to a domesticated canine, *Canis familiaris*.  Dogs come in a wide variety of breeds, sizes, and temperaments. They are known for their loyalty, intelligence, and ability to be trained.

* **ID: 2**
    * **Name:** Suna
    * **Description:** Chicken. This likely refers to *Gallus gallus domesticus*, the domesticated subspecies of the red junglefowl. Chickens are primarily raised for their meat and eggs. They are social animals that live in flocks.

% git stash
Saved working directory and index state WIP on main: f659fa3 Add support for grounding using google_search (#29)
% llm -m gemini-1.5-pro-latest --at hello.csv text/csv 'tell me about these creatures'
Error: This model does not support attachments of type 'text/csv', only application/pdf, image/png, image/jpeg, image/webp, image/heic, image/heif, audio/wav, audio/mp3, audio/aiff, audio/aac, audio/ogg, application/ogg, audio/flac, audio/mpeg, video/mp4, video/mpeg, video/mov, video/avi, video/x-flv, video/mpg, video/webm, video/wmv, video/3gpp, video/quicktime

@simonw simonw merged commit de35a5f into simonw:main Jan 22, 2025
simonw added a commit that referenced this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants