{"id":13878193,"url":"https://github.com/st0012/irb-ai","last_synced_at":"2025-04-24T04:37:22.648Z","repository":{"id":171100319,"uuid":"646993316","full_name":"st0012/irb-ai","owner":"st0012","description":"IRB-AI is an experimental project that explores various ways to enhance users' IRB experience through AI (currently using ChatGPT).","archived":false,"fork":false,"pushed_at":"2023-05-31T16:55:48.000Z","size":30,"stargazers_count":25,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-22T06:15:31.635Z","etag":null,"topics":["chatgpt","irb","openai","ruby"],"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/st0012.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2023-05-29T20:28:17.000Z","updated_at":"2023-12-08T09:12:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"51c85e79-4648-43bc-9b6c-48930dc93af6","html_url":"https://github.com/st0012/irb-ai","commit_stats":null,"previous_names":["st0012/irb-ai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st0012%2Firb-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st0012%2Firb-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st0012%2Firb-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st0012%2Firb-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/st0012","download_url":"https://codeload.github.com/st0012/irb-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232352969,"owners_count":18510078,"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":["chatgpt","irb","openai","ruby"],"created_at":"2024-08-06T08:01:42.378Z","updated_at":"2025-01-03T15:19:33.463Z","avatar_url":"https://github.com/st0012.png","language":"Ruby","readme":"# IRB-AI\n\n[![Gem Version](https://badge.fury.io/rb/irb-ai.svg)](https://badge.fury.io/rb/irb-ai)\n\n`IRB-AI` is an experimental project that explores various ways to enhance users' IRB experience through AI (currently using `ChatGPT`).\n\n## Installation\n\nAdd this gem to your `Gemfile`:\n\n```rb\ngem \"irb-ai\", group: [:development, :test]\n```\n\n## Setup\n\nEnsure you have your [OpenAI API](https://openai.com/blog/openai-api) key stored in `ENV[\"OPENAI_API_KEY\"]`.\n\n## Usage\n\nAt the moment, this gem only provides the `explain` command:\n\n- `explain \u003cexpression\u003e as \u003ccontext expression\u003e` explains the execution of `\u003cexpression\u003e` by observing `\u003ccontext expression\u003e`\n  - For instance, `explain Post.find_the_closest as Post` will trace `Post`'s method calls to collect runtime information.\n- `explain \u003cexpression\u003e` is equivalent to `explain \u003cexpression\u003e as self`\n\nIncluding `\u003ccontext expression\u003e` is advised because this project relies on [`ruby/tracer`](https://github.com/ruby/tracer)'s\n[`ObjectTracer`](https://github.com/ruby/tracer#objecttracer), which only collects traces around the target object.\n\nThe more detailed [`CallTracer`](https://github.com/ruby/tracer#calltracer) is not used because the current ChatGPT models\nhave a relatively low token limit (`gpt-3.5-turbo` allows only `4000` tokens). Thus, using it can easily exceed that limit and\nresult in the request being rejected.\n\n### Configurations\n\nYou can specify the model through `IRB::AI.model = \"\u003cmy model\u003e\"`. The default is `gpt-3.5-turbo`.\n\n## Example\n\nGiven this script:\n\n```rb\nrequire \"bundler/inline\"\n\ngemfile do\n  gem \"irb-ai\"\n  gem \"activesupport\"\nend\n\nrequire \"irb/ai\"\nrequire \"active_support\"\nrequire \"active_support/core_ext/object/blank\"\n\nold_secret = SecureRandom.base64(24)\nold_encryptor = ActiveSupport::MessageEncryptor.new old_secret\nnew_secret = SecureRandom.base64(24)\nnew_encryptor = ActiveSupport::MessageEncryptor.new new_secret\nnew_encryptor.rotate old_secret\n\nmsg_from_old_encryptor = old_encryptor.encrypt_and_sign(\"test\")\n\n# Run `explain new_encryptor.decrypt_and_verify(msg_from_old_encryptor) as new_encryptor`\nbinding.irb \n```\n\nIf you run the following command from the breakpoint:\n\n```\nexplain new_encryptor.decrypt_and_verify(msg_from_old_encryptor) as new_encryptor\n```\n\nIt will respond with answers like this as rendered markdown output:\n\n```md\nThis is an analysis of the program's behaviour when running the expression `new_encryptor.decrypt_and_verify(msg_from_old_encryptor)`\n\n### Code Summary\n\nFrom the given information, there is no program source code provided.\n\n### Execution Summary\n\nThe `decrypt_and_verify` method was called on an instance of `ActiveSupport::MessageEncryptor` with a message received from an old encryptor. The method returned the decrypted message \"test\".\n\n### Execution Details\n\n1. The `decrypt_and_verify` method was called on an instance of `ActiveSupport::MessageEncryptor` with a message received from an old encryptor.\n2. The `decrypt_and_verify` method called the `verifier` method on the same instance of `ActiveSupport::MessageEncryptor`.\n3. An `ActiveSupport::MessageVerifier::InvalidSignature` exception was raised at line 178 in `message_verifier.rb`, indicating that the message could not be authenticated with the given signature (which was generated by the old encryptor).\n4. The exception was caught by `run_rotations` in `rotator.rb`.\n5. `run_rotations` calls `decrypt_and_verify` again, this time with a different key used by the new encryptor.\n6. `decrypt_and_verify` called `verifier` again, but this time with the new key used by the new encryptor.\n7. The `verifier` method verified the signature of the message using the new key, and found it to be valid.\n8. The `decrypt_and_verify` method decrypted the message using the new key, which was used to encrypt the message before it was signed.\n9. The decrypted message \"test\" was returned from the `decrypt_and_verify` method.\n\nThus the program successfully decrypted and authenticated the message received from the old encryptor.\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test-unit` to run the tests.\nYou 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`.\nTo release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,\nwhich 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/st0012/irb-ai.\nThis 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/st0012/irb-ai/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `IRB-AI` project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/st0012/irb-ai/blob/main/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fst0012%2Firb-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fst0012%2Firb-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fst0012%2Firb-ai/lists"}