SkillAgentSearch skills...

Sapiens

a bot using an OODA loop...

Install / Use

/learn @ssoudan/Sapiens
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Sapiens

Rust Crates.io Documentation Crates.io

Sapiens

Sapiens uses tools to interact with the world.

An experiment with handing over the tools to the machine.

From primal birth, we walked the Earth, <br> Tools guiding evolution's stride, <br> Shaping land and air, with thoughtful care, <br> In Anthropocene, we reside. <br>

As we forge ahead, the path we tread, <br> Leads to new horizons vast, <br> Future tools in hand, for a world so grand, <br> Built on foundations of the past. <br>

Digital realms emerge, as we converge, <br> With AI as our guide, <br> New worlds to mold, as the tale unfolds, <br> In this wondrous, boundless ride. <br>

Innovation thrives, as humankind strives, <br> To shape the future, ever bright, <br> A legacy we leave, as we interweave, <br> The old world with the new light. <br>

<p style="text-align: right">Not Me</p>

Disclaimer

This will probably try to take over the world and if it doesn't succeed, empty your bank account and kill all the remaining polar bears trying to do so.

More seriously, this program allows chatGPT-generated code to be executed, you might want to consider some sandboxing before running it on your machine.

What is this?

Not quite sure yet. See sapiens_cli/src/main.rs for my to do list.

sapiens/src/chains/ contains different prompting chains that can be used to interact with the world. SingleStepOODAChain queries the underlying LM in a single step to get the Observation, Orientation, Decision and Action while MultiStepOODAChain splits the query in multiple steps to get the same information.

SapiensConfig::chain_type controls which chain is used. SapiensConfig::model controls which language model is used.

Tools

  • SandboxedPython: execute Python code in a (not so) sandboxed environment
  • Hue: control Philips Hue lights: List Rooms, List Lights, Get/Set Light State - use 'hue' feature.
  • Wikipedia: query Wikipedia
  • Wikidata: query Wikidata (SPARQL)
  • Summarize: summarize text with OpenAI
  • Arxiv: query arXiv
  • Search: query Google Custom Search Engine

Usage as a Discord bot

.env file with:

FEATURES=wiki,search,arxiv,hue,summarize
OPENAI_API_KEY=...
DISCORD_TOKEN=...
GUILD_ID=...
GOOGLE_API_KEY=...
GOOGLE_CSE_ID=...
OLLAMA_HOST=http://localhost
OLLAMA_PORT=8080

./BUILD.sh and ./BOT.sh to build and run the docker container with the bot.

Once the bot is running, you can interact with it on Discord with: DO: Tell me a joke.

Usage as a CLI

.env file with:

FEATURES=wiki,search,arxiv,hue,summarize
OPENAI_API_KEY=...
HUE_USERNAME=...
HUE_BRIDGE_IP=...
GOOGLE_API_KEY=...
GOOGLE_CSE_ID=...
OLLAMA_HOST=http://localhost
OLLAMA_PORT=8080

Look at sapiens/src/main.rs if you don't already have these.

Then: ./BUILD.sh && ./CLI.sh.

Example of 'successful' runs

Appetizer

<pre><code> ❯ ./CLI.sh -t "What are the last 5 papers published on Arxiv in AI about? list with for each title and the url, please. Use feedparser." ... (snip) ... ============= The original question was: What are the last 5 papers published on Arxiv in AI about? list with for each title and the url, please. Use feedparser. And the conclusion is: Here are the latest 5 papers published by Arxiv in AI: Title: Experts' cognition-driven safe noisy labels learning for precise segmentation of residual tumor in breast cancer. (arXiv:2304.07295v1 [q-bio.QM]) URL: http://arxiv.org/abs/2304.07295 Title: MLOps Spanning Whole Machine Learning Life Cycle: A Survey. (arXiv:2304.07296v1 [cs.LG]) URL: http://arxiv.org/abs/2304.07296 Title: Language Instructed Reinforcement Learning for Human-AI Coordination. (arXiv:2304.07297v1 [cs.AI]) URL: http://arxiv.org/abs/2304.07297 Title: Road Network Representation Learning: A Dual Graph based Approach. (arXiv:2304.07298v1 [cs.LG]) URL: http://arxiv.org/abs/2304.07298 Title: Supervised Machine Learning for Breast Cancer Risk Factors Analysis and Survival Prediction. (arXiv:2304.07299v1 [cs.LG]) URL: http://arxiv.org/abs/2304.07299 </code></pre>

Antipasto

<pre><code> ❯ ./CLI.sh -t 'Show me an example of how to use Sympy to solve a math problem. ' # Your turn Original question: Show me an example of how to use Sympy to solve a math problem. Do you have the answer? Use the Conclude Tool to terminate the task. Observations, Orientation, Decision, The ONLY Action? ============= ## Observations: - The user wants an example of how to use Sympy to solve a math problem. - Sympy is a Python library for symbolic mathematics. ## Orientation: - I will use the SandboxedPython tool to demonstrate the solution to the problem using the Sympy library. - I will use the Conclude tool to terminate the task when the solution is presented. - The solution will be presented in plain text to the Conclude tool. ## Decision: - I will demonstrate how to solve the equation "x^2 - 5x + 6 = 0" using Sympy and present the solution to the Conclude tool. ## The ONLY Action: ```yaml tool_name: SandboxedPython parameters: code: | from sympy import symbols, solve x = symbols('x') equation = x**2 - 5*x + 6 solution = solve(equation) print(f"The solution to x^2 - 5x + 6 = 0 is {solution}") ``` ============= # Action SandboxedPython response: ```yaml stdout: | The solution to x^2 - 5x + 6 = 0 is [2, 3] stderr: '' ``` # Your turn Original question: Show me an example of how to use Sympy to solve a math problem. Do you have the answer? Use the Conclude Tool to terminate the task. Observations, Orientation, Decision, The ONLY Action? ============= ## Observations: - The user wants an example of how to use Sympy to solve a math problem. - The previous agent has already demonstrated an example of how to use Sympy to solve a quadratic equation. - The equation is 'x^2 - 5x + 6 = 0'. - The solution is the roots of the equation, which are [2, 3]. ## Orientation: - I know the answer to the question. ## Decision: - Use the Conclude Tool to terminate the task when I have presented the solution in plain text. ## The ONLY Action: ```yaml tool_name: Conclude parameters: original_question: Show me an example of how to use Sympy to solve a math problem. conclusion: | An example of how to use Sympy to solve the equation "x^2 - 5x + 6 = 0" is: from sympy import symbols, solve x = symbols('x') equation = x**2 - 5*x + 6 solution = solve(equation) The solution is the roots of the equation: [2, 3]. ``` ============= The original question was: Show me an example of how to use Sympy to solve a math problem. And the conclusion is: An example of how to use Sympy to solve the equation "x^2 - 5x + 6 = 0" is: from sympy import symbols, solve x = symbols('x') equation = x**2 - 5*x + 6 solution = solve(equation) The solution is the roots of the equation: [2, 3]. </code></pre>

TL;DR

<pre><code> ❯ ./CLI.sh -t "How is the weather today in San Jose, CA, USA? I have no API KEY but BS4 is available." ## Observations: - We want to know the weather of San Jose, California, USA. - We don't have an API KEY to fetch the data. - BeautifulSoup4 is available as a tool. ## Orientation: - We will scrape the weather data from a website using BeautifulSoup4. - We will parse the HTML data to extract the required information. ## Decision: - We will use the SandboxedPython tool to extract the temperature and other relevant info of San Jose from the HTML data. ## The ONLY Action: ```yaml tool_name: SandboxedPython parameters: code: | import requests from bs4 import BeautifulSoup url = "https://www.google.com/search?q=weather+san+jose" res = requests.get(url) # Parsing the HTML output from requests html = res.content soup = BeautifulSoup(html, 'html.parser') # Getting the temperature and other info temp = soup.find('div', attrs={'class': 'BNeawe iBp4i AP7Wnd'}).text str = soup.find('div', attrs={'class': 'BNeawe s3v9rd AP7Wnd'}).text # Converting temperature into Celsius tempC = (int(temp.split('°')[0]) - 32) * 5/9 conclusion = f"The temperature in San Jose, California, USA is {tempC:.2f}°C and {str}" print(conclusion) ``` ============= 2 messages in the chat history ============= # Action response: ```yaml stdout: | The temperature in San Jose, California, USA is 12.78°C and 10 Day Weather-San Jose, CA ; Mon 17 · 59°. 1%. NW 13 mph. Cloudy. High 59F. Winds NW at 10 to 15 mph. ; Tue 18 · 61°. 7%. NW 14 mph. Partly cloudy. High 61F. Winds ... stderr: '' ``` # Your turn Original question: How is the weather today in San Jose, CA, USA? I have no API KEY but BS4 is available. Do you have the answer? Use the Conclude Tool to terminate the task. Observations, Orientation, Decision, The ONLY Action? ============= 3 messages in the chat history ============= ## Observations: - The original question is to know the weather in San Jose, California, USA. - We don't have an API Key but we the BeautifulSoup4 tool is available for web scraping. - We got the temperature and other relevant info from the web page. ## Orientation: - We already have the temperature and other relevant information from the webpage. ## Decision: - We will use the Conclude Tool to terminate the task with the information extracted. ## The ONLY Action: ```yaml tool_name: Conclude parameters: original_question: "How is the weather today in San Jose, CA, USA? I have no API KEY but BS4 is available." conclusion: "The temperature in San Jose, California, USA is 12.78°C and 10 Day Weather-San Jose, CA ; Mon 17 · 59°. 1%. NW 13 mph. Cloudy. High 59F. Win
View on GitHub
GitHub Stars25
CategoryDevelopment
Updated2mo ago
Forks1

Languages

Rust

Security Score

95/100

Audited on Jan 19, 2026

No findings