Sha256: b7331f7efd6ec70c4d155a08a9caa811f3ded39a1ffa5a9da66d6221a6adb426

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# ActiveCortex

Easily add AI-generated fields to your Rails models.

## Usage

```ruby
# app/models/document.rb
class Document < ApplicationRecord
  include ActiveCortex::Model

  ai_generated :summary, prompt: -> (doc) { "Summarize: #{doc.text}" }
  # (or)
  ai_generated :summary, prompt: :generate_summary_prompt

  private

  def generate_summary_prompt
     "Summarize: #{text}"
  end
end

# ... then ...
doc = Document.new(text: "Call me Ishmael...")
doc.generate_summary!
doc.summary # => an AI-generated summary of `text`
```

## Installation

Add this line to your application's Gemfile:

```ruby
gem "active_cortex"
```

And then execute:
```bash
$ bundle
```

Or install it yourself as:
```bash
$ gem install active_cortex
```

And set an OpenAI key

```ruby
# config/initializers/active_cortex.rb
ActiveCortex.config.openai_key = ENV.fetch("OPENAI_ACCESS_TOKEN")
```

## Contributing

Happy for you to open an issue if you have ideas to improve the gem.

## License

The gem is available as open source under the terms of the [MIT
License](https://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_cortex-0.1.0 README.md