diff options
author | icebaker <icebaker@proton.me> | 2023-11-19 13:35:54 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2023-11-19 13:35:54 -0300 |
commit | e89a1d57c49c94c16c37a8ee3a69b52a9e2b341b (patch) | |
tree | e82a7579534003f02de32d058f4a60d1d076240c /spec/logic | |
parent | c470d63b169058d81f44569a5f1c4c1fb222279f (diff) |
improving tool specifications
Diffstat (limited to 'spec/logic')
-rw-r--r-- | spec/logic/cartridge/tools_spec.rb | 58 | ||||
-rw-r--r-- | spec/logic/providers/openai/tools_spec.rb | 24 |
2 files changed, 45 insertions, 37 deletions
diff --git a/spec/logic/cartridge/tools_spec.rb b/spec/logic/cartridge/tools_spec.rb index 42b8c57..913fa62 100644 --- a/spec/logic/cartridge/tools_spec.rb +++ b/spec/logic/cartridge/tools_spec.rb @@ -10,11 +10,11 @@ RSpec.describe NanoBot::Logic::Cartridge::Tools do let(:cartridge) { {} } it 'uses default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(true) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(false) end end @@ -24,11 +24,11 @@ RSpec.describe NanoBot::Logic::Cartridge::Tools do end it 'overrides default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(false) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(false) end end @@ -38,59 +38,59 @@ RSpec.describe NanoBot::Logic::Cartridge::Tools do end it 'overrides default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(true) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(true) end end context 'top-level-specific overrides' do let(:cartridge) do - { interfaces: { tools: { call: { feedback: false }, response: { feedback: true } } } } + { interfaces: { tools: { executing: { feedback: false }, responding: { feedback: true } } } } end it 'overrides default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(false) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(true) end end context 'repl interface overrides' do let(:cartridge) do { interfaces: { - tools: { call: { feedback: false }, response: { feedback: true } }, - repl: { tools: { call: { feedback: true }, response: { feedback: false } } } + tools: { executing: { feedback: false }, responding: { feedback: true } }, + repl: { tools: { executing: { feedback: true }, responding: { feedback: false } } } } } end it 'overrides default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(false) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(true) end end context 'eval interface overrides' do let(:cartridge) do { interfaces: { - tools: { call: { feedback: false }, response: { feedback: true } }, - eval: { tools: { call: { feedback: true }, response: { feedback: false } } } + tools: { executing: { feedback: false }, responding: { feedback: true } }, + eval: { tools: { executing: { feedback: true }, responding: { feedback: false } } } } } end it 'overrides default values when appropriate' do - expect(described_class.feedback?(cartridge, :repl, :call)).to be(false) - expect(described_class.feedback?(cartridge, :eval, :call)).to be(true) + expect(described_class.feedback?(cartridge, :repl, :executing)).to be(false) + expect(described_class.feedback?(cartridge, :eval, :executing)).to be(true) - expect(described_class.feedback?(cartridge, :repl, :response)).to be(true) - expect(described_class.feedback?(cartridge, :eval, :response)).to be(false) + expect(described_class.feedback?(cartridge, :repl, :responding)).to be(true) + expect(described_class.feedback?(cartridge, :eval, :responding)).to be(false) end end end diff --git a/spec/logic/providers/openai/tools_spec.rb b/spec/logic/providers/openai/tools_spec.rb index c92c374..1758e5f 100644 --- a/spec/logic/providers/openai/tools_spec.rb +++ b/spec/logic/providers/openai/tools_spec.rb @@ -13,14 +13,16 @@ RSpec.describe NanoBot::Logic::OpenAI::Tools do expect(described_class.adapt(cartridge[:tools][0])).to eq( { type: 'function', function: { - name: 'get-current-weather', - description: 'Get the current weather in a given location.', + name: 'what-time-is-it', + description: 'Returns the current date and time for a given timezone.', parameters: { type: 'object', properties: { - location: { type: 'string' }, - unit: { type: 'string' } - } + timezone: { + type: 'string', + description: 'A string representing the timezone that should be used to provide a datetime, following the IANA (Internet Assigned Numbers Authority) Time Zone Database. Examples are "Asia/Tokyo" and "Europe/Paris".' + } + }, required: ['timezone'] } } } ) @@ -28,9 +30,15 @@ RSpec.describe NanoBot::Logic::OpenAI::Tools do expect(described_class.adapt(cartridge[:tools][1])).to eq( { type: 'function', function: { - name: 'what-time-is-it', - description: 'Returns the current date and time.', - parameters: { properties: {}, type: 'object' } + name: 'get-current-weather', + description: 'Get the current weather in a given location.', + parameters: { + type: 'object', + properties: { + location: { type: 'string' }, + unit: { type: 'string' } + } + } } } ) |