Skip to content

Commit

Permalink
improve readme and dockerfile (ngaut#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
IANTHEREAL authored Oct 17, 2023
1 parent c9515e0 commit 5a933ec
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 64 deletions.
10 changes: 0 additions & 10 deletions .fleet/run.json

This file was deleted.

4 changes: 0 additions & 4 deletions .fleet/settings.json

This file was deleted.

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10.12-bullseye
FROM python:3.10.13

WORKDIR /app

Expand All @@ -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/
Expand Down
126 changes: 79 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -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=<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=<task_num>
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

Expand Down
Binary file added docs/media/demo.mp4
Binary file not shown.
70 changes: 70 additions & 0 deletions example.ipynb
Original file line number Diff line number Diff line change
@@ -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=\"<customize 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
}
42 changes: 42 additions & 0 deletions jarvis/README.md
Original file line number Diff line number Diff line change
@@ -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=<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=<task_num>
```

## 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
```
2 changes: 1 addition & 1 deletion jarvis/smartgpt/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5a933ec

Please sign in to comment.