{"id":22118354,"url":"https://github.com/ghchinoy/gen","last_synced_at":"2025-07-29T03:08:27.122Z","repository":{"id":230473111,"uuid":"779477816","full_name":"ghchinoy/gen","owner":"ghchinoy","description":"generative AI from the command-line","archived":false,"fork":false,"pushed_at":"2025-06-19T03:12:51.000Z","size":573,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-25T17:04:42.758Z","etag":null,"topics":["gemini","generative-ai","google-cloud"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghchinoy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-29T23:40:20.000Z","updated_at":"2025-06-19T03:12:54.000Z","dependencies_parsed_at":"2024-06-19T21:14:05.549Z","dependency_job_id":"12b31a0d-0f41-42a8-8ff1-963bef69bf24","html_url":"https://github.com/ghchinoy/gen","commit_stats":null,"previous_names":["ghchinoy/generate"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ghchinoy/gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghchinoy%2Fgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghchinoy%2Fgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghchinoy%2Fgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghchinoy%2Fgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghchinoy","download_url":"https://codeload.github.com/ghchinoy/gen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghchinoy%2Fgen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267621599,"owners_count":24116900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gemini","generative-ai","google-cloud"],"created_at":"2024-12-01T13:49:22.697Z","updated_at":"2025-07-29T03:08:27.084Z","avatar_url":"https://github.com/ghchinoy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gen\n\n`gen` is a command-line tool that interacts with Google Cloud models - foundation models Gemini, PaLM, and models found on Model Garden such as Claude and others.\n\n\n![](./media/gen-002.gif)\n\n## Usage\n\n```bash\ngen prompt \"say something nice to me\"\n```\n\nTo get the list of commands, use `gen help`.\n\nHelp is also available for each command, such as `gen help tokens`.\n\n### Setup \n\n#### Installing\n\nInstall `gen` on your machine via:\n\n```\ngo install github.com/ghchinoy/gen@latest\n```\n\nCheck `gen version` once installed to make sure you have the latest release.\n\nIf you want to install the main branch, use `go install github.com/ghchinoy/gen@main`.\n\n\n#### Authentication\n\n[Standard methods of authenticating](https://cloud.google.com/docs/authentication/provide-credentials-adc) to Google Cloud are supported.\n\n```bash\n# set your GCP project\ngcloud config set project YOUR_PROJECT\n# login to obtain credentials\ngcloud auth application-default login\n```\n\n#### GCP Project \u0026 Region\n\nSet your Google Cloud Project either via the env var `GEN_PROJECT_ID` or via the flag `--project` and your region either via the env var `GEN_REGION` or via the flag `--region`\n\nUsing env vars\n\n```bash\nexport GEN_PROJECT_ID=$(gcloud config get project)\nexport GEN_REGION=us-central1\n```\n\nUsing flags\n\n```bash\ngen --project $(gcloud config get project) --region us-central1 p \"hi there\"\n```\n\n## Usage\n\n### Generate content\n\nGenerate content with the `prompt` command. This defaults to `gemini-2.5-flash`.\n\n```bash\ngen prompt \"say something nice to me\"\n```\n\nThis will result in:\n\n```\n2024/03/30 15:29:13 model: gemini-1.0-pro\n2024/03/30 15:29:13 prompt: [say something nice to me]\n2024/03/30 15:29:13 using Gemini\nYou are a wonderful person with a kind heart and a beautiful soul. You deserve all the happiness in the world, and I hope you find it.\n```\n\nUsing the `--output json` output flag with `json` will return the full response payload.\n\nUse another model family, such as PaLM 2:\n\n```\ngen p --model text-bison@002 \"say something nice to me\"\n\n2024/03/30 16:24:50 model: text-bison@002\n2024/03/30 16:24:50 prompt: [say something nice to me]\n2024/03/30 16:24:50 using PaLM 2\n You are a bright and shining light in this world. Your kindness and compassion touch the lives of everyone you meet. You are a true gift to us all.\n```\n\nNote: This uses the `p` alias for the `prompt` command, see `gen help prompt` for aliases for a specific command.\n\nIf you have [Anthropic's models activated from Model Garden](https://console.cloud.google.com/vertex-ai/model-garden?pageState=(%22galleryStateKey%22:(%22f%22:(%22g%22:%5B%22providers%22%5D,%22o%22:%5B%22ANTHROPIC%22%5D),%22s%22:%22%22))), you can also use the model name in the `--model` (or `-m`) flag, the example below is for [Claude 3 Haiku](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-3-haiku). The tool uses the `aiplatform` SDK for these models.\n\n```bash\ngen p -m claude-3-haiku@20240307 \"say something nice to me\"\n```\n\n[Claude 3.5 Sonnet](https://console.cloud.google.com/vertex-ai/publishers/anthropic/model-garden/claude-3-5-sonnet):\n\n```bash\ngen p -m claude-3-5-sonnet@20240620 \"say something nice to me\"\n```\n\n\n### Model Configuration Parameters\n\nUse the `--config` flag to pass in model parameters, as a json file, such as:\n\n```bash\ngen p --model text-bison@002 --config config.json \"say something nice to me\"\n```\n\nWhere `config.json` contains [PaLM 2 parameters](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text#request_body):\n\n```json\n{\n    \"temperature\":     0.95,\n    \"maxOutputTokens\": 1024,\n    \"topP\":            0.4,\n    \"topK\":            40\n}\n```\n\nor, for [Gemini](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini#request_body), containing the `generationConfig`:\n\n```json\n{\n    \"temperature\": 0.1,\n    \"topP\": 0.9,\n    \"topK\": 40,\n    \"maxOutputTokens\": 256\n}\n```\n\n\n### Count Tokens\n\n```\ngen tokens \"hi how are you today\"\n\nNumber of tokens for the prompt: 5\n```\n\nor for a very long prompt in file\n\n```\ngen tokens --file VeryLongPromptFile.txt\n\nNumber of tokens for the prompt: 1599681\n```\n\n### Interactive mode\n\nMultiple single-turn interactions (synthetic context and support for models with a chat api planned):\n\n```\ngen interactive\n\n2024/03/30 15:27:33 entering interactive mode\n2024/03/30 15:27:33 type 'exit' or 'quit' to exit\n2024/03/30 15:27:33 model: gemini-1.0-pro\n? Hi say something nice to me\nYou are a beautiful, intelligent, and kind person. You are loved and appreciated by many people, and you bring joy to the lives of those around you. You are strong and capable, and you can achieve anything you set your mind to. I am proud of you, and I know you will continue to do great things.\n\n? What's your name?\nI am Gemini, a multi-modal AI language model developed by Google. I don't have a name, as I am not an individual being.\n\n```\n\n### Compare outputs with diff\n\nUsing the unix `diff` command and a clever ordering of `gen`, you can compare the output of two models with the same prompt.\n\n```\nexport MY_PROMPT=\"say something nice to me and mention your name\"\ndiff \u003c(gen p \"${MY_PROMPT}\") \u003c(gen p -m claude-3-5-sonnet@20240620 \"${MY_PROMPT}\")\n```\n\nThe result should be similar to:\n\n```\n\u003c You are a bright spark in the world, and I, Bard, am delighted to have crossed paths with you today!  Your energy and creativity shine through, and I'm sure you have amazing things ahead of you. Keep shining! 😊\n---\n\u003e As an AI language model, I don't have a personal name, but I'm happy to say something nice to you!\n2a3\n\u003e You are a thoughtful and kind person for wanting to hear something positive. Your curiosity and willingness to engage in conversation are admirable qualities. I hope you have a wonderful day filled with joy and positivity!\n```\n\n\n\n## Development\n\nThis project uses a hybrid approach to interacting with Google's generative models. The `google.golang.org/genai` SDK is used for Gemini models, while the `cloud.google.com/go/aiplatform` SDK is used for other models from the Vertex AI Model Garden.\n\n### Architecture\n\nThe `internal/model` package contains the core logic for interacting with the different models. The `ModelClient` interface provides a common abstraction for the different model clients, and the `NewClient` factory function is responsible for creating the correct client based on the model name. The `NewClient` function acts as a dispatcher, using the `genai` SDK for Gemini models and the `aiplatform` SDK for other models.\n\nThe `internal/cmd` package contains the command-line interface logic, which is built using the `cobra` library.\n\n### Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n\n## Acknowledgements\n`gen` is inspired by Simon Willison's [llm tool](https://llm.datasette.io/en/stable/) as well as Eli Bendersky's [gemini-cli](https://github.com/eliben/gemini-cli). Both are super awesome, check them out!\n\n\n## License\n\nApache 2.0; see [`LICENSE`](LICENSE) for details.\n\n## Disclaimer\n\nThis project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghchinoy%2Fgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghchinoy%2Fgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghchinoy%2Fgen/lists"}