Skip to content

Commit 85cc6f2

Browse files
committed
Fix bugs preventing selective use of ai services
1 parent d17420b commit 85cc6f2

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [0.0.5] - 2025-03-04
1+
## [0.0.6] - 2025-03-04
22

33
- Do not require all 3 services to function. Let user require which services they want to use.
44

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-ai (0.0.5)
4+
foobara-ai (0.0.6)
55
foobara-anthropic-api
66
foobara-ollama-api
77
foobara-open-ai-api

lib/foobara/ai.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ module Ai
77
module AnswerBot
88
foobara_domain!
99

10-
base_dir = "#{__dir__}/../../src/foobara/ai/answer_bot"
11-
Util.require_directory "#{base_dir}/types"
12-
Dir["#{base_dir}/domain_mappers/*.rb"].each { |f| require f }
13-
Dir["#{base_dir}/*.rb"].each { |f| require f }
10+
require_relative "../../src/foobara/ai/answer_bot/types/service_enum"
1411

1512
ai_services = {}
1613

@@ -26,12 +23,19 @@ module AnswerBot
2623

2724
ai_services[service] = domain
2825
foobara_depends_on domain
29-
30-
path = Util.underscore(domain.foobara_domain_name)
31-
Util.require_directory "#{__dir__}/../../src/foobara/ai/answer_bot/domain_mappers/#{path}"
3226
end
3327

3428
AI_SERVICES = ai_services
29+
30+
base_dir = "#{__dir__}/../../src/foobara/ai/answer_bot"
31+
Util.require_directory "#{base_dir}/types"
32+
Dir["#{base_dir}/domain_mappers/*.rb"].each { |f| require f }
33+
Dir["#{base_dir}/*.rb"].each { |f| require f }
34+
35+
AI_SERVICES.each_value do |domain|
36+
path = Util.underscore(domain.foobara_domain_name)
37+
Util.require_directory "#{base_dir}/domain_mappers/#{path}"
38+
end
3539
end
3640
end
3741
end

src/foobara/ai/answer_bot/list_models.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require_relative "types/service_enum"
12
require_relative "types/model"
23

34
module Foobara
@@ -8,11 +9,13 @@ class ListModels < Foobara::Command
89

910
result [Types::Model]
1011

11-
LIST_COMMANDS = [
12-
OpenAiApi::ListModels,
13-
AnthropicApi::ListModels,
14-
OllamaApi::ListLocalModels
15-
].freeze
12+
LIST_COMMANDS = AI_SERVICES.values.map do |domain|
13+
if domain == OllamaApi
14+
OllamaApi::ListLocalModels
15+
else
16+
domain::ListModels
17+
end
18+
end
1619

1720
depends_on(*LIST_COMMANDS)
1821

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Foobara
22
module Ai
3-
VERSION = "0.0.5".freeze
3+
VERSION = "0.0.6".freeze
44

55
local_ruby_version = File.read("#{__dir__}/.ruby-version").chomp
66
local_ruby_version_minor = local_ruby_version[/\A(\d+\.\d+)\.\d+\z/, 1]

0 commit comments

Comments
 (0)