Nanoアプリは、Nanoボットに埋め込むことができる小さなアプリケーションです。人間がレンチ、電卓、スクリーンリーダー、インターネットアクセスなどのツールへのアクセスで機能を増幅できるように、NANOボットはNANOアプリを装備したときに機能を強化できます。
Nanoアプリは、Lua、Fennel、またはClojureで記述できます。この特定のリポジトリは、Nanoアプリに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を入力することでREPLを終了できます。
基本的な操作や導関数や積分などの複雑な計算を含む、算術および象徴的な数学に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を提供します。
playerctlのインストール:
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.
?> |
「警告:このNanoアプリは、システムで危険で破壊的な操作を実行する場合があります。それに注意してください。
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アプリソースコード。specification.yml :NANOボットのNANOアプリ仕様。test.clj :NANOアプリのテスト。さらに:
README.md :このreadmeを強化するためだけに、他の場所では使用されていない人間のためのreadme。ベーステンプレートから、すべてのNANOアプリを含むカートリッジを生成します。
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を入力することでREPLを終了できます。
すべてのテストの実行:
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 ; doneマークダウンライブプレビューのトリック:
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 NanoアプリはNano Botsの一部として設計されているため、Nano Botsの仕様と原則に精通することが重要です:Nano Bots仕様
Nanoアプリは、AIプロバイダーがそれを活用する機能と同じくらい優れています。したがって、核となる原則として、迅速なエンジニアリングについて学んだことはすべて、特に仕様を作成するときに、NANOアプリの開発に検討し、適用する必要があります。
「これは複雑すぎる」、「役に立たない」、「なぜこれを使用するのか」などを感じることがある場合があります。ナノアプリがモデルで使用されるクリエイティブな方法に驚くかもしれません。
具体的な例として、メディアプレーヤーのコントロールには、提供する価値がないと思われるコマンドがあります。しかし、あなたが少し遊んでいる時間を過ごすならば、あなたはモデルがそれを使用してあなたが求めていることを達成する方法について多くの「すごい」瞬間を持っています。
ですから、それを創造的で探検する余地を与えてください。あなたが不確かだと感じたからといって、機能を抑えないでください。
LLMはかなりの量のデータを処理できるようになっていますが、トークンに関しては以下を考慮する必要があります。
不必要に長い出力を提供しないでください。出力を簡潔にする機会をつかみます。データベースをクエリしたり、コマンドを実行したりするNANOアプリを構築するときは、予期せず長い出力を生成できるため、注意してください。
Nanoアプリを一般的なソフトウェアのプロキシとして使用する場合、出力が実際のソフトウェアに忠実であることを確認してください。モデルは、出力がプログラムに期待されるものである場合に優れています。
たとえば、NANOアプリがGNUオクターブソフトウェアのプロキシである場合、操作に予想される出力は次のとおりです。
ans = 6
ans = 6の代わりに6だけを返すように短縮するのは魅力的かもしれません。それをしないでください。モデルがトレーニング中に期待することを学んだことであるため、元の出力を維持します。
エラーを簡潔に(簡潔な出力)と役立つ(プロンプトエンジニアリング)保持します。
Nanoアプリを一般的なソフトウェアのプロキシとして使用する場合、ソフトウェアからの元のエラー出力(出力Fidelity)の共有を優先します。一部のソフトウェアは、長いエラースタックトレースを生成します。このシナリオでは、必要な詳細を犠牲にすることなく、代替のカスタムショートメッセージを提供するか、出力サイズを制限することをお勧めします。忠実度と簡潔な出力のバランス。
()関数の出力として() returning()により、Openaiモデルが関数が再び実行されることを要求し、潜在的に無限のループにつながる可能性があります。
これは、実験的な初期段階のプロジェクトです。 Nanoアプリは危険な場合があるため、構築しようとするものに注意してください。彼らはあなたのコンピューターで破壊的なアクションを実行することができました。また、予算に注意してください。使用しているプロバイダーを監視し、予算を立ててください。 Nanoアプリは、予期せずに長いコンテンツまたは無限の/あまりにも長すぎるループを生成する可能性があり、コストを急上昇させる可能性があります。
このソフトウェアは、保証の免責事項を含むMITライセンスの下で配布されます。さらに、著者は、この実験的な初期段階のプロジェクトの使用から生じる可能性のある損害またはコストについて責任を負いません。あなた自身の責任でナノアプリを使用してください。