纳米应用程序是可以嵌入纳米机器人的微小应用。就像人类可以通过访问扳手,计算器,屏幕读取器或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许可分发的,其中包括保修免责声明。此外,作者对使用该实验性早期项目可能产生的任何损害或成本不承担任何责任。使用纳米应用程序自行风险。