Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanhe42 committed Jan 23, 2023
0 parents commit 38ab4de
Show file tree
Hide file tree
Showing 5 changed files with 421 additions and 0 deletions.
164 changes: 164 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
chromedriver

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
script/user_data
outputs/user_data
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ActGPT - chatbot that controls browser

blog post: https://yihui.dev/actgpt

config api key, chromedriver path and user data path in `conf/config.yaml`.

- API key is from OpenAI. You can get it from https://beta.openai.com/
- chromedriver path is where you have chromedriver installed. You can download it from https://chromedriver.chromium.org/downloads
- User data path is where your browser stores cookies, history, etc. You can use a new folder to avoid logging in to websites.

```
OPENAI_API_KEY: api_key
executable_path: /path/to/chromedriver
user_data_dir: /path/to/user_data
```

install `requirements.txt` then run `python3 demo.py` to start the chatbot.

### examples

search for "ChatGPT" on wikipedia. summarize and tweet on Tiwtter.

```
write code:
1. go to www.wikipedia.org
2. find all textboxes. find one from them that is visible
3. click on the textbox
4. type in "ChatGPT" + Keys.ENTER
5. sleep 3 seconds
6. find all elements that contains text longer than 50 characters
7. combine their text in a string `text` and print it
8. go to url 'www.twitter.com'
9. ask AI about "write a tagline tweet given:" + `text` and store it in variable `response`
10. find an element whose text is Tweet
11. find a textbox near the element
12. click the textbox
13. type in existing variable `response` + Keys.ENTER
14. click the element whose text is Tweet.
15. wait 3 seconds
16. find an element that has text longer than 50 characters
17. click on the nearest like button
```

Google search, write joke about search and tweet it

```
write code: 1. go to google. 2. find all textboxes. find one from them that is visible 3. click on the textbox 4. type in Andrej Karpathy and ENTER key
write code: 1. find all elements that contains text longer than 50 characters 2. store their text in `text` and print it
write code: 1. find all elements contain text 2. initialize an empty string 3. for each element, split the text into lines 4. for each line, if it's longer than 20 words, append it to the string
ask AI about "write a joke given:" + `text` and store it in variable `response`
write code: 1. go to twitter 2. find an element whose text is Tweet 3. find a textbox near the element 4. click the textbox 5. type in existing variable `response` 6. click the element
```

Amazon search

```
go to amazon
find all textboxes. find one from them that is visible
click on the textbox
type in "ChatGPT" and enter
```
3 changes: 3 additions & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY: api_key
executable_path: /path/to/chromedriver
user_data_dir: /path/to/user_data
Loading

0 comments on commit 38ab4de

Please sign in to comment.