foobara-ai 0.0.14 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c915b80c804ceddc6311400052b2a7cce0011bfcfda4d80dc200f63e50382e5
4
- data.tar.gz: 3e50a758f4b65631c5c535fcce51aca9013170cdcd856760c956bb3605b1acff
3
+ metadata.gz: aa2a8e4b0d4b634506aa49974927e7a3aecd0ba36b7992b27e58d051264e4cd7
4
+ data.tar.gz: 593b5f446f52e566f7e77821e2873c5561e38e6ae10e595a547896def58ab493
5
5
  SHA512:
6
- metadata.gz: 1eb53a355a90be12c04da34da4449c22ef8808c4b9bb98e422285a363089d5284fbf916138bc60dcfab525ade24016fdda5878649b9310d9c662857326d9ea0a
7
- data.tar.gz: 6d825776dc6a23720bf90d72c9f61aed29665f19625d8c36dcd03388f751ccae3b798c38cab8c388c0f15b3b69f7fe17e42d7c52a61d7e6145e6cf3ce103d30c
6
+ metadata.gz: 37b829fa773865a26180bf8ae386973b7f6062a89dd5aab090ad5e866a2b8dab7a6e471e759164ea714fbc25fac203b3d26c36197def11eb4dd2d7775f8caf27
7
+ data.tar.gz: 4c054fbbfacf099659792bfd3158ae31a6ebfeaf51625d41c13c64e9c1820adea2e474ffdc0a09d319e2a96c1ffeb63775ac4ecb25167b664ee7ac7a00bbae00
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.0] - 2025-07-09
2
+
3
+ - Add .default_llm_model
4
+
1
5
  ## [0.0.14] - 2025-07-05
2
6
 
3
7
  - o1 models don't support temperature so force it to 1
data/lib/foobara/ai.rb CHANGED
@@ -7,33 +7,14 @@ module Foobara
7
7
  module AnswerBot
8
8
  foobara_domain!
9
9
 
10
- require_relative "../../src/foobara/ai/answer_bot/types/service_enum"
10
+ require_relative "../../src/foobara/ai"
11
11
 
12
- ai_services = {}
12
+ AI_SERVICES = Ai.installed_ai_services
13
13
 
14
- if defined?(Foobara::Ai::OpenAiApi)
15
- ai_services[Types::ServiceEnum::OPEN_AI] = OpenAiApi
16
- end
17
- if defined?(Foobara::Ai::AnthropicApi)
18
- ai_services[Types::ServiceEnum::ANTHROPIC] = AnthropicApi
19
- end
20
- if defined?(Foobara::Ai::OllamaApi)
21
- ai_services[Types::ServiceEnum::OLLAMA] = OllamaApi
22
- end
23
-
24
- if ai_services.empty?
25
- # :nocov:
26
- require "foobara/anthropic_api"
27
- ai_services = { Types::ServiceEnum::ANTHROPIC => AnthropicApi }
28
- # :nocov:
29
- end
30
-
31
- ai_services.each_value do |domain|
14
+ AI_SERVICES.each_value do |domain|
32
15
  foobara_depends_on domain
33
16
  end
34
17
 
35
- AI_SERVICES = ai_services
36
-
37
18
  base_dir = "#{__dir__}/../../src/foobara/ai/answer_bot"
38
19
 
39
20
  AI_SERVICES.each_value do |domain|
@@ -8,7 +8,7 @@ module Foobara
8
8
  question :string, :required, "whatever you want to know!"
9
9
  instructions :string, "Results in a system prompt. You can specify how you want the LLM to behave."
10
10
  service :service_enum, "If two services expose the same model, you can specify which one to use."
11
- model :model_enum, default: "claude-3-7-sonnet-20250219", description: "The model to use."
11
+ model :model_enum, default: Ai.default_llm_model, description: "The model to use."
12
12
  end
13
13
 
14
14
  result :string
@@ -7,7 +7,7 @@ module Foobara
7
7
  inputs do
8
8
  chat Types::Chat, :required
9
9
  service :service_enum, "If two services expose the same model, you can specify which one to use."
10
- model :model_enum, default: "claude-3-7-sonnet-20250219", description: "The model to use."
10
+ model :model_enum, default: Ai.default_llm_model, description: "The model to use."
11
11
  temperature :float
12
12
  end
13
13
 
data/src/foobara/ai.rb ADDED
@@ -0,0 +1,50 @@
1
+ require_relative "ai/answer_bot/types/service_enum"
2
+
3
+ module Foobara
4
+ module Ai
5
+ class << self
6
+ def anthropic_setup?
7
+ defined?(Ai::AnthropicApi)
8
+ end
9
+
10
+ def open_ai_setup?
11
+ defined?(Ai::OpenAiApi)
12
+ end
13
+
14
+ def ollama_setup?
15
+ defined?(Ai::OllamaApi)
16
+ end
17
+
18
+ def installed_ai_services
19
+ return @ai_services if @ai_services
20
+
21
+ @ai_services = {}
22
+
23
+ if anthropic_setup?
24
+ @ai_services[AnswerBot::Types::ServiceEnum::ANTHROPIC] = AnthropicApi
25
+ end
26
+
27
+ if open_ai_setup?
28
+ @ai_services[AnswerBot::Types::ServiceEnum::OPEN_AI] = OpenAiApi
29
+ end
30
+
31
+ if ollama_setup?
32
+ @ai_services[AnswerBot::Types::ServiceEnum::OLLAMA] = OllamaApi
33
+ end
34
+
35
+ if @ai_services.empty?
36
+ # :nocov:
37
+ require "foobara/anthropic_api"
38
+ @ai_services = { Types::ServiceEnum::ANTHROPIC => AnthropicApi }
39
+ # :nocov:
40
+ end
41
+
42
+ @ai_services
43
+ end
44
+
45
+ def default_llm_model
46
+ @default_llm_model ||= installed_ai_services.values.first.default_llm_model
47
+ end
48
+ end
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -20,6 +20,7 @@ files:
20
20
  - LICENSE.txt
21
21
  - README.md
22
22
  - lib/foobara/ai.rb
23
+ - src/foobara/ai.rb
23
24
  - src/foobara/ai/answer_bot/ask.rb
24
25
  - src/foobara/ai/answer_bot/domain_mappers/anthropic_api/chat_to_create_message.rb
25
26
  - src/foobara/ai/answer_bot/domain_mappers/anthropic_api/message_result_to_answer.rb