MIT License

项目介绍

alexshapalov/rubyai 是一个托管在 GitHub 上的开源项目,主要使用 Ruby 编写,采用 MIT License 许可证,目前获得 78 个 Star、5 次 Fork。

仓库全名
alexshapalov/rubyai
开源许可证
MIT License
Star 数
78
Fork 数
5
未关闭 Issue
1

README 摘要

RubyAI - OpenAI integration Ruby gem Use the OpenAI API 🤖 with Ruby! ❤️ Generate text with ChatGPT (Generative Pre-trained Transformer) Installation Add this line to your application's Gemfile: And then execute: $ bundle install Or install with: $ gem install rubyai and require with: Usage Get your API key from https://beta.openai.com/account/api-keys If you belong to multiple organizations, you can get your…

完整内容见 GitHub 原始 README 或本页 。

常见问题

rubyai 用什么语言开发?

主要使用 Ruby 编写,采用 MIT License 许可证,目前有 78 个 Star。

rubyai 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 rubyai 的源码?

可以直接克隆仓库:git clone https://github.com/alexshapalov/rubyai.git,默认分支为 main;安装与运行步骤见仓库 README。

rubyai 最近还在维护吗?

仓库最近一次更新为 2025年3月25日,当前有 1 个未关闭 Issue;Star 数为 78,可作为社区活跃度的参考。

关于

RubyAI is OpenAI integration Ruby LLM gem, GPT-5 + Ruby! ❤️

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
92
价值分
48
活跃状态
活跃

Release

README

RubyAI - OpenAI integration Ruby gem

Gem Version GitHub license

Use the OpenAI API 🤖 with Ruby! ❤️

Generate text with ChatGPT (Generative Pre-trained Transformer)

Installation

Add this line to your application’s Gemfile:

gem "rubyai"

And then execute:

$ bundle install

Or install with:

$ gem install rubyai

and require with:

require "rubyai"

Usage

Quickstart

For a quick test you can pass your token directly to a new client:

result = RubyAI::Client.new(access_token, messages).call

ChatGPT

ChatGPT is a conversational-style text generation model. You can use it to generate a response to a sequence of messages:

api_key = "YOUR API KEY"
messages = "Who is the best chess player in history?"

result = RubyAI::Client.new(api_key, messages, model: "gpt-4").call
puts result.dig("choices", 0, "message", "content")

# => As an AI language model, I do not have personal opinions, but according to historical records, Garry Kasparov is often considered as one of the best chess players in history. Other notable players include Magnus Carlsen, Bobby Fischer, and Jose Capablanca.

You can also pass client variables using the configuration file. Create configruation file like on example:

configuration = RubyAI::Configuration.new("YOUR API KEY", "Who is the best chess player in history?")
client = RubyAI::Client.new(configuration)
result = client.call
puts result.dig("choices", 0, "message", "content")

Also (mostly) if you are using Rails you can use configure method:

RubyAI.configure do |config|
  config.api_key = "YOUR API KEY"
  config.messages = "Who is the best chess player in history?"
  config.model = "gpt-4o-mini"
end

Models

We support all popular GPT models:

gpt-4-turbo: A powerful variant of GPT-4 optimized for efficiency and speed, perfect for high-demand tasks.

gpt-4o-mini: A streamlined version of GPT-4, designed to provide a balance between performance and resource efficiency.

o1-mini: A compact, yet effective model that is well-suited for lightweight tasks.

o1-preview: A preview version of the o1 model, offering insights into upcoming advancements and features.

Development

After checking out the repo, run bin/setup to install dependencies. You can run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alexshapalov/rubyai. This project is intended to be a safe, welcoming space for collaboration, and contributors.

License

The gem is available as open source under the terms of the MIT License.

评论

暂无评论