{"id":13878059,"url":"https://github.com/alchaplinsky/gen-ai","last_synced_at":"2025-04-09T09:09:13.217Z","repository":{"id":202866627,"uuid":"705222726","full_name":"alchaplinsky/gen-ai","owner":"alchaplinsky","description":"✨ Generative AI toolset for Ruby ✨","archived":false,"fork":false,"pushed_at":"2024-10-11T15:41:45.000Z","size":2435,"stargazers_count":32,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T07:11:13.254Z","etag":null,"topics":["ai","artificial-intelligence","gemini","generative-ai","google-palm-ai","llm","openai","ruby-ai","stability-ai","stable-diffusion"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alchaplinsky.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2023-10-15T12:08:00.000Z","updated_at":"2025-02-09T11:14:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"80cf5dfe-69f7-4956-97a7-bde7a3405f32","html_url":"https://github.com/alchaplinsky/gen-ai","commit_stats":{"total_commits":108,"total_committers":2,"mean_commits":54.0,"dds":0.03703703703703709,"last_synced_commit":"a9e3290633670157bd2508607c381947816d799c"},"previous_names":["alchaplinsky/gen-ai"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fgen-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fgen-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fgen-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fgen-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alchaplinsky","download_url":"https://codeload.github.com/alchaplinsky/gen-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"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","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":["ai","artificial-intelligence","gemini","generative-ai","google-palm-ai","llm","openai","ruby-ai","stability-ai","stable-diffusion"],"created_at":"2024-08-06T08:01:38.734Z","updated_at":"2025-04-09T09:09:13.192Z","avatar_url":"https://github.com/alchaplinsky.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# GenAI\n\n✨ Generative AI toolset for Ruby ✨\n\nGenAI allows you to easily integrate Generative AI model providers like OpenAI, Google Vertex AI, Stability AI, etc. Easily add Large Language Models, Stable Diffusion image generation, and other AI model integrations into your application!\n\n![Tests](https://github.com/alchaplinsky/gen-ai/actions/workflows/main.yml/badge.svg?branch=main)\n[![Gem Version](https://badge.fury.io/rb/gen-ai.svg)](https://badge.fury.io/rb/gen-ai)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/alchaplinsky/gen-ai/blob/main/LICENSE.txt)\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add gen-ai\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install gen-ai\n\n## Compatibility\n\nThis gem is compatible with Ruby 3.1 or greater.\n\n## Usage\n\nRequire it in you code:\n\n```ruby\nrequire 'gen_ai'\n```\n\n### Feature support\n\n✅ - Supported | ❌ - Not supported | 🛠️ - Work in progress\n\nLanguage models capabilities\n\n| Provider          | Embedding | Completion | Conversation | Sentiment | Summarization |\n| ----------------- | :-------: | :--------: | :----------: | :-------: | :-----------: |\n| **OpenAI**        |    ✅     |     ✅     |      ✅      |    🛠️     |      🛠️       |\n| **Google Palm2**  |    ✅     |     ✅     |      ✅      |    🛠️     |      🛠️       |\n| **Google Gemini** |    ❌     |     🛠️     |      ✅      |    🛠️     |      🛠️       |\n| **Anthropic**     |    ❌     |     ✅     |      ✅      |    🛠️     |      🛠️       |\n\nImage generation model capabilities\n\n| Provider        | Generate | Variations | Edit | Upscale |\n| --------------- | :------: | :--------: | :--: | :-----: |\n| **OpenAI**      |    ✅    |     ✅     |  ✅  |   ❌    |\n| **StabilityAI** |    ✅    |     ❌     |  ✅  |   ✅    |\n\n### Language\n\nInstantiate a language model client by passing a provider name and an API token.\n\n```ruby\nmodel = GenAI::Language.new(:open_ai, ENV['OPEN_AI_TOKEN'])\n```\n\nGenerate **embedding(s)** for text using provider/model that fits your needs\n\n```ruby\nresult = model.embed('Hi, how are you?')\n# =\u003e #\u003cGenAI::Result:0x0000000110be6f20...\u003e\n\nresult.value\n# =\u003e  [-0.013577374, 0.0021624255, 0.0019274801, ... ]\n\nresult = model.embed(['Hello', 'Bonjour', 'Cześć'])\n# =\u003e #\u003cGenAI::Result:0x0000000110be6f34...\u003e\n\nresult.values\n# =\u003e  [[-0.021834826, -0.007176527, -0.02836839,, ... ], [...], [...]]\n```\n\nGenerate text **completions** using Large Language Models\n\n```ruby\nresult = model.complete('London is a ', temperature: 0, max_tokens: 11)\n# =\u003e #\u003cGenAI::Result:0x0000000110be6d21...\u003e\n\nresult.value\n# =\u003e \"vibrant and diverse city located in the United Kingdom\"\n\n\nresult = model.complete('London is a ', max_tokens: 12, n: 2)\n# =\u003e #\u003cGenAI::Result:0x0000000110c25c70...\u003e\n\nresult.values\n# =\u003e [\"thriving, bustling city known for its rich history.\", \"major global city and the capital of the United Kingdom.\"]\n\n```\n\n### Chat\nHave a **conversation** with Large Language Model and Build your own AI chatbot.\n\nSetting a context for the conversation is optional, but it helps the model to understand the topic of the conversation.\n\n```ruby\nchat = GenAI::Chat.new(:open_ai, ENV['OPEN_AI_TOKEN'])\nchat.start(context: \"You are a chat bot named Erl\")\nchat.message(\"Hi, what's your name\")\n# = \u003e#\u003cGenAI::Result:0x0000000106ff3d20...\u003e\n\nresult.value\n# =\u003e \"I am a chatbot and you can call me Erl. How can I help you?\"\"\n\n```\n\n\nProvider a history of the conversation to the model to help it understand the context of the conversation.\n\n```ruby\nhistory = [\n    {role: 'user', content: 'What is the capital of Great Britain?'},\n    {role: 'assistant', content: 'London'},\n]\n\nchat = GenAI::Chat.new(:open_ai, ENV['OPEN_AI_TOKEN'])\nresult = model.start(history: history)\nresult = model.message(\"what about France?\")\n# =\u003e #\u003cGenAI::Result:0x00000001033c3bc0...\u003e\n\nresult.value\n# =\u003e \"Paris\"\n```\n\n### Image\n\nInstantiate a image generation model client by passing a provider name and an API token.\n\n```ruby\nmodel = GenAI::Image.new(:open_ai, ENV['OPEN_AI_TOKEN'])\n```\n\nGenerate **image(s)** using provider/model that fits your needs\n\n```ruby\nresult = model.generate('A painting of a dog')\n# =\u003e #\u003cGenAI::Result:0x0000000110be6f20...\u003e\n\nresult.value\n# =\u003e image binary\n\nresult.value(:base64)\n# =\u003e image in base64\n\n# Save image to file\nFile.open('dog.jpg', 'wb') do |f|\n  f.write(result.value)\nend\n```\n\n![dog](https://github.com/alchaplinsky/gen-ai/assets/695947/27a2af5d-530b-4966-94e8-6cdf628b6cac)\n\nGet more **variations** of the same image\n\n```ruby\nresult = model.variations('./dog.jpg')\n# =\u003e #\u003cGenAI::Result:0x0000000116a1ec50...\u003e\n\nresult.value\n# =\u003e image binary\n\nresult.value(:base64)\n# =\u003e image in base64\n\n# Save image to file\nFile.open('dog_variation.jpg', 'wb') do |f|\n  f.write(result.value)\nend\n\n```\n\n![dog_variation](https://github.com/alchaplinsky/gen-ai/assets/695947/977f5238-0114-4085-8e61-8f8b356ce308)\n\n**Editing** existing images with additional prompt\n\n```ruby\nresult = model.edit('./llama.jpg', 'A cute llama wearing a beret', mask: './mask.png')\n# =\u003e #\u003cGenAI::Result:0x0000000116a1ec50...\u003e\n\nresult.value\n# =\u003e image binary\n\nresult.value(:base64)\n# =\u003e image in base64\n\n# Save image to file\nFile.open('dog_edited.jpg', 'wb') do |f|\n  f.write(result.value)\nend\n```\n\n![llama](https://github.com/alchaplinsky/gen-ai/assets/695947/9c862c6c-428e-463c-b935-ca749a6a33df)\n![llama_edited](https://github.com/alchaplinsky/gen-ai/assets/695947/070d8e6a-07a0-4ed2-826f-8b9aabd183ae)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/alchaplinsky/gen-ai. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alchaplinsky/gen-ai/blob/main/CODE_OF_CONDUCT.md).\n\n## Code of Conduct\n\nEveryone interacting in the GenAI project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/alchaplinsky/gen-ai/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fgen-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falchaplinsky%2Fgen-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fgen-ai/lists"}