Skip to content

Commit

Permalink
feat: 2.0 release, more info on the changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
elblogbruno committed Feb 27, 2021
1 parent 89dcfe2 commit 3c30656
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 30 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

*.jks
key.properties

/Python Server/output
/Python Server/app/.idea
/Python Server/app/image_tagging/temp_image_folder
/Python Server/app/__pycache__
/Python Server/app/uploads


*.zip
*.log
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0]

### Added

- Added server as a .exe program on windows so it is easier as ever to run Notion AI My Mind in simple clicks.
- Server url is opened automatically on the browser, so you don't get lost if you don't know what the server url is.


### Fixed

- No port was returned at first run of the server.
- Refactored python directory, organized with folders.

## [1.9]

### Added
Expand Down Expand Up @@ -41,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed server issues adding callback capabilities. Before some websites images were not added due to timeouts.

[2.0]: https://github.com/elblogbruno/NotionAI-MyMind/releases/tag/2.0
[1.9]: https://github.com/elblogbruno/NotionAI-MyMind/releases/tag/1.9
[1.8]: https://github.com/elblogbruno/NotionAI-MyMind/releases/tag/1.8
[1.7]: https://github.com/elblogbruno/NotionAI-MyMind/releases/tag/1.7
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,40 @@
import validators
import os

from custom_errors import OnImageNotFound, OnUrlNotValid, EmbedableContentNotFound, NoTagsFound
from utils.custom_errors import OnImageNotFound, OnUrlNotValid, EmbedableContentNotFound, NoTagsFound

import requests
import json

import webbrowser
import socket
from threading import Thread

from image_tagging.image_tagging import ImageTagging
from lang_utils import get_response_text
from utils.lang_utils import get_response_text


class NotionAI:
def __init__(self, logging):
def __init__(self, logging, port):
self.logging = logging
logging.info("Initiating NotionAI Class.")
if os.path.isfile('data.json'):
print("Initiating with a found config file.")
logging.info("Initiating with a found config file.")
self.loaded = self.run(logging)
else:
print("You should go to the homepage and set the config.")
self.logging.info("You should go to the homepage and set the config.")
self.open_browser_at_start(port)

def open_browser_at_start(self, port):
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
final_url = "http://" + str(local_ip) + ":" + str(port)
print("You should go to the homepage and set the credentials. The url will open in your browser now. If can't "
"access a browser you can access {0}".format(final_url))
self.logging.info("You should go to the homepage and set the credentials. The url will open in your browser "
"now. If can't "
"access a browser you can access {0}".format(final_url))
webbrowser.open(final_url)

def run(self, logging, email=None, password=None):
loaded = False
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from tensorflow.python.keras.applications.inception_v3 import InceptionV3, preprocess_input, decode_predictions
from tensorflow.python.keras.preprocessing import image
import os
from utils import download_image_from_url, createFolder
from utils.utils import download_image_from_url, createFolder


class TensorFlowTag:
Expand Down
7 changes: 2 additions & 5 deletions Python Server/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
flask==1.1.2
gunicorn==20.0.4
clarifai-grpc==6.7.1
notion==0.0.28
requests==2.24.0
urllib3==1.25.10
validators==0.17.1
Werkzeug==1.0.1
tensorflow~=2.3.1
tensorflow>=2.4.0
keras
Pillow
pillow
Quart~=0.14.1
numpy~=1.18.5
numpy~=1.19.2
9 changes: 5 additions & 4 deletions Python Server/app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

import secrets

from utils import ask_server_port, save_options, save_data, createFolder
from NotionAI import *
from NotionAI.NotionAI import *
from utils.utils import ask_server_port, save_options, save_data, createFolder

UPLOAD_FOLDER = '../app/uploads/'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif','webp'])
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'webp'])

app = Quart(__name__)

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s',
level=logging.INFO)

notion = NotionAI(logging)
notion = None


@app.route('/add_url_to_mind')
Expand Down Expand Up @@ -150,4 +150,5 @@ async def handle_data():
secret = secrets.token_urlsafe(32)
app.secret_key = secret
port = ask_server_port(logging)
notion = NotionAI(logging, port)
app.run(host="0.0.0.0", port=port, debug=True)
11 changes: 11 additions & 0 deletions Python Server/app/static/thank_you.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
<div class="jumbotron text-center">
<h1 class="display-3">Thank You!</h1>
<p class="lead"><strong>You have now a fully </strong> 100% open source server with AI.</p>
<p class="lead"><strong>Server URL is: </strong> </p>
<p id ="ip" ></p>
<p> Set this url on the <strong>browser extension</strong> and <strong>phone app.</strong></p>

<hr>
<p>
Don't have any of these? <a href="https://github.com/elblogbruno/NotionAI-MyMind#extensions">Download the browser extension and app right now</a>
</p>
<p>
Having trouble? <a href="https://github.com/elblogbruno/NotionAI-MyMind/issues">Post an issue on github</a>
</p>
Expand All @@ -29,4 +36,8 @@ <h1 class="display-3">Thank You!</h1>
<h2 class="display-2">Made with love by @elblogbruno!</h2>
</div>
</body>
<script>
ip = document.getElementById("ip");
ip.innerHTML = "http://"+document.location.host+"/"
</script>
</html>
File renamed without changes.
File renamed without changes.
17 changes: 11 additions & 6 deletions Python Server/app/utils.py → Python Server/app/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

path = "/proc/self/cgroup"


def is_docker():
if not os.path.isfile(path): return False
with open(path) as f:
for line in f:
if re.match("\d+:[\w=]+:/docker(-[ce]e)?/\w+", line):
return True
return False
if not os.path.isfile(path): return False
with open(path) as f:
for line in f:
if re.match("\d+:[\w=]+:/docker(-[ce]e)?/\w+", line):
return True
return False


def ask_server_port(logging):
if is_docker():
Expand All @@ -41,11 +43,14 @@ def ask_server_port(logging):
options = {
'port': port
}

with open('port.json', 'w') as outfile:
json.dump(options, outfile)

logging.info("Port saved succesfully!")

return options['port']


def save_options(logging, **kwargs):
logging.info("Saving options.")
Expand Down
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This repo uses AI and the wonderful Notion to enable you to add anything on the
- [Browser Extension](#extensions)
- [Prerequisites](#prerequisites)
- [Love to try it?](#love-to-try-it)
- [Post installing steps](#post-installing-steps)
- [Docker-Compose](#docker-compose)
- [Common Issues](#common-issues)
- [Roadmap](#roadmap)
Expand Down Expand Up @@ -57,16 +58,30 @@ TokenV2 is updated automatically when it changes (it occurs when you log out of

*If you enter a clarifai api key, clarifai will be used. (Clarifai is cloud base, non gpu dependant, image is tagged on clarifai's servers) if you leave it blank it will use local tensorflow (will use cores of your server but image will be processed locally)

### Love to try it?
#### Love to try it?

### Linux
To install the python server, fire up your linux distributed machine and run this command.

```
wget https://raw.githubusercontent.com/elblogbruno/NotionAI-MyMind/master/setup.sh && sudo sh setup.sh
```
That's it.

The installation script will:
- Download the repo and install the server, then follow steps 4 to 7 down here:
- Download the repo and install the server, then follow [the post installation steps down here](https://github.com/elblogbruno/NotionAI-MyMind#post-installing-steps) :


### Windows

If you are on windows, you can go to the release tab and download [the exe installer](https://github.com/elblogbruno/NotionAI-MyMind/releases)
which will install it as easy as a normal windows program, so you don't have to bother, and install it like a normal program.

The installation setup program will:
- Extract and install the server on your computer, then follow [the post installation steps down here](https://github.com/elblogbruno/NotionAI-MyMind#post-installing-steps) :


### Manual installation

Instead, you can follow the steps down here:

Expand All @@ -80,24 +95,27 @@ cd NotionAI-MyMind && pip -r install requirements.txt
```
- Step 3. Run the server.
```
python server.py \\Python 3.5 or up needed.
python server.py \\Python 3.5 to versions 3.8 supported.
```
- Step 4. Create Notion Database.

## Post-installing steps

- Step 1. Create Notion Database.
It must have this properties selected and add more properties if you want, but the selected ones must exist. (AITagsText (text) and URL (url property))
![Notion Screen](/doc/notion-database-howto.jpg)

- Step 5. Go to your servers IP and fill the data needed (Token, Notion Database URL and clarifai api key).
- Step 2. Go to your servers IP and fill the data needed (Token, Notion Database URL and clarifai api key) (The url will be opened automatically if you don't know what url it is).

![Options Screen](/doc/options_python.png)

- Step 6. Load the extension on your chromium Browser or download from chrome or firefox [store](#extensions)
- Step 3. Load the extension on your chromium Browser or download from chrome or firefox [store](#extensions)

![Extension Screen](/doc/extension_howto.png)

- Step 7. Change the config of your extension to your local server IP.
- Step 4. Change the config of your extension to your local server IP.
![Settings Screen](/doc/settings_howto.png)

- Step 8. ENJOY!
- Step 5. ENJOY!

## Docker-Compose
You can run the server on docker container. Change the [SERVER_PORT] variable with the desired port to run the server with. Then simply call `docker-compose up -d`.
Expand Down

0 comments on commit 3c30656

Please sign in to comment.