納米應用程序是可以嵌入納米機器人的微小應用。就像人類可以通過訪問扳手,計算器,屏幕讀取器或Internet訪問等工具來擴大其功能一樣,納米機器人可以在配備Nano應用程序時增強其功能。
納米應用程序可以用LUA,茴香或Clojure編寫。該特定的存儲庫選擇將Clojure用於其納米應用程序。
然後安裝並設置Nano Bots CLI和Babashka,然後:
git clone https://github.com/gbaptista/nano-apps.git
cd nano-apps
bb tasks/generate-cartridge.clj cartridges/template.yml cartridge.yml
# Cartridge successfully generated at cartridge.yml
nb cartridge.yml - repl ?> What day of the week is it today?
date-and-time {}
{:date-time 2023-12-02T14:19:18-03:00, :timezone America/Sao_Paulo}
Today is Saturday.
?> |
您可以通過輸入exit來退出重複。
為算術和符號數學提供GNU八度,包括基本操作以及復雜的計算,例如衍生物和積分。
安裝GNU八度:
sudo pacman -S octave # Arch / Manjaro
sudo apt-get install octave # Debian / Ubuntu / Raspberry Pi OS
sudo dnf install octave # Fedora / CentOS / RHEL安裝後,您需要安裝symbolic軟件包: pkg install -forge symbolic
octave GNU Octave, version 6.4.0
octave:1> pkg install -forge symbolic
For information about changes from previous versions of the symbolic package, run 'news symbolic'.
octave:2>
派生式例子:
?> What is the derivative of the function f(x) = 3x^2 + 5x + 2 with respect to x?
advanced-calculator {"expression":"syms x; diff(3*x^2 + 5*x + 2)"}
Symbolic pkg v3.1.1: Python communication link active, SymPy v1.11.1.
ans = (sym) 6⋅x + 5
The derivative of the function f(x) = 3x^2 + 5x + 2 with respect to x is 6x + 5.
?> Find the derivative of the function g(x) = e^(2x) – cos(x) with respect to x.
advanced-calculator {"expression":"syms x; diff(exp(2*x) - cos(x))"}
Symbolic pkg v3.1.1: Python communication link active, SymPy v1.11.1.
ans = (sym)
2⋅x
2⋅ℯ + sin(x)
The derivative of the function g(x) = e^(2x) – cos(x) with respect to x is 2e^(2x) + sin(x).
?> |
整體示例:
?> What is the indefinite integral of the function f(x) = 1/(x^2 + 1) with respect to x?
advanced-calculator {"expression":"syms x; int(1/(x^2 + 1))"}
Symbolic pkg v3.1.1: Python communication link active, SymPy v1.11.1.
ans = (sym) atan(x)
The indefinite integral of the function f(x) = 1/(x^2 + 1) with respect to x is atan(x) + C,
where C is the constant of integration.
?> Calculate the definite integral of g(x) from x = 0 to x = pi of g(x) = sin^2(x).
advanced-calculator {"expression":"syms x; int(sin(x)^2, 0, pi)"}
Symbolic pkg v3.1.1: Python communication link active, SymPy v1.11.1.
ans = (sym)
π
─
2
The definite integral of g(x) = sin^2(x) from x = 0 to x = pi is pi/2.
?> |
提供對時鐘的基本訪問,從而允許納米機器人訪問日期和時間。
示例:
?> What time is it?
date-and-time {}
{:date-time 2023-12-02T12:22:01-03:00, :timezone America/Sao_Paulo}
The current time is 12:22:01 PM in the timezone America/Sao Paulo.
?> What day of the week is it today?
Today is Saturday.
?> |
提供用於控制實現MPRIS D-BUS接口規範的媒體播放器的PlayerCTL。
安裝plasterctl:
sudo pacman -S playerctl # Arch / Manjaro
sudo apt-get install playerctl # Debian / Ubuntu / Raspberry Pi OS
sudo dnf install playerctl # Fedora / CentOS / RHEL示例:
?> which players do i have?
media-player-control {"command":"list"}
chromium.instance12231
plasma-browser-integration
You have two media players available for control:
1. Chromium, with an instance ID of 12231.
2. Plasma Browser Integration.
These players can be controlled with play, pause,
stop, and various other media control commands.
?> what's playing on plasma?
media-player-control {"command":"metadata","player":"plasma-browser-integration"}
plasma-browser-integration kde:mediaSrc blob:https://www.youtube.com/9c1414f1-5ae7-43d3-a7e2-45f519cdb0a9
plasma-browser-integration kde:pid 12231
plasma-browser-integration mpris:artUrl https://i.ytimg.com/vi/1JNmz17gnMw/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDr0ppBmCZeRzvIfsuDAY7BxKYeBQ
plasma-browser-integration mpris:length 350041000
plasma-browser-integration mpris:trackid '/org/kde/plasma/browser_integration/1337'
plasma-browser-integration xesam:artist Polyphia
plasma-browser-integration xesam:title Polyphia - Ego Death feat. Steve Vai (Official Music Video)
plasma-browser-integration xesam:url https://www.youtube.com/watch?v=1JNmz17gnMw
Currently, on Plasma Browser Integration, the track
"Ego Death" by Polyphia featuring Steve Vai is playing.
This is the official music video on YouTube.
The artwork for the track is available as well, which
you would recognize from the video thumbnail on YouTube.
?> pause the song
media-player-control {"command":"pause","player":"plasma-browser-integration"}
The song has been paused on Plasma Browser Integration.
If you wish to resume playback, just let me know!
?> resume playing
media-player-control {"command":"play","player":"plasma-browser-integration"}
The song is now playing again on Plasma Browser Integration.
Enjoy the music!
?> go back to the beginning of the song
media-player-control {"command":"position","player":"plasma-browser-integration","option":"0"}
I've reset the song to the beginning for you.
?> turn up the volume to the maximum
media-player-control {"command":"volume","player":"plasma-browser-integration","option":"1.0"}
?> |
它提供了生成隨機數的功能。
示例:
?> Choose a random number.
random-number {"from":1,"to":100}
53
The random number chosen is 53.
?> I would like a random number between 350 and 480.
random-number {"from":350,"to":480}
382
The random number chosen between 350 and 480 is 382.
?> |
☠️警告:這個納米應用程序可能會在系統上執行危險和破壞性操作;小心。
通過執行Shell命令,類似於Linux終端中使用的方法,提供了一種與計算機系統和數據進行交互的方法。它可以將命令發送到軟件,提取信息並執行各種操作。
示例:
?> How much space do I have on my disk?
sh {"command":["df","-h","--output=avail","/"]}
Avail
478G
You have 478 GB of available space on your disk.
?> How many cores does my CPU have?
sh {"command":["nproc"]}
8
Your CPU has 8 cores.
?> Am I connected to the Internet?
sh {"command":["ping","-c","1","8.8.8.8"]}
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=16.1 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 16.126/16.126/16.126/0.000 ms
Yes, you are connected to the Internet. I successfully pinged the
IP address 8.8.8.8 (Google's DNS server) and received a response.
?> |
提供GNU BC進行算術計算。它可以以任意精度處理加法,減法,乘法,分裂和模量操作以及指示和各種功能。
安裝GNU BC:
sudo pacman -S bc # Arch / Manjaro
sudo apt-get install bc # Debian / Ubuntu / Raspberry Pi OS
sudo dnf install bc # Fedora / CentOS / RHEL示例:
?> How much is 10 plus 15?
simple-calculator {"expression":"10+15"}
25
10 plus 15 equals 25.
?> What is the remainder when dividing 28 by 6?
simple-calculator {"expression":"28 % 6"}
4
The remainder when dividing 28 by 6 is 4.
?> Calculate if 3 is less than 4.
simple-calculator {"expression":"3<4"}
1
The calculation confirms that 3 is less than 4.
?> What is 3 divided by 2?
simple-calculator {"expression":"scale=1; 3/2"}
1.5
3 divided by 2 equals 1.5.
?> |
提供來自wttr.in的天氣預報和當前狀況,包括溫度,風速和濕度。它還提供了天文數據,例如日出和日落的時代,以及有關月球的細節。
示例:
?> What's the current temperature in New York?
weather {"location":"New York"}
{:current_condition [{:FeelsLikeC 4, :windspeedMiles...
The current temperature in New York is 6°C (43°F).
?> Tell me about the moon in Cairo today.
weather {"location":"Cairo"}
{:current_condition [{:FeelsLikeC 25, :windspeedMiles...
In Cairo today, the moon is in a Waning Gibbous phase with 79% illumination.
Moonrise is at 9:30 PM and moonset is at 10:57 AM (local time).
?> Should I wear sunglasses or carry an umbrella in Rome today?
weather {"location":"Rome"}
{:current_condition [{:FeelsLikeC 12, :windspeedMiles...
You should wear sunglasses in Rome today, as the weather is partly cloudy with
a 0.0 mm precipitation forecast, indicating no need for an umbrella.
?> What's the likelihood of me seeing a rainbow this afternoon in Rio de Janeiro?
weather {"location":"Rio de Janeiro"}
{:current_condition [{:FeelsLikeC 29, :windspeedMiles...
The likelihood of seeing a rainbow this afternoon in Rio de Janeiro is
low as the weather is partly cloudy with no precipitation reported.
Rainbows typically require rain combined with sunshine.
?> Is it a good day for kite flying in Sydney based on wind conditions?
weather {"location":"Sydney"}
{:current_condition [{:FeelsLikeC 18, :windspeedMiles...
Yes, it's a good day for kite flying in Sydney.
The weather is clear with wind speeds of 9 km/h (6 miles per hour).
?> |
只需複制並粘貼任何類似於您要做的事情的內部/apps程序夾即可。結構是:
app.clj :Nano App源代碼。specification.yml :nano bot的納米應用規範。test.clj :納米應用程序的測試。此外:
README.md :不使用其他地方的人類的讀書文件,只是為了增強此讀數。從基本模板中,生成帶有所有納米應用的墨盒:
bb tasks/generate-cartridge.clj [CARTRIDGE-TEMPLATE] [OUTPUT-FILE]
# If you don't want to include your private Nano Apps:
bb tasks/generate-cartridge.clj [CARTRIDGE-TEMPLATE] [OUTPUT-FILE] --no-private
bb tasks/generate-cartridge.clj cartridges/template.yml cartridge.yml
# => cartridge.yml
bb tasks/generate-cartridge.clj cartridges/template.yml cartridge.yml --no-private
# => cartridge.yml產生墨盒後,考慮到您擁有納米機器人CLI,您可以立即嘗試:
nb cartridge.yml - repl
?> what time is it?
date-and-time {}
{:date-time 2023-12-02T14:10:05Z, :timezone UTC}
The current time in UTC is 14:10:05 on December 2, 2023.
?> |
您可以通過輸入exit來退出重複。
運行所有測試:
bb tasks/run-tests.clj運行單個測試:
bb apps/simple-calculator/test.clj運行所有測試,不包括私人納米應用程序:
bb tasks/run-tests.clj --no-private 更新template.md文件,然後:
bb tasks/generate-readme.clj template.md更改時自動更新README.md的技巧:
sudo pacman -S inotify-tools # Arch / Manjaro
sudo apt-get install inotify-tools # Debian / Ubuntu / Raspberry Pi OS
sudo dnf install inotify-tools # Fedora / CentOS / RHEL
while inotifywait -e modify -e create template.md apps/ * /README.md ; do bb tasks/generate-readme.clj ; doneMarkdown Live Preview的技巧:
pip install -U markdown_live_preview
mlp README.md -p 8076bb tasks/cljfmt-fix.clj您可以通過使用模式user@app :創建不會致力於存儲庫的私有納米應用程序:
apps/your-name@your-app/app.clj
私人墨盒模板也是如此:
cartridges/[email protected]
您可以從墨盒一代中排除私人納米應用程序:
bb tasks/generate-cartridge.clj cartridges/template.yml cartridge.yml --no-private運行所有測試,不包括私人納米應用程序:
bb tasks/run-tests.clj --no-private 納米應用程序設計為納米機器人的一部分,因此熟悉納米機器人的規範和原理很重要:納米機器人規範
納米應用程序僅與AI提供商利用它的能力一樣好。因此,作為核心原則,您了解的有關及時工程的所有知識都應考慮並應用於納米應用程序的開發,尤其是在編寫其規格時:
有時,您可能會覺得“這太複雜”或“它將沒有用”或“為什麼會使用此功能”等。您可能會驚訝於模型使用Nano Apps的創意方式。
對於具體的示例,媒體播放器控件具有您認為不值得提供的命令。但是,如果您花一些時間玩耍,您將有許多“哇”時刻,即模型如何實現您的需求。
因此,給它富有創造力和探索的空間,不要僅僅因為您感到不確定而堅持功能。
儘管LLM越來越有能力處理大量數據,但在代幣方面,我們需要考慮以下幾點:
避免提供不必要的冗長輸出;抓住機會使您的產出簡潔。在構建納米應用程序查詢數據庫或運行命令時,請小心,因為它們可能會產生冗長的輸出。
當使用Nano應用程序作為流行軟件的代理時,請確保輸出忠實於實際軟件。當輸出完全對程序的期望時,模型理由更好。
例如,如果您的Nano應用程序是GNU八度軟件的代理,則操作的預期輸出將為:
ans = 6
縮短其僅返回6而不是ans = 6可能很容易。不要那樣做;保持原始輸出,因為這是模型在培訓期間學會的期望。
保持錯誤簡潔(簡潔的輸出)和有幫助的(及時工程)。
當使用Nano Apps作為流行軟件的代理時,請優先分配軟件的原始錯誤輸出(輸出保真度)。一些軟件會生成冗長的錯誤堆棧跟踪。在這種情況下,最好提供替代性自定義短消息或限制輸出大小而不犧牲必要的細節。平衡輸出保真度與簡潔的輸出。
返回()作為函數的輸出可能會導致OpenAI模型要求再次運行該功能,並可能導致無限循環。
這是一個實驗性的早期項目。納米應用程序可能很危險,因此請務必謹慎嘗試構建的內容;他們可以在您的計算機上執行破壞性動作。另外,請注意您的預算:確保您使用的任何提供商監視和預算。納米應用程序可能會產生意外的內容或無限/太長的循環,這可能會導致您的成本飆升。
該軟件是根據MIT許可分發的,其中包括保修免責聲明。此外,作者對使用該實驗性早期項目可能產生的任何損害或成本不承擔任何責任。使用納米應用程序自行風險。