LaVague icon indicating copy to clipboard operation
LaVague copied to clipboard

Add MacOS installation Support

Open willschneider15 opened this issue 10 months ago • 10 comments

Added macOS support via shell script that checks for x86 or arm. This logic could be used to condense down to one setup shell script.

I renamed chrome folders to -testing as to not have to update the logic in the python to check for the OS and CPU. I also had to update this renaming convention in the default setup.sh.

# Uncomment if Chromium/Google Chrome is installed via our script
# chrome_options.binary_location = f"{homedir}/chrome-testing/chrome"
webdriver_service = Service(f"{homedir}/chromedriver-testing/chromedriver")

I also found that binary_location is not needed for anyone that already has chrome installed.

willschneider15 avatar Apr 05 '24 07:04 willschneider15

Screenshot 2024-04-05 at 3 01 25 AM

Working on my x86 mac

willschneider15 avatar Apr 05 '24 07:04 willschneider15

Updated not to make breaking change but still need to troubleshoot why the binary_location is not working. I am considering testing the headless version here:

https://googlechromelabs.github.io/chrome-for-testing/

Any other thoughts?

willschneider15 avatar Apr 06 '24 03:04 willschneider15

Thanks for doing this! The included sudo apt install does not work on Mac. I tried to get it running on my ARM machine, but stumbled into Python problems (created a new venv):

lavague-build --file_path tests/hf.txt --config_file examples/api/openai_api.py
Traceback (most recent call last):
  File "/opt/homebrew/bin/lavague-build", line 5, in <module>
    from lavague import build
  File "/Users/adria/gh/LaVague/LaVague/src/lavague/__init__.py", line 2, in <module>
    from .utils import load_action_engine, load_instructions
  File "/Users/adria/gh/LaVague/LaVague/src/lavague/utils.py", line 7, in <module>
    from .defaults import (
  File "/Users/adria/gh/LaVague/LaVague/src/lavague/defaults.py", line 2, in <module>
    from llama_index.llms.openai import OpenAI
  File "/opt/homebrew/lib/python3.11/site-packages/llama_index/llms/openai/__init__.py", line 1, in <module>
    from llama_index.llms.openai.base import AsyncOpenAI, OpenAI, SyncOpenAI, Tokenizer
  File "/opt/homebrew/lib/python3.11/site-packages/llama_index/llms/openai/base.py", line 48, in <module>
    from llama_index.llms.openai.utils import (
  File "/opt/homebrew/lib/python3.11/site-packages/llama_index/llms/openai/utils.py", line 24, in <module>
    from openai.types.chat.chat_completion_token_logprob import ChatCompletionTokenLogprob
ModuleNotFoundError: No module named 'openai.types.chat.chat_completion_token_logprob'
1.74s user 1.93s system 149% cpu 2.455s total

The docker setup also didn't work:

docker run --platform linux/amd64 --user $(id -u):$(id -g) -v /Users/adria/gh/LaVague/lavague-files:/home/vscode/lavague-files -e OPENAI_API_KEY=$KEY lavagueai/lavague:latest build
/usr/bin/bash: /home/vscode/entrypoint.sh: Permission denied

so I just ended up using the colab notebook

elchead avatar Apr 06 '24 10:04 elchead

Hi @elchead - I'll look into the docker issue on Monday!

lyie28 avatar Apr 06 '24 11:04 lyie28

And @willschneider15, thanks - I'll check your changes out on Monday too :)

lyie28 avatar Apr 06 '24 11:04 lyie28

@elchead I have not tested on Arm since my mac is an x86 Intel machine. Would love your help to troubleshoot that if you have time.

Off first look of the error logs. It looks like you may need to retry your pip install.

Then for Docker it looks like the shell script may not have enough permissions. Can try running chmod +x on that.

willschneider15 avatar Apr 06 '24 13:04 willschneider15

Hi @elchead, I have opened a new issue for the Docker image and will fix it ASAP: https://github.com/lavague-ai/LaVague/issues/108

lyie28 avatar Apr 08 '24 09:04 lyie28

Hey @willschneider15,

I tested your PR on my Arm Mac, and it didn't work at all for me. I first got this error while running the installation script:

chrome-mac-arm64/Google Chrome for Testing.app/Contents/Frameworks/Google Chrome for Testing Framework.framework/Libraries -> Versions/Current/Libraries
chrome-mac-arm64/Google Chrome for Testing.app/Contents/Frameworks/Google Chrome for Testing Framework.framework/Google Chrome for Testing Framework -> Versions/Current/Google Chrome for Testing Framework
chrome-mac-arm64/Google Chrome for Testing.app/Contents/Frameworks/Google Chrome for Testing Framework.framework/Helpers -> Versions/Current/Helpers
Password:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

When I runned lavague-build, I got this error:

~/mac_lav on  main! ⌚ 12:14:23
$ ./env_test/bin/lavague-build --file_path tests/hf.txt --config_path examples/api/openai_api.py

Traceback (most recent call last):
  File "/Users/mb/mac_lav/./env_test/bin/lavague-build", line 8, in <module>
    sys.exit(build())
  File "/Users/mb/mac_lav/env_test/lib/python3.9/site-packages/lavague/__init__.py", line 49, in build
    abstractDriver = get_driver()
  File "/Users/mb/mac_lav/env_test/lib/python3.9/site-packages/lavague/defaults.py", line 39, in default_get_driver
    path_linux = f"{homedir}/chromedriver-mac-x64/chromedriver"
UnboundLocalError: local variable 'homedir' referenced before assignment

When I fix this issue and declare homedir in time, I get this error instead:

selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /Users/mb/chrome-testing/chrome
Stacktrace:
0   chromedriver                        0x0000000102da0474 chromedriver + 4326516
1   chromedriver                        0x0000000102d9893c chromedriver + 4294972
2   chromedriver                        0x00000001029c4088 chromedriver + 278664
3   chromedriver                        0x00000001029f15a8 chromedriver + 464296
4   chromedriver                        0x00000001029f0074 chromedriver + 458868
5   chromedriver                        0x0000000102a2f128 chromedriver + 717096
6   chromedriver                        0x00000001029fb4e4 chromedriver + 505060
7   chromedriver                        0x00000001029fbf5c chromedriver + 507740
8   chromedriver                        0x0000000102d63a10 chromedriver + 4078096
9   chromedriver                        0x0000000102d687c8 chromedriver + 4097992
10  chromedriver                        0x0000000102d4a5b4 chromedriver + 3974580
11  chromedriver                        0x0000000102d690e0 chromedriver + 4100320
12  chromedriver                        0x0000000102d3bba4 chromedriver + 3914660
13  chromedriver                        0x0000000102d896e8 chromedriver + 4232936
14  chromedriver                        0x0000000102d89864 chromedriver + 4233316
15  chromedriver                        0x0000000102d985b0 chromedriver + 4294064
16  libsystem_pthread.dylib             0x000000018afbd06c _pthread_start + 148
17  libsystem_pthread.dylib             0x000000018afb7e2c thread_start + 8

For some reasons, the script download does indeed install chrome at the correct location, but all I can find is the .app folder:

~/mac_lav on  main! ⌚ 12:26:03
$ ls -l /Users/mb/chrome-testing/
total 8
-rw-r--r--  1 mb  staff  248 Apr  1 23:47 ABOUT
drwxr-xr-x  3 mb  staff   96 Apr  1 23:46 Google Chrome for Testing.app
(env_test) (base)

My MacOS version is Ventura 13.1.

JoFrost avatar Apr 08 '24 09:04 JoFrost

@elchead The docker image should be working now. Can you try pulling the latest docker image and let me know if it is working for you now?

Command modified to: docker run -v /home/$USER/LaVague/lavague-files:/home/vscode/lavague-files -e OPENAI_API_KEY=[YOUR_OPENAI_API_KEY] lavagueai/lavague:latest build

lyie28 avatar Apr 08 '24 12:04 lyie28

docker run -v /home/$USER/LaVague/lavague-files:/home/vscode/lavague-files -e OPENAI_API_KEY=[YOUR_OPENAI_API_KEY] lavagueai/lavague:latest build

Thanks! The issue is solved.

elchead avatar Apr 09 '24 15:04 elchead