summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2024-01-08 21:41:30 -0300
committericebaker <icebaker@proton.me>2024-01-08 21:41:30 -0300
commit31e53046bd35b83027f8a8e1ab99a6eceb4e6a3c (patch)
treed13179fb7eb91db4e70a97c96f24889b3153c451 /spec
parent819381e7bd3e3ca5d310ad0a29b6925dcfa26720 (diff)
adding support to markdown cartridges
Diffstat (limited to 'spec')
-rw-r--r--spec/data/cartridges/markdown.md37
-rw-r--r--spec/logic/cartridge/parser_spec.rb31
2 files changed, 68 insertions, 0 deletions
diff --git a/spec/data/cartridges/markdown.md b/spec/data/cartridges/markdown.md
new file mode 100644
index 0000000..cd50b7b
--- /dev/null
+++ b/spec/data/cartridges/markdown.md
@@ -0,0 +1,37 @@
+A cartridge is a YAML file with human-readable data that outlines the bot's goals, expected behaviors, and settings for authentication and provider utilization.
+
+We begin with the meta section, which provides information about what this cartridge is designed for:
+
+```yaml
+meta:
+ symbol: 🤖
+ name: ChatGPT 4 Turbo
+ author: icebaker
+ version: 0.0.1
+ license: CC0-1.0
+ description: A helpful assistant.
+```
+
+It includes details like versioning and license.
+
+Next, we add a behavior section that will provide the bot with a directive on how it should behave:
+
+```yaml
+behaviors:
+ interaction:
+ directive: You are a helpful assistant.
+```
+
+Now, we need to provide instructions on how this Nano Bot should connect with a provider, which credentials to use, and what specific configurations for the LLM are required:
+
+```yaml
+provider:
+ id: openai
+ credentials:
+ access-token: ENV/OPENAI_API_KEY
+ settings:
+ user: ENV/NANO_BOTS_END_USER
+ model: gpt-4-1106-preview
+```
+
+In my API, I have set the environment variables `OPENAI_API_KEY` and `NANO_BOTS_END_USER`, which is where the values for these will come from.
diff --git a/spec/logic/cartridge/parser_spec.rb b/spec/logic/cartridge/parser_spec.rb
new file mode 100644
index 0000000..f8d1302
--- /dev/null
+++ b/spec/logic/cartridge/parser_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require_relative '../../../logic/cartridge/parser'
+
+RSpec.describe NanoBot::Logic::Cartridge::Parser do
+ context 'markdown' 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'
+ }
+ } }
+ )
+ end
+ end
+end