納米機器人規範的實施,並支持人類的Claude,Cohere Command,Google Gemini,Maritaca aiSabiá,Mistral AI,Ollama,Ollama,Openai Chatgpt等,並支持通話工具(功能)。
gem install nano-bots -v 3.4.0nb - - eval " hello "
# => Hello! How may I assist you today? nb - - repl ?> Hi, how are you doing?
As an AI language model, I do not experience emotions but I am functioning
well. How can I assist you?
?> |
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
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-4o nb gpt.yml - eval " hi "
# => Hello! How can I assist you today? gem 'nano-bots' , '~> 3.4.0' require 'nano-bots'
bot = NanoBot . new ( cartridge : 'gpt.yml' )
bot . eval ( 'Hi!' ) do | content , fragment , finished , meta |
print fragment unless fragment . nil?
end
# => Hello! How can I assist you today?安裝GEM後, nb二進制命令將用於您的項目或系統。
用法的示例:
nb - - eval " hello "
# => Hello! How may I assist you today?
nb to-en-us-translator.yml - eval " Salut, comment ça va? "
# => Hello, how are you doing?
nb midjourney.yml - eval " happy cyberpunk robot "
# => A cheerful and fun-loving robot is dancing wildly amidst a
# futuristic and lively cityscape. Holographic advertisements
# and vibrant neon colors can be seen in the background.
nb lisp.yml - eval " (+ 1 2) "
# => 3
cat article.txt |
nb to-en-us-translator.yml - eval |
nb summarizer.yml - eval
# -> LLM stands for Large Language Model, which refers to an
# artificial intelligence algorithm capable of processing
# and understanding vast amounts of natural language data,
# allowing it to generate human-like responses and perform
# a range of language-related tasks. nb - - repl
nb assistant.yml - repl ?> Hi, how are you doing?
As an AI language model, I do not experience emotions but I am functioning
well. How can I assist you?
?> |
您可以通過輸入exit來退出重複。
上面的所有命令都是無狀態的。如果您想保留互動的歷史記錄,請用狀態-替換:
nb assistant.yml your-user eval " Salut, comment ça va? "
nb assistant.yml your-user repl
nb assistant.yml 6ea6c43c42a1c076b1e3c36fa349ac2c eval " Salut, comment ça va? "
nb assistant.yml 6ea6c43c42a1c076b1e3c36fa349ac2c repl您可以使用一個簡單的鍵,例如用戶名或隨機生成的鍵:
require 'securerandom'
SecureRandom . hex # => 6ea6c43c42a1c076b1e3c36fa349ac2cnb - - cartridge
nb cartridge.yml - cartridge
nb - STATE-KEY state
nb cartridge.yml STATE-KEY state將其用作庫:
require 'nano-bots/cli' # Equivalent to the `nb` command. require 'nano-bots'
NanoBot . cli # Equivalent to the `nb` command.
NanoBot . repl ( cartridge : 'cartridge.yml' ) # Starts a new REPL.
bot = NanoBot . new ( cartridge : 'cartridge.yml' )
bot = NanoBot . new (
cartridge : YAML . safe_load ( File . read ( 'cartridge.yml' ) , permitted_classes : [ Symbol ] )
)
bot = NanoBot . new (
cartridge : { ... } # Parsed Cartridge Hash
)
bot . eval ( 'Hello' )
bot . eval ( 'Hello' , as : 'eval' )
bot . eval ( 'Hello' , as : 'repl' )
# When stream is enabled and available:
bot . eval ( 'Hi!' ) do | content , fragment , finished , meta |
print fragment unless fragment . nil?
end
bot . repl # Starts a new REPL.
NanoBot . repl ( cartridge : 'cartridge.yml' , state : '6ea6c43c42a1c076b1e3c36fa349ac2c' )
bot = NanoBot . new ( cartridge : 'cartridge.yml' , state : '6ea6c43c42a1c076b1e3c36fa349ac2c' )
bot . prompt # => "?u001b[34m> u001b[0m"
bot . boot
bot . boot ( as : 'eval' )
bot . boot ( as : 'repl' )
bot . boot do | content , fragment , finished , meta |
print fragment unless fragment . nil?
end 要在系統上安裝CLI:
gem install nano-bots -v 3.4.0要在Ruby Project作為庫中使用它,請添加到您的Gemfile :
gem 'nano-bots' , '~> 3.4.0' bundle install對於憑據和配置,可以在.bashrc , .zshrc或等效文件以及Docker容器或系統環境中設置相關的環境變量。例子:
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
export NANO_BOTS_END_USER=your-user
# export NANO_BOTS_STATE_PATH=/home/user/.local/state/nano-bots
# export NANO_BOTS_CARTRIDGES_PATH=/home/user/.local/share/nano-bots/cartridges另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
NANO_BOTS_END_USER=your-user
# NANO_BOTS_STATE_PATH=/home/user/.local/state/nano-bots
# NANO_BOTS_CARTRIDGES_PATH=/home/user/.local/share/nano-bots/cartridges您可以在人類游戲機上獲得憑據。
export ANTHROPIC_API_KEY=your-api-key另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
ANTHROPIC_API_KEY=your-api-key創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : anthropic
credentials :
api-key : ENV/ANTHROPIC_API_KEY
settings :
model : claude-3-5-sonnet-20240620
max_tokens : 4096閱讀人類克勞德(Claude)的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )您可以在Cohere平台上獲得憑據。
export COHERE_API_KEY=your-api-key另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
COHERE_API_KEY=your-api-key創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : cohere
credentials :
api-key : ENV/COHERE_API_KEY
settings :
model : command閱讀Cohere命令的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )您可以在Maritalk獲取API鍵。
使用環境變量在API密鑰中使用$字符的問題時,將憑據包裝在單個引號中:
export MARITACA_API_KEY= ' 123...$a12... '另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
MARITACA_API_KEY= ' 123...$a12... '創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : maritaca
credentials :
api-key : ENV/MARITACA_API_KEY
settings :
model : sabia-2-medium閱讀Mistral AI的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )您可以在Mistral平台上獲得憑據。
export MISTRAL_API_KEY=your-api-key另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
MISTRAL_API_KEY=your-api-key創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : mistral
credentials :
api-key : ENV/MISTRAL_API_KEY
settings :
model : mistral-medium-latest閱讀Mistral AI的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )要安裝並設置,請按照Ollama網站上的說明進行操作。
export OLLAMA_API_ADDRESS=http://localhost:11434另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
OLLAMA_API_ADDRESS=http://localhost:11434創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : ollama
credentials :
address : ENV/OLLAMA_API_ADDRESS
settings :
model : llama3閱讀Ollama的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )您可以在OpenAI平台上獲得憑據。
export OPENAI_API_KEY=your-access-token另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
OPENAI_API_KEY=your-access-token創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
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-4o閱讀Openai Chatgpt的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' )單擊此處了解如何獲得您的憑據。
export GOOGLE_API_KEY=your-api-key另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
GOOGLE_API_KEY=your-api-key創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : google
credentials :
service : generative-language-api
api-key : ENV/GOOGLE_API_KEY
options :
model : gemini-pro閱讀Google Gemini的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' ) export GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
export GOOGLE_REGION=us-east4另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
GOOGLE_REGION=us-east4創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : google
credentials :
service : vertex-ai-api
file-path : ENV/GOOGLE_CREDENTIALS_FILE_PATH
region : ENV/GOOGLE_REGION
options :
model : gemini-pro閱讀Google Gemini的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' ) export GOOGLE_REGION=us-east4另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
GOOGLE_REGION=us-east4創建一個cartridge.yml文件:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
license : CC0-1.0
description : A helpful assistant.
behaviors :
interaction :
directive : You are a helpful assistant.
provider :
id : google
credentials :
service : vertex-ai-api
region : ENV/GOOGLE_REGION
options :
model : gemini-pro閱讀Google Gemini的完整規範。
nb cartridge.yml - eval " Hello "
nb cartridge.yml - repl bot = NanoBot . new ( cartridge : 'cartridge.yml' )
puts bot . eval ( 'Hello' ) 如果您需要手動設置Google項目ID:
export GOOGLE_PROJECT_ID=your-project-id另外,如果您的當前目錄具有帶有環境變量的.env文件,則將自動加載它們:
GOOGLE_PROJECT_ID=your-project-id添加到您的cartridge.yml文件:
---
provider :
id : google
credentials :
project-id : ENV/GOOGLE_PROJECT_ID 檢查納米機器人規範,以了解有關如何構建墨盒的更多信息。
嘗試使用Nano Bots診所(Live Editor)學習有關創建墨盒的知識。
這是納米機器人墨盒的樣子:
---
meta :
symbol : ?
name : Nano Bot Name
author : Your Name
version : 1.0.0
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-4o納米機器人也可以由工具(功能)提供動力:
---
tools :
- name : random-number
description : Generates a random number between 1 and 100.
fennel : |
(math.random 1 100) ?> please generate a random number
random-number {} [yN] y
random-number {}
59
The randomly generated number is 59.
?> |
要成功使用工具(功能),您需要指定一個提供者和支持它們的模型。在撰寫此讀數時,支持他們的提供商是OpenAI,Models gpt-3.5-turbo-1106和gpt-4o以及Google,以及vertex-ai-api服務和模型gemini-pro 。其他提供商尚無支持。
檢查納米機器人規範以了解有關工具(功能)的更多信息。
我們正在通過Graalvm提供動力的Babashka探索Clojure的使用。
使用clojure: key:
---
clojure : |
(-> (java.time.ZonedDateTime/now)
(.format (java.time.format.DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm"))
(clojure.string/trimr))與Lua和Fennel不同,Clojure支持並未嵌入此實現中。它依賴於在納米機器人運行的環境中提供Babashka二進制( bb )。
這是安裝Babashka的方法:
curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | sudo bash這是一項快速檢查,以確保其可用並有效:
bb -e ' {:hello "world"} '
# => {:hello "world"}我們沒有用於Clojure的沙盒支持;這意味著您需要禁用它才能運行Clojure代碼,這是您自負的風險:
---
safety :
functions :
sandboxed : false您可以探索納米機器人市場,以發現可以幫助您的新墨盒。
每個提供商都會有自己的安全和隱私政策(例如OpenAI政策),因此您必須諮詢它們以了解其含義。
默認情況下,存儲在您本地磁盤中的所有狀態均已加密。
為了確保加密是安全的,您需要通過NANO_BOTS_ENCRYPTION_PASSWORD環境變量定義密碼。否則,儘管內容將被加密,但任何人都可以在沒有密碼的情況下解密它。
重要的是要注意,儘管通過安全連接(例如HTTP)傳輸了與提供商共享的內容,但提供商將可以閱讀。這是因為提供商需要在數據上操作,如果內容已超過HTTPS,則不可能。因此,將本地存儲在系統上的數據加密,這並不意味著您與提供商共享的數據將無法被它們讀取。
為了確保正確配置您的加密和密碼,您可以運行以下命令:
nb security應該返回:
✅ Encryption is enabled and properly working.
This means that your data is stored in an encrypted format on your disk.
✅ A password is being used for the encrypted content.
This means that only those who possess the password can decrypt your data.
或者,您可以在運行時檢查以下方式:
require 'nano-bots'
NanoBot . security . check
# => { encryption: true, password: true }通過API或自動化向多個用戶部署納米機器人的常見策略是為每個用戶分配一個唯一的最終用戶ID。如果您的任何用戶由於虐待行為違反了提供者的政策,這將很有用。通過提供最終用戶ID,您可以解開即使起源於API密鑰的活動,採取的動作不是您自己的。
您可以通過以下方式定義自定義最終用戶標識符:
NanoBot . new ( environment : { NANO_BOTS_END_USER : 'custom-user-a' } )
NanoBot . new ( environment : { NANO_BOTS_END_USER : 'custom-user-b' } )認為您在環境中具有以下最終用戶標識符:
NANO_BOTS_END_USER=your-name或墨盒中的配置:
---
provider :
id : openai
settings :
user : your-name請求將如下執行:
NanoBot . new ( cartridge : '-' )
# { user: 'your-name' }
NanoBot . new ( cartridge : '-' , environment : { NANO_BOTS_END_USER : 'custom-user-a' } )
# { user: 'custom-user-a' }
NanoBot . new ( cartridge : '-' , environment : { NANO_BOTS_END_USER : 'custom-user-b' } )
# { user: 'custom-user-b' }實際上,為了增強隱私,您的用戶和用戶的標識符都不會以這種方式共享。相反,它們將在與提供商共享之前進行加密:
'your-name'
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==
'custom-user-a'
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=
'custom-user-b'
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=通過這種方式,如果需要,您擁有標識符,但是,他們的實際內容只能通過您的安全密碼( NANO_BOTS_ENCRYPTION_PASSWORD )解密。
要解密您的加密數據,一旦您正確配置了密碼,就可以簡單地運行:
require 'nano-bots'
NanoBot . security . decrypt ( '_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==' )
# your-name
NanoBot . security . decrypt ( '_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=' )
# custom-user-a
NanoBot . security . decrypt ( '_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=' )
# custom-user-b如果丟失密碼,則會丟失數據。根本不可能恢復它。真正的。
01.AI YI,LMSYS VICUNA,META LLAMA和WIZARDLM是通過Ollama支持的開源車型。
克隆存儲庫並複制Docker組成模板:
git clone https://github.com/icebaker/ruby-nano-bots.git
cd ruby-nano-bots
cp docker-compose.example.yml docker-compose.yml
設置您的提供商憑據,並為墨盒文件選擇所需的路徑:
---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
ANTHROPIC_API_KEY : your-api-key
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
COHERE_API_KEY : your-api-key
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
MARITACA_API_KEY : your-api-key
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
MISTRAL_API_KEY : your-api-key
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots請記住,默認情況下,您的localhost是從內部Docker無法訪問的。您需要根據Ollama Server運行的位置和您的首選項來建立跨域網絡,使用主機的地址或使用主機網絡。
---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
OLLAMA_API_ADDRESS : http://localhost:11434
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots
# If you are running the Ollama server on your localhost:
network_mode : host # WARNING: Be careful, this may be a security risk.---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
OPENAI_API_KEY : your-access-token
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
GOOGLE_API_KEY : your-api-key
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots ---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
GOOGLE_CREDENTIALS_FILE_PATH : /root/.config/google-credentials.json
GOOGLE_REGION : us-east4
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./google-credentials.json:/root/.config/google-credentials.json
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots ---
services :
nano-bots :
image : ruby:3.3.3-slim-bookworm
command : sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 3.4.0 && bash"
environment :
GOOGLE_REGION : us-east4
NANO_BOTS_ENCRYPTION_PASSWORD : UNSAFE
NANO_BOTS_END_USER : your-user
volumes :
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
- ./your-state-path:/root/.local/state/nano-bots 如果您需要手動設置Google項目ID:
environment :
GOOGLE_PROJECT_ID=your-project-id輸入容器:
docker compose run nano-bots開始播放:
nb - - eval " hello "
nb - - repl
nb assistant.yml - eval " hello "
nb assistant.yml - repl您可以通過輸入exit來退出重複。
bundle
rubocop -A
rspec
bundle exec ruby spec/tasks/run-all-models.rb
bundle exec ruby spec/tasks/run-model.rb spec/data/cartridges/models/openai/gpt-4-turbo.yml
bundle exec ruby spec/tasks/run-model.rb spec/data/cartridges/models/openai/gpt-4-turbo.yml stream如果您面臨升級的寶石版本:
bundle install --full-indexgem build nano-bots.gemspec
gem signin
gem push nano-bots-3.4.0.gem