{"id":17816385,"url":"https://github.com/nuzair46/ask_gpt","last_synced_at":"2026-04-02T02:06:57.911Z","repository":{"id":153056244,"uuid":"628023185","full_name":"Nuzair46/ask_gpt","owner":"Nuzair46","description":"A ruby gem to Interact with OpenAI GPT API with context and history","archived":false,"fork":false,"pushed_at":"2023-04-14T20:24:18.000Z","size":12,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-21T02:51:13.042Z","etag":null,"topics":["chatgpt","gpt","openai","ruby-gem","rubygem","rubygems"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/ask_gpt","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/Nuzair46.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-04-14T18:18:37.000Z","updated_at":"2023-06-04T08:21:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"fac7e665-8afc-4e7b-b5cd-11b08f086886","html_url":"https://github.com/Nuzair46/ask_gpt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Nuzair46/ask_gpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nuzair46%2Fask_gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nuzair46%2Fask_gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nuzair46%2Fask_gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nuzair46%2Fask_gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nuzair46","download_url":"https://codeload.github.com/Nuzair46/ask_gpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nuzair46%2Fask_gpt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"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":["chatgpt","gpt","openai","ruby-gem","rubygem","rubygems"],"created_at":"2024-10-27T16:37:46.523Z","updated_at":"2026-04-02T02:06:57.889Z","avatar_url":"https://github.com/Nuzair46.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AskGpt\n\n[![Gem Version](https://badge.fury.io/rb/ask_gpt.svg)](https://badge.fury.io/rb/ask_gpt)\n\n## Introduction\n\nAskGpt is a Ruby Gem that enables users to ask questions to ChatGPT with context.\n\n## Installation\n\nTo install AskGpt, add the following line to your Gemfile:\n\n```ruby\ngem 'ask_gpt'\n```\n\nThen run `bundle install` to install the gem.\n\n## Usage\n\nAfter installation, import AskGpt into your Ruby program:\n\n```ruby\nrequire 'ask_gpt'\n```\n\nNext, create a new instance of the `AskGpt::GPT` class:\n\n```ruby\ngpt = AskGpt::GPT.new(api_key)\n```\n\n- The `api_key` parameter is required and represents your OpenAI API key. You can get it from [here](https://platform.openai.com/account/api-keys).\n\n- The `model` parameter is optional and represents the GPT model that you want to use. The default value is `gpt-3.5-turbo`. You can use `gpt-4` if you have access to it.\n\n- The `temperature` parameter is also optional and represents the \"creativity\" of the model's responses. The default value is `0.7`, which should provide a good balance between creativity and accuracy. Value ranges from `0.0 - 1.0` and the higher the value, the more creative the model's responses will be.\n\n- The `unable_to_get_answer_text` parameter is optional and represents the message that will be returned if the model is unable to generate a response. The default value is 'Unable to get answer from ChatGPT. Make sure API key is valid and has enough credits.'\n\nOnce you have created a new instance of the GPT class, you can ask questions by calling the `ask` method:\n\n```ruby\nanswer = gpt.ask(\"What is the capital of France?\")\n```\n\nThe `ask` method takes a single parameter, which is the question that you want to ask the model. If the question is empty, the method will return `nil`. Otherwise, it will use the context of previous questions and answers to generate a response. If the model is unable to generate a response, the `ask` method will return the `unable_to_get_answer_text` message.\n\nIf the model is able to generate a response, the `ask` method will return the answer as a string.\n\n## Example\n\nHere's an example of how you can use AskGpt to ask a series of questions and get answers:\n\n```ruby\nrequire 'ask_gpt'\n\napi_key = 'your_api_key_here'\ngpt = AskGpt::GPT.new(api_key)\n\nquestions = [\n  \"What is the capital of France?\",\n  \"Who was the first president of the United States?\",\n  \"What is the tallest mountain in the world?\"\n]\n\nquestions.each do |question|\n  answer = gpt.ask(question)\n  puts \"Q: #{question}\\nA: #{answer}\\n\\n\"\nend\n\n```\n\nIn this example, we first create a new instance of the GPT class using our API key. We then define an array of questions that we want to ask the model. Finally, we loop through each question, ask the model for an answer, and print the question and answer to the console.\n\n## Projects using AskGpt\n\n- [ask_gpt_cli](https://github.com/Nuzair46/ask_gpt_cli)\n\n### Remarks\n\nThis readme was generated by ChatGPT with some guidance and modifications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuzair46%2Fask_gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuzair46%2Fask_gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuzair46%2Fask_gpt/lists"}