diff options
author | icebaker <icebaker@proton.me> | 2024-01-10 20:05:48 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2024-01-10 20:05:48 -0300 |
commit | 3dc22548895718ffc7396227267ecbb4902b62f9 (patch) | |
tree | d19984eef953a2cd1e57c6fd51a73f2bcbb77541 /spec/logic/cartridge | |
parent | a36604d266cb019311cdf67110596a16986a0fff (diff) |
improving markdown parser
Diffstat (limited to 'spec/logic/cartridge')
-rw-r--r-- | spec/logic/cartridge/parser_spec.rb | 106 |
1 files changed, 85 insertions, 21 deletions
diff --git a/spec/logic/cartridge/parser_spec.rb b/spec/logic/cartridge/parser_spec.rb index f8d1302..e8bac0b 100644 --- a/spec/logic/cartridge/parser_spec.rb +++ b/spec/logic/cartridge/parser_spec.rb @@ -4,28 +4,92 @@ require_relative '../../../logic/cartridge/parser' RSpec.describe NanoBot::Logic::Cartridge::Parser do context 'markdown' do - let(:raw) { File.read('spec/data/cartridges/markdown.md') } + context 'default' do + let(:raw) { File.read('spec/data/cartridges/markdown.md') } - it 'parses markdown cartridge' do - expect(described_class.parse(raw, format: 'md')).to eq( - { meta: { - symbol: '🤖', - name: 'ChatGPT 4 Turbo', - author: 'icebaker', - version: '0.0.1', - license: 'CC0-1.0', - description: 'A helpful assistant.' - }, - behaviors: { interaction: { directive: 'You are a helpful assistant.' } }, - provider: { - id: 'openai', - credentials: { 'access-token': 'ENV/OPENAI_API_KEY' }, - settings: { - user: 'ENV/NANO_BOTS_END_USER', - model: 'gpt-4-1106-preview' - } - } } - ) + it 'parses markdown cartridge' do + expect(described_class.parse(raw, format: 'md')).to eq( + { meta: { + symbol: '🤖', + name: 'ChatGPT 4 Turbo', + author: 'icebaker', + version: '0.0.1', + license: 'CC0-1.0', + description: 'A helpful assistant.' + }, + behaviors: { interaction: { directive: 'You are a helpful assistant.' } }, + provider: { + id: 'openai', + credentials: { 'access-token': 'ENV/OPENAI_API_KEY' }, + settings: { + user: 'ENV/NANO_BOTS_END_USER', + model: 'gpt-4-1106-preview' + } + } } + ) + end + end + + context 'tools' do + let(:raw) { File.read('spec/data/cartridges/tools.md') } + + it 'parses markdown cartridge' do + expect(described_class.parse(raw, format: 'md')).to eq( + { meta: { + symbol: '🕛', + name: 'Date and Time', + author: 'icebaker', + version: '0.0.1', + license: 'CC0-1.0', + description: 'A helpful assistant.' + }, + behaviors: { + interaction: { + directive: 'You are a helpful assistant.' + } + }, + provider: { + id: 'openai', + credentials: { 'access-token': 'ENV/OPENAI_API_KEY' }, + settings: { + user: 'ENV/NANO_BOTS_END_USER', + model: 'gpt-4-1106-preview' + } + }, + tools: [ + { name: 'random-number', + description: 'Generates a random number within a given range.', + parameters: { + type: 'object', + properties: { + from: { + type: 'integer', + description: 'The minimum expected number for random generation.' + }, + to: { + type: 'integer', + description: 'The maximum expected number for random generation.' + } + }, + required: %w[from to] + }, + clojure: "(let [{:strs [from to]} parameters]\n (+ from (rand-int (+ 1 (- to from)))))\n" }, + { name: 'date-and-time', + description: 'Returns the current date and time.', + fennel: "(os.date)\n" } + ] } + ) + end + end + + context 'block' do + let(:raw) { File.read('spec/data/cartridges/block.md') } + + it 'parses markdown cartridge' do + expect(described_class.parse(raw, format: 'md')).to eq( + { safety: { functions: { sandboxed: false } } } + ) + end end end end |