Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter and lint existing files #107

Merged
merged 9 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[flake8]
max-line-length = 100
max-complexity = 10
exclude =
.git,
__pycache__,
build,
dist,
*.egg-info,
venv,
.venv
extend-ignore =
# Black conflicts with E203 (whitespace before ':')
E203,
# Line break before binary operator (Black formats this way)
W503,
# Lambda assignments (used in routes)
E731,
# Bugbear errors that might cause recursion
B023,
# Ignore nested function definition
B006,
# Ignore missing docstring in public module/package/class/function/method
D100,
D101,
D104,
D102,
D103,
D105,
D106,
D107,

per-file-ignores =
# Allow unused imports in __init__.py
__init__.py: F401
# Allow longer lines in config files
config.py: E501

# Limit the plugins to avoid recursion issues
enable-extensions = B

# Increased recursion depth adjustment for bugbear
max-recursion-depth = 1000
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .github/workflows/lint.yml
name: Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Python linting dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort
pip install -r requirements.txt

- name: Run Python linters
run: |
black . --check
isort . --check-only
4 changes: 2 additions & 2 deletions .github/workflows/mor-agents-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
local model=\$1
local max_attempts=3
local attempt=1

while [ \$attempt -le \$max_attempts ]; do
echo -e "\${YELLOW}Pulling Ollama model \$model (Attempt \$attempt)...${NC}"
if ollama pull \$model; then
Expand All @@ -115,7 +115,7 @@ jobs:
sleep 5
attempt=\$((attempt + 1))
done

echo -e "\${RED}Failed to pull \$model after \$max_attempts attempts.${NC}"
return 1
}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/mor-agents-build-mac-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ on:
jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller

- name: Build with PyInstaller
run: |
pyinstaller --windowed --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py

- name: Move .app to expected location
run: |
mv dist/MORagents.app build_assets/macOS/

- name: Install Packages app
run: |
wget http://s.sudre.free.fr/files/Packages_1211_dev.dmg
hdiutil attach Packages_1211_dev.dmg
sudo installer -pkg /Volumes/Packages\ 1.2.11/packages/Packages.pkg -target /
hdiutil detach /Volumes/Packages\ 1.2.11

- name: Create installer package
run: |
cd build_assets/macOS
/usr/local/bin/packagesbuild --verbose --project MorpheusPackagesSudre.pkgproj

- name: Upload Installer
uses: actions/upload-artifact@v4
with:
name: MORagentsSetup-macOS
path: ./build_assets/macOS/MORAgentsInstaller.pkg
path: ./build_assets/macOS/MORAgentsInstaller.pkg
18 changes: 9 additions & 9 deletions .github/workflows/mor-agents-build-mac-intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ on:
jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller

- name: Build with PyInstaller
run: |
pyinstaller --windowed --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py

- name: Move .app to expected location
run: |
mv dist/MORagents.app build_assets/macOS/

- name: Install Packages app
run: |
wget http://s.sudre.free.fr/files/Packages_1211_dev.dmg
hdiutil attach Packages_1211_dev.dmg
sudo installer -pkg /Volumes/Packages\ 1.2.11/packages/Packages.pkg -target /
hdiutil detach /Volumes/Packages\ 1.2.11

- name: Create installer package
run: |
cd build_assets/macOS
/usr/local/bin/packagesbuild --verbose --project MorpheusPackagesSudreIntel.pkgproj

- name: Upload Installer
uses: actions/upload-artifact@v4
with:
name: MORagentsSetup-macOS
path: ./build_assets/macOS/MORAgentsInstaller.pkg
path: ./build_assets/macOS/MORAgentsInstaller.pkg
2 changes: 1 addition & 1 deletion .github/workflows/mor-agents-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/security_scan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Security Scan
permissions:
security-events: write
contents: write

on:
push:
Expand All @@ -11,36 +14,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install safety bandit

- name: Run Safety check
run: safety check -r requirements.txt
continue-on-error: true

- name: Run Bandit
run: bandit -r . -f custom
continue-on-error: true

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'

- name: Upload Trivy scan results to GitHub Security tab
scanners: 'vuln,secret,config'
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ resources/*
## installer
MORagentsWindowsInstaller
MORagentsWindowsInstaller.zip

## app
MORagents.app

## lint
.pytest_cache/
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-added-large-files
- id: detect-private-key
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
language_version: python3.12

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
14 changes: 7 additions & 7 deletions AGENTABILITIES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# MORagents
Welcome to the world of Web3 agents! If you're interested in building and using agents locally, this document will guide you through the principles and
Welcome to the world of Web3 agents! If you're interested in building and using agents locally, this document will guide you through the principles and
current projects underway.

### Principles:
1. **Agents cannot execute decisions**: Agents should not be given private keys or allowed to make transactions on their own. They can only construct transaction
1. **Agents cannot execute decisions**: Agents should not be given private keys or allowed to make transactions on their own. They can only construct transaction
payloads for a user's approval. This is due to the limitations of current LLMs in understanding complex transactions and the risk of [gaslighting](https://arxiv.org/abs/2311.04235).
2. **Local installation**: Agents should run on the user's laptop, typically with 8-16 GB of RAM. This allows for faster execution and better performance.
3. **No private keys**: Agents must not have access to private keys or be able to execute transactions independently. User's cryptographic approval is essential for any
3. **No private keys**: Agents must not have access to private keys or be able to execute transactions independently. User's cryptographic approval is essential for any
transaction.

### Current Projects:
1. **lachsbagel on Discord** - [this repo](https://github.com/MorpheusAIs/moragents):
1. **lachsbagel on Discord** - [this repo](https://github.com/MorpheusAIs/moragents):
1. Architecture
2. **IODmitri, SanatSharma, LachsBagel on GitHhub**
1. [HideNSeek](https://github.com/MorpheusAIs/HideNSeek): An algorithm for verifying and fingerprinting which model a compute provider is actually running
Expand All @@ -25,10 +25,10 @@ transaction.
4. CICD builds for Linux and macOS (apple and intel)
5. Vulnerability scanning of dependencies and code
4. GenLayer
1. (pending) [FeedBuzz](https://github.com/yeagerai/feedbuzz-contracts) - AI filtered logging system to surface user demand and failure modes for new functionality
1. (pending) [FeedBuzz](https://github.com/yeagerai/feedbuzz-contracts) - AI filtered logging system to surface user demand and failure modes for new functionality
5. **CliffordAttractor on Discord** - Following Assume 16GB+ RAM:
1. Developed a [price fetcher agent](submodules/moragents_dockers/agents/src/data_agent) using CoinGecko.
2. A [web interface](submodules/moragents_dockers/frontend) which is served by the local Docker installation and integrated with Rainbow, enabling the use of MetaMask, WalletConnect, and other
2. A [web interface](submodules/moragents_dockers/frontend) which is served by the local Docker installation and integrated with Rainbow, enabling the use of MetaMask, WalletConnect, and other
EVM-based wallets.
3. (NEEDS REFACTORING DUE TO 1INCH CHANGE) [Swap agent](submodules/moragents_dockers/agents/src/swap_agent) which can iteratively ask users to provide needed details for disambiguation.
4. [General-purpose agent](https://github.com/MorpheusAIs/moragents/pull/34) that can ingest arbitrary documents, such as PDFs, for basic document QA and text generation.
Expand Down Expand Up @@ -57,7 +57,7 @@ Pending Lumerin's work. Eventually Agent Builders will be able to permission-les


### How to Contribute:
- If you are working on an agent which can provide value through open models and relies on processing public data, please reach out to lachsbagel on Discord (link below)
- If you are working on an agent which can provide value through open models and relies on processing public data, please reach out to lachsbagel on Discord (link below)
- Otherwise, you are more than welcome to publish your agent to the registry when it goes live pending Lumerin's work and any other necessary pieces which come up to better ensure security and verifiability of models in non-local execution environments.
- If you are working on security and/or verifiability of models and the runtime, please reach out to LachsBagel on the Morpheus Discord.
- Currently looking at [Hyperbolic.xyz](https://hyperbolic.xyz) and [6079](https://docs.6079.ai/technology/6079-proof-of-inference-protocol). See more ecosystem members [here](https://mor.org/ecosystem).
Expand Down
2 changes: 1 addition & 1 deletion DISCLAIMER.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This highly experimental chatbot is not intended for making important decisions, and its responses are generated based on incomplete data and algorithms that may evolve
This highly experimental chatbot is not intended for making important decisions, and its responses are generated based on incomplete data and algorithms that may evolve
rapidly. By using this chatbot, you acknowledge that you use it at your own discretion and assume all risks associated with its limitations and potential errors.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Fully Extensible! Add your own agents and have them automatically invoked based

#### Steps to Install
1. Download Installer
1. For Mac on Apple Silicon M1/2/3 etc. (arm64)
1. For Mac on Apple Silicon M1/2/3 etc. (arm64)
1. Download and run MORagents installer [MORagents020-apple.pkg](https://drive.proton.me/urls/20ENWS94AW#Kols2sA9mWLf)
> SHA256 e65e11719a24ca9a00545443a35cda3b6d78f756b8e2ba535db00399ef75168f MORagents020-apple.pkg
2. For Mac on Intel (x86_64)
Expand All @@ -52,11 +52,11 @@ Fully Extensible! Add your own agents and have them automatically invoked based

#### Future Usage
- Open the "MORagents" app from Mac search bar.
- For easier access: Right-click MORagents icon on dock -> Options -> Keep in Dock
- For easier access: Right-click MORagents icon on dock -> Options -> Keep in Dock

#### Troubleshooting
- If the app shows connections errors in connecting to agents. Please ensure Docker Desktop is running, then close and reopen **MORagents** from desktop.
- If installation is unsuccessful, run the following in your Terminal and open the MORagents....pkg again
- If installation is unsuccessful, run the following in your Terminal and open the MORagents....pkg again
```shell
$ xcode-select --install
```
Expand All @@ -74,7 +74,7 @@ Fully Extensible! Add your own agents and have them automatically invoked based
2. If that still doesn't work, try temporarily disabling your antivirus and open the .exe again
4. Click and Run **MORagentsSetup.exe**
1. This will auto-install Docker and Ollama dependencies. Those will ask you for confirmation.
5. Open **MORagents** from Desktop
5. Open **MORagents** from Desktop
1. Wait for Docker engine to start...
2. If you see any errors or if anything hangs for >10min, please try opening the MORagents app again from the Desktop

Expand All @@ -100,4 +100,3 @@ This will allow you to add custom agents which will be automatically invoked bas
#### Build instructions:
1. [macOS](build_assets/macOS/README_MACOS_DEV_BUILD.md)
2. [Windows](build_assets/windows/README_WINDOWS_DEV_BUILD.md)

2 changes: 1 addition & 1 deletion build_assets/linux/install_moragents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ echo -e "${YELLOW}Running MORagents setup...${NC}"

echo -e "${GREEN}Installation complete!${NC}"
echo "You can now start MORagents from your application menu or by running 'MORagents' in the terminal."
echo -e "${YELLOW}NOTE: Please log out and log back in for Docker group changes to take effect.${NC}"
echo -e "${YELLOW}NOTE: Please log out and log back in for Docker group changes to take effect.${NC}"

This file was deleted.

Loading