diff --git a/.fleet/run.json b/.fleet/run.json deleted file mode 100644 index ba3f1e7..0000000 --- a/.fleet/run.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "configurations": [ - { - "type": "python-tests", - "name": "test_planner", - "testFramework": "unittest", - "targets": ["test_planner"] - } - ] -} \ No newline at end of file diff --git a/.fleet/settings.json b/.fleet/settings.json deleted file mode 100644 index 9c19d31..0000000 --- a/.fleet/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "autoSave": true, - "autoSave.delay": 1000 -} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1440555..10dde77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10.12-bullseye +FROM python:3.10.13 WORKDIR /app @@ -11,7 +11,8 @@ RUN pipenv install --deploy --ignore-pipfile --verbose # Install browsers RUN apt-get update && apt-get install -y \ chromium-driver firefox-esr \ - ca-certificates libnss3 + ca-certificates libnss3 \ + sqlite3 libsqlite3-dev COPY data/ ./data/ COPY jarvis/ ./jarvis/ diff --git a/README.md b/README.md index 60d3228..ad88a93 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,131 @@ -# Jarvis: A Virtual Machine Tailored for AI +# Jarvis: AI-Powered Virtual Machine -Jarvis is a virtual machine designed to seamlessly integrate and run AI models. This README provides a step-by-step guide to setting up and using Jarvis. +Welcome to Jarvis, a cutting-edge virtual machine designed specifically to facilitate AI tasks. This README offers a comprehensive guide to effectively set up and utilize Jarvis for optimal results. + +## Demo + +[Experimental Jarvis Application](/docs/media/demo.mp4) ## Prerequisites -1. Ensure [pipenv](https://pypi.org/project/pipenv/) is installed on your system. -2. Obtain the necessary API keys to interface with third-party services: +1. Obtain the necessary API keys to interface with third-party services: - [OPENAI_API_KEY](https://platform.openai.com/account/api-keys) -- Both `GOOGLE_API_KEY` and `GOOGLE_SEARCH_ENGINE_ID`` for integrating Google Search Engine. +- Both `GOOGLE_API_KEY` and `GOOGLE_SEARCH_ENGINE_ID` for integrating Google Search Engine. -## Setup +## Installation and Setup 1. Clone this repository: + ``` git clone https://github.com/ngaut/jarvis.git && cd jarvis ``` -2. Initiate a Python virtual environment: +2. Set up the environment variables: + +- Rename `.env.template` to `.env`, and input the necessary API keys mentioned in the Prerequisites section. + +3. Build a Local Docker Image + ``` -pipenv shell +docker build -t jarvis-server:latest . ``` -3. Install the dependencies: +4. Running Jarvis Server + +The Jarvis server operates on port `51155` by default, offering services via the gRPC protocol. + +To run the Jarvis server with Docker: + ``` -pipenv install +docker run --rm -p 51155:51155 \ +-v $(pwd)/workspace:/app/workspace \ +-v $(pwd)/.env:/app/.env \ +jarvis-server:latest ``` -4. Set up the environment variables: -- Rename `.env.template` to `.env`, and input the necessary API keys mentioned in the Prerequisites section. -- Update the `PYTHONPATH` environment variable with the absolute path of this project and include it in your .env file. - +Note: Ensure you've configured the `.env` file in the current directory before proceeding. ## Usage -To generate a plan for tasks execution based on input goals: +For guidance, you can refer to the code provided in this [demo](example.ipynb) -``` -python -m jarvis --replan -``` +1. Develop a Skill: -To generate a plan for tasks execution based on a given goal file, which should be placed in the 'workspace' directory: +Develop a skill that generates summaries of top stories from Hacknews. -``` -python -m jarvis --replan --goalfile= +```python +stub.Execute( + jarvis_pb2.ExecuteRequest( + task=( + "Collect the top three articles featured on Hacker News (https://news.ycombinator.com/), " + "and produce a single professional reading summary that encompasses the content of all three articles, formatted in a user-friendly manner." + ) + ) +) ``` -To translate all tasks in plan into JVM instructions: +Task output example: ``` -python -m jarvis +executor_id: "ea8fcfdf59c011002875a88fcdac5e97" +task_id: 1 +task: Collect the top three articles featured on Hacker News (https://news.ycombinator.com/), and produce a single professional reading summary that encompasses the content of all three articles, formatted in a user-friendly manner. +result: "The University of Turku in Finland is developing an artificial language corpus proficient in all European languages ..." ``` -To translate a task with specified task number into JVM instructions: +2. Save a Skill: -``` -python -m jarvis --compile= +A step-by-step guide to save a developed skill for subsequent use. + +```python +stub.SaveSkill( + jarvis_pb2.SaveSkillRequest( + executor_id="ea8fcfdf59c011002875a88fcdac5e97", + skill_name="HackerNews top three articles summary", + ) +) ``` -To execute JVM instructions in the specified task: +Task output example: ``` -python -m jarvis --yaml=1.yaml -python -m jarvis --yaml=2.yaml +executor_id: "ea8fcfdf59c011002875a88fcdac5e97" +result: "skill is saved as HackerNews top three articles summary" ``` -## Docker Integration -Run Jarvis within a Docker container by following these steps: +3. Reuse Skills: -### Build a Local Docker Image +Recall and utilize previously saved skills for the same or related tasks. -``` -docker build -t jarvis-server:latest . +```python +python run_skill_chain.py --workspace=workspace --skill_dir=skill_library --execution_dir=summary_hn_news --skills="HackerNews top three articles summary" ``` -Or pull a pre-built Docker image +Task output example: ``` -docker pull public.ecr.aws/l7n5d1m0/jarvis-server:latest -``` +executing skill: HackerNews top three articles summary +-------------------------------------------------- +Skill Execution Summary +-------------------------------------------------- -### Running Jarvis Server +Skill Result: The article discusses a 3 state, 3 symbol Turing Machine called 'Bigfoot' that cannot be proven to halt or not without solving a Collatz-like problem ... +Skill Error: None -The Jarvis server operates on port `51155` by default, offering services via the gRPC protocol. +================================================== +Detailed Task Infos +================================================== -To run the Jarvis server with Docker: +Subtask: Collect the top three articles featured on Hacker News (https://news.ycombinator.com/), and produce a single professional reading summary that encompasses the content of all three articles, formatted in a user-friendly manner. +Result: ... +Error: None -``` -docker run --rm -p 51155:51155 \ --v $(pwd)/workspace:/app/workspace \ --v $(pwd)/.env:/app/.env \ -jarvis-server:latest -``` +-------------------------------------------------- -Note: Ensure you've configured the `.env` file in the current directory before proceeding. +End of Execution Summary +-------------------------------------------------- +``` ## Working with SuperAGI diff --git a/docs/media/demo.mp4 b/docs/media/demo.mp4 new file mode 100644 index 0000000..4f434d1 Binary files /dev/null and b/docs/media/demo.mp4 differ diff --git a/example.ipynb b/example.ipynb new file mode 100644 index 0000000..a0bf991 --- /dev/null +++ b/example.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import grpc\n", + "import jarvis.server.jarvis_pb2 as jarvis_pb2\n", + "import jarvis.server.jarvis_pb2_grpc as jarvis_pb2_grpc\n", + "\n", + "channel = grpc.insecure_channel(\"localhost:51155\")\n", + "stub = jarvis_pb2_grpc.JarvisStub(channel)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "response=stub.Execute(\n", + " jarvis_pb2.ExecuteRequest(\n", + " task=(\n", + " \"Collect the top three articles featured on Hacker News (https://news.ycombinator.com/), \"\n", + " \"and produce a single professional reading summary that encompasses the content of all three articles, formatted in a user-friendly manner.\"\n", + " )\n", + " )\n", + ")\n", + "response" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "stub.SaveSkill(\n", + " jarvis_pb2.SaveSkillRequest(\n", + " executor_id=response.executor_id,\n", + " skill_name=\"\",\n", + " )\n", + ")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "jarvis", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.11" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/jarvis/README.md b/jarvis/README.md new file mode 100644 index 0000000..af53d0f --- /dev/null +++ b/jarvis/README.md @@ -0,0 +1,42 @@ +# Overview + +Jarvis streamlines the process of task execution planning based on user-defined goals. Beyond that, it efficiently translates these tasks into JVM instructions, allowing seamless integration and execution. + +## How to Use Jarvis + +### Generating a Task Execution Plan + +For Direct Input Goals. Generate a plan for task execution directly from provided input goals: + +``` +python -m jarvis --replan +``` + +Using a Goal File. If you have predefined goals stored in a file, place this file in the 'workspace' directory. To generate a plan based on this file: + +``` +python -m jarvis --replan --goalfile= +``` + +### Translating Tasks to JVM Instructions + +Translate All Tasks. Convert all tasks in the execution plan into their corresponding JVM instructions: + +``` +python -m jarvis +``` + +Translate Specific Task. If you wish to only translate a task with a particular task number: + +``` +python -m jarvis --compile= +``` + +## Executing JVM Instructions + +Execute JVM instructions based on the specified task. Here are a couple of examples: + +``` +python -m jarvis --yaml=1.yaml +python -m jarvis --yaml=2.yaml +``` \ No newline at end of file diff --git a/jarvis/smartgpt/instruction.py b/jarvis/smartgpt/instruction.py index 309b299..a781fb3 100644 --- a/jarvis/smartgpt/instruction.py +++ b/jarvis/smartgpt/instruction.py @@ -140,7 +140,7 @@ def loop(self, jvm_instruction: JVMInstruction): # Extract the count and the list of instructions for the loop loop_count = 0 # if loop_count is integer - print( + logging.info( f"loop instruction (seq={jvm_instruction.instruction.get('seq', 'N/A')}) args: {args}" ) if isinstance(args["count"], int):