ai-engine 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/app/models/concerns/ai/engine/assistable.rb +2 -2
- data/app/services/ai/engine/openai/assistants/create.rb +2 -7
- data/app/services/ai/engine/openai/assistants/update.rb +2 -7
- data/db/migrate/20240528153439_create_ai_engine_assistants.rb +1 -1
- data/lib/ai/engine/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02cef4cd33bb5b92f49695151fa4aa9e4004c9b5383745a977f3a9dfe0e46838
|
4
|
+
data.tar.gz: 8f01799a009e77481da633e93c9e2a6a73101ca0c2c98004a34bdb6ecc42152b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4e1801c40ba227499902b2475cd5ff06097c3d51eb3d26f417bb62e1ca17da7786934815fa251298bd62b8d066a44a574aee9073f213d2b53e4d18423edc1eb
|
7
|
+
data.tar.gz: 1b9960397d6bf0f234272aa21dc3780740f33de76dc39ce030d737a9cf45ec538c559d5401d362db5daafad528898a18fac86e7532a8f04f00471455c1750eb1
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# AI::Engine
|
2
2
|
|
3
|
-
|
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
|
29
|
+
Full docs can be found at [RailsAI.com](https://railsai.com/docs/installation).
|
26
30
|
|
27
31
|
## Engine Development
|
28
32
|
|
@@ -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(
|
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,
|
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)
|
@@ -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(
|
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:,
|
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
|
data/lib/ai/engine/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ai-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rudall
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.1.0
|
27
|
-
description:
|
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
|
89
|
+
summary: The fastest way to get AI Assistants into your Rails app!
|
90
90
|
test_files: []
|