ai-engine 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 243780cd32368a63bf16fef0f89a122c2877d338fa196c885925aee25161e060
4
- data.tar.gz: a41343a78d3bfe8098c4fa8b169dbc85c789351ba710f16da927ca7b609b654b
3
+ metadata.gz: 0702cfaf1ad63d8a98a0b8acb67fdd0b1d3cf46320652f8f86df6b677af981ac
4
+ data.tar.gz: 1adacb8b8e2ef7da675077a79950ca342df9401a62780b8955c5b785f3d32538
5
5
  SHA512:
6
- metadata.gz: ab48e0f806a2b4171e16b567c819c6d759cd453b525bc9d4152b689ab195922fc7eafc691e222cad13f05682226a5e8a9e836c11da610062378cf24478116acf
7
- data.tar.gz: 25826ebd894a27f9b0599e2fde6586acc76bc496de3ec9a98d0f1a3178fac780ac11358dbe9735dcd0e9d892aa27bc22199eaed3713c744a1fae7f693f5619b6
6
+ metadata.gz: b1270b59cdbe033e1147cc54ca9124145d3670363ec73b51854832983ae6f1d5dc88ead7ad726d99d641b4c7a9b0d2fe4eb5b236b7c6bdcb792d44c9f175fd77
7
+ data.tar.gz: 12e4f4c75a87e9f5b3c67312009906f981e01ebe340c2de3f6c8420a625bf2b7bddde7507bd9d0246747434d8ba95c5cd9cf6e4d6d1741cefdd15906d3774d6b
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # AI::Engine
2
2
 
3
- An experimental, easy-ish way to add AI assistants to your Rails app!
3
+ AI::Engine is the fastest way to get AI Assistants into your Rails app! It's a Rails Engine which sets up everything you need to start streaming from OpenAI Assistants in your Rails app.
4
+
5
+ Full docs can be found at [RailsAI.com](https://railsai.com/docs/installation).
6
+
7
+ A demo app can be found [here](https://github.com/alexrudall/ai-engine-starter-kit/).
4
8
 
5
9
  ## Usage
6
10
 
@@ -22,7 +26,7 @@ And run them:
22
26
  bundle exec rails db:migrate
23
27
  ```
24
28
 
25
- Full usage documentation can be found at [RailsAI.com](https://railsai.com/docs/installation).
29
+ Full docs can be found at [RailsAI.com](https://railsai.com/docs/installation).
26
30
 
27
31
  ## Engine Development
28
32
 
@@ -4,7 +4,7 @@ module AI
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_one :assistant, as: :assistable, class_name: "AI::Engine::Assistant"
7
+ has_one :assistant, as: :assistable, class_name: "AI::Engine::Assistant", dependent: :nullify
8
8
 
9
9
  before_create :create_openai_assistant
10
10
  before_update :update_openai_assistant
@@ -29,7 +29,7 @@ module AI
29
29
  def create_openai_assistant
30
30
  build_assistant
31
31
  begin
32
- assistant.remote_id = AI::Engine::OpenAI::Assistants::Create.call(**ai_engine_assistant)
32
+ assistant.remote_id = AI::Engine::OpenAI::Assistants::Create.call(ai_engine_assistant)
33
33
  rescue Faraday::Error => e
34
34
  errors.add(:base, e.message)
35
35
  throw(:abort)
@@ -37,7 +37,7 @@ module AI
37
37
  end
38
38
 
39
39
  def update_openai_assistant
40
- AI::Engine::OpenAI::Assistants::Update.call(remote_id: assistant&.remote_id, **ai_engine_assistant)
40
+ AI::Engine::OpenAI::Assistants::Update.call(remote_id: assistant&.remote_id, parameters: ai_engine_assistant)
41
41
  rescue Faraday::Error => e
42
42
  errors.add(:base, e.message)
43
43
  throw(:abort)
@@ -4,7 +4,7 @@ module AI
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- has_many :assistant_threads, as: :threadable, class_name: "AI::Engine::AssistantThread"
7
+ has_many :assistant_threads, as: :threadable, class_name: "AI::Engine::AssistantThread", dependent: :nullify
8
8
 
9
9
  def ai_engine_on_message_create(message:)
10
10
  # This is a hook for the AI Engine to notify the AssistantThreadtable that a Message has been updated.
@@ -1,14 +1,9 @@
1
1
  class AI::Engine::OpenAI::Assistants::Create
2
2
  # Creates a new Assistant on the OpenAI API.
3
3
  # Returns the OpenAI ID of the new Assistant.
4
- def self.call(name:, model:, description:, instructions:)
4
+ def self.call(parameters)
5
5
  response = client.assistants.create(
6
- parameters: {
7
- name: name,
8
- model: model,
9
- description: description,
10
- instructions: instructions
11
- }
6
+ parameters: parameters
12
7
  )
13
8
 
14
9
  response["id"]
@@ -1,12 +1,7 @@
1
1
  class AI::Engine::OpenAI::Assistants::Update
2
2
  # Updates an OpenAI Assistant with the given parameters.
3
- def self.call(remote_id:, name: nil, model: nil, description: nil, instructions: nil)
4
- parameters = {
5
- name: name,
6
- model: model,
7
- description: description,
8
- instructions: instructions
9
- }.compact
3
+ def self.call(remote_id:, parameters:)
4
+ parameters = parameters.compact
10
5
 
11
6
  client.assistants.modify(
12
7
  id: remote_id,
@@ -7,6 +7,6 @@ class CreateAIEngineAssistants < ActiveRecord::Migration[7.1]
7
7
  t.timestamps
8
8
  end
9
9
 
10
- add_index :ai_engine_assistants, %i[assistable_type assistable_id remote_id], unique: true
10
+ add_index :ai_engine_assistants, %i[assistable_type assistable_id remote_id], unique: true, name: "ai_engine_assistants_unique_index"
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
1
  module AI
2
2
  module Engine
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rudall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-16 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.1.0
27
- description: A Rails Engine from the creator of ruby-openai.
27
+ description: The fastest way to get AI Assistants into your Rails app!
28
28
  email:
29
29
  - hello@alexrudall.com
30
30
  executables: []
@@ -86,5 +86,5 @@ requirements: []
86
86
  rubygems_version: 3.5.11
87
87
  signing_key:
88
88
  specification_version: 4
89
- summary: The easiest way to get AI into your Rails app.
89
+ summary: The fastest way to get AI Assistants into your Rails app!
90
90
  test_files: []