foobara-ai 1.0.3 → 1.0.5

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: a394ba18a1ef53f37bfe3fd850907042103c0e50a34daac9faf4a2ecaab7b76d
4
- data.tar.gz: bcc1f6b814d116fe46e7ffbc7f427223e6040c3e53c12d84956f7830ef0a8c18
3
+ metadata.gz: 97027ea41c3a72b3bc242c6aeae9e91a4d8631320c1f43e5c42cc9830df2eb04
4
+ data.tar.gz: 7d991b95c1ea8cf2db63fb46934d3516b23c0271dd9f452b557032916ae8b14e
5
5
  SHA512:
6
- metadata.gz: 87174a0b4fb67958c07c5b783d985e3298507c64fc272fc5de3967a39edbd9f85fd3bc7fa6e5b322671f95ed90a11405c361821165c9f320091799f0a1de1b8a
7
- data.tar.gz: 639426e8589599c55b382ba7cbfeee0ffca83c993b3a057ed7eacfbf8d8fa64176e08cbae66fcf35a01c677df471aecd1f38b5c6ad8ac5fe902c3c5032a856d1
6
+ metadata.gz: 86b3ee6a3f145e2a76580cbd96ced441d4060083126f420334e08d51f27ce22cfaea96adeba1eb39970087132dca22beb6950a1e168b44ef641d1823f0df4f93
7
+ data.tar.gz: 18f3281c42615b4b4f5b4c6948fd36d323e07f3e0cb1afd8a451f4439d1f17c6c5885f796a24a12ed63320b0cf0c9e45a8d4bba256ebe3cad2b75d05f3eaa746
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.5] - 2026-09-22
2
+
3
+ - Fix generate next message domain mapper selection problems using domain-specific model_enum
4
+ - Make temperature optional/removed to deal with API changes/complications added to the API by Anthropic and OpenAI
5
+
6
+ ## [1.0.4] - 2025-11-10
7
+
8
+ - Allow disabling automatic loading of AI services
9
+
1
10
  ## [1.0.3] - 2025-10-30
2
11
 
3
12
  - Sort models by id instead of service,id for demo convenience
@@ -6,10 +6,13 @@ module Foobara
6
6
  module DomainMappers
7
7
  module AnthropicApi
8
8
  class ChatToCreateMessage < Foobara::DomainMapper
9
+ # TODO: why doesn't this have a model?
9
10
  from do
10
11
  chat Types::Chat, :required
11
- temperature :float
12
- model :model_enum
12
+ # NOTE: temperature is not supported by Anthropic these days and it is ignored
13
+ temperature :float, :allow_nil, "temperature is not supported by Anthropic these days and it is ignored"
14
+ # TODO: shouldn't this be in Types prefix??
15
+ model :"Foobara::Ai::AnthropicApi::model_enum"
13
16
  end
14
17
  to Foobara::Ai::AnthropicApi::CreateMessage
15
18
 
@@ -26,10 +29,6 @@ module Foobara
26
29
  inputs[:system] = system_messages.map(&:content).join("\n")
27
30
  end
28
31
 
29
- if temperature
30
- inputs[:temperature] = temperature
31
- end
32
-
33
32
  if model
34
33
  inputs[:model] = model
35
34
  end
@@ -41,10 +40,6 @@ module Foobara
41
40
  from[:chat]
42
41
  end
43
42
 
44
- def temperature
45
- from[:temperature]
46
- end
47
-
48
43
  def model
49
44
  from[:model]
50
45
  end
@@ -16,9 +16,9 @@ module Foobara
16
16
  return service if domain::Types::ModelEnum.value?(symbol)
17
17
  end
18
18
 
19
- # :nocov:
19
+ # simplecov:disable
20
20
  raise "Unknown model: #{model}"
21
- # :nocov:
21
+ # simplecov:enable
22
22
  end
23
23
 
24
24
  alias model from
@@ -8,8 +8,9 @@ module Foobara
8
8
  class ChatToGenerateChatCompletion < Foobara::DomainMapper
9
9
  from do
10
10
  chat Types::Chat, :required
11
- temperature :float
12
- model :model_enum
11
+ temperature :float, :allow_nil
12
+ # TODO: shouldn't this be in Types prefix??
13
+ model :"Foobara::Ai::OllamaApi::model_enum"
13
14
  end
14
15
  to Foobara::Ai::OllamaApi::GenerateChatCompletion
15
16
 
@@ -8,8 +8,12 @@ module Foobara
8
8
  class ChatToGenerateChatCompletion < Foobara::DomainMapper
9
9
  from do
10
10
  chat Types::Chat, :required
11
- temperature :float
12
- model :model_enum
11
+ # NOTE: ignoring temperature for now to prevent breakage
12
+ # TODO: either figure out a deterministic way to know if temperature should be dropped
13
+ # or a way to react to the error with a retry when it happens.
14
+ temperature :float, :allow_nil
15
+ # TODO: shouldn't this be in Types prefix??
16
+ model :"Foobara::Ai::OpenAiApi::model_enum"
13
17
  end
14
18
  to Foobara::Ai::OpenAiApi::CreateChatCompletion
15
19
 
@@ -20,11 +24,11 @@ module Foobara
20
24
  end
21
25
  }
22
26
 
23
- if temperature
24
- # NOTE: some models don't support temperature, like o1. Instead of possibly receiving an error
25
- # we will set the temperature to 1 which prevents a 400. Maybe print a warning instead?
26
- inputs[:temperature] = model_supports_temperature? ? temperature : 1
27
- end
27
+ # if temperature
28
+ # # NOTE: some models don't support temperature, like o1. Instead of possibly receiving an error
29
+ # # we will set the temperature to 1 which prevents a 400. Maybe print a warning instead?
30
+ # inputs[:temperature] = model_supports_temperature? ? temperature : 1
31
+ # end
28
32
 
29
33
  if model
30
34
  inputs[:model] = model
@@ -37,17 +41,17 @@ module Foobara
37
41
  from[:chat]
38
42
  end
39
43
 
40
- def temperature
41
- from[:temperature]
42
- end
44
+ # def temperature
45
+ # from[:temperature]
46
+ # end
43
47
 
44
48
  def model
45
49
  from[:model]
46
50
  end
47
51
 
48
- def model_supports_temperature?
49
- model && model.to_s !~ /\Ao[13](-|$)/
50
- end
52
+ # def model_supports_temperature?
53
+ # model && model.to_s !~ /\Ao[13](-|$)/
54
+ # end
51
55
  end
52
56
  end
53
57
  end
@@ -18,9 +18,9 @@ module Foobara
18
18
  when Types::ServiceEnum::OLLAMA
19
19
  Ai::OllamaApi::GenerateChatCompletion
20
20
  else
21
- # :nocov:
21
+ # simplecov:disable
22
22
  raise "Unknown service: #{service}"
23
- # :nocov:
23
+ # simplecov:enable
24
24
  end
25
25
  end
26
26
 
@@ -16,9 +16,9 @@ module Foobara
16
16
  when Types::ServiceEnum::OLLAMA
17
17
  Ai::OllamaApi::ListLocalModels
18
18
  else
19
- # :nocov:
19
+ # simplecov:disable
20
20
  raise "Unknown service: #{service}"
21
- # :nocov:
21
+ # simplecov:enable
22
22
  end
23
23
  end
24
24
 
@@ -8,7 +8,7 @@ module Foobara
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
10
  model :model_enum, default: Ai.default_llm_model, description: "The model to use."
11
- temperature :float
11
+ temperature :float, :allow_nil
12
12
  end
13
13
 
14
14
  result Types::Message
@@ -28,11 +28,11 @@ module Foobara
28
28
  # models = threads.each(&:join).map(&:value).flatten
29
29
 
30
30
  unless models.uniq == models
31
- # :nocov:
31
+ # simplecov:disable
32
32
  # TODO: we should return something more complicated than a bare list of strings. Either a more
33
33
  # robust object or prefix strings with the relevant service to handle collisions.
34
34
  raise "Duplicate models detected"
35
- # :nocov:
35
+ # simplecov:enable
36
36
  end
37
37
 
38
38
  ModelEnum = Foobara::Enumerated.make_module(models)
data/src/foobara/ai.rb CHANGED
@@ -32,18 +32,18 @@ module Foobara
32
32
  @ai_services[AnswerBot::Types::ServiceEnum::OLLAMA] = OllamaApi
33
33
  end
34
34
 
35
- if @ai_services.empty?
36
- # :nocov:
35
+ if @ai_services.empty? && ENV["SKIP_AI_SERVICES"] != "true"
36
+ # simplecov:disable
37
37
  require "foobara/anthropic_api"
38
38
  @ai_services = { AnswerBot::Types::ServiceEnum::ANTHROPIC => AnthropicApi }
39
- # :nocov:
39
+ # simplecov:enable
40
40
  end
41
41
 
42
42
  @ai_services
43
43
  end
44
44
 
45
45
  def default_llm_model
46
- @default_llm_model ||= installed_ai_services.values.first.default_llm_model
46
+ @default_llm_model ||= installed_ai_services&.values&.first&.default_llm_model
47
47
  end
48
48
  end
49
49
  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: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.6.9
75
+ rubygems_version: 4.0.20
76
76
  specification_version: 4
77
77
  summary: No description. Add one.
78
78
  test_files: []