- app.py +16 -15
- demo-tools-1.ipynb +45 -16
app.py
CHANGED
@@ -2,21 +2,22 @@
|
|
2 |
import os
|
3 |
import json
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
#
|
19 |
-
|
|
|
20 |
|
21 |
# %% [markdown]
|
22 |
# # Setup Web Crawler and Lookup functions
|
|
|
2 |
import os
|
3 |
import json
|
4 |
|
5 |
+
pathToSettings = '../../env/ai.json'
|
6 |
+
if os.path.exists(pathToSettings):
|
7 |
+
# Load setting from Json outside of project.
|
8 |
+
print(f'Reading settings from {pathToSettings}')
|
9 |
+
f = open(pathToSettings)
|
10 |
+
settingsJson = json.load(f)
|
11 |
+
del f
|
12 |
+
|
13 |
+
for key in settingsJson:
|
14 |
+
os.environ[key] = settingsJson[key]
|
15 |
+
|
16 |
+
del settingsJson
|
17 |
+
else:
|
18 |
+
# Manually set settings
|
19 |
+
os.environ['HUGGING_FACE_API_KEY'] = 'Get here: https://huggingface.co/settings/tokens'
|
20 |
+
os.environ['OPENAI_API_KEY'] = 'Get here: https://platform.openai.com/account/api-keys'
|
21 |
|
22 |
# %% [markdown]
|
23 |
# # Setup Web Crawler and Lookup functions
|
demo-tools-1.ipynb
CHANGED
@@ -2,28 +2,57 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
"source": [
|
9 |
"import os\n",
|
10 |
"import json\n",
|
11 |
"\n",
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"
|
15 |
-
"
|
|
|
|
|
|
|
16 |
"\n",
|
17 |
-
"for key in settingsJson:\n",
|
18 |
-
"
|
19 |
-
"
|
20 |
-
"del settingsJson\n",
|
21 |
-
" \n",
|
22 |
-
"#
|
23 |
-
"
|
24 |
-
"
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
]
|
28 |
},
|
29 |
{
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 239,
|
6 |
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Reading settings from ../../env/ai.json\n"
|
13 |
+
]
|
14 |
+
}
|
15 |
+
],
|
16 |
"source": [
|
17 |
"import os\n",
|
18 |
"import json\n",
|
19 |
"\n",
|
20 |
+
"pathToSettings = '../../env/ai.json'\n",
|
21 |
+
"if os.path.exists(pathToSettings):\n",
|
22 |
+
" # Load setting from Json outside of project.\n",
|
23 |
+
" print(f'Reading settings from {pathToSettings}')\n",
|
24 |
+
" f = open(pathToSettings)\n",
|
25 |
+
" settingsJson = json.load(f)\n",
|
26 |
+
" del f\n",
|
27 |
"\n",
|
28 |
+
" for key in settingsJson:\n",
|
29 |
+
" os.environ[key] = settingsJson[key]\n",
|
30 |
+
" \n",
|
31 |
+
" del settingsJson\n",
|
32 |
+
"else: \n",
|
33 |
+
" # Manually set settings \n",
|
34 |
+
" os.environ['HUGGING_FACE_API_KEY'] = 'Get here: https://huggingface.co/settings/tokens'\n",
|
35 |
+
" os.environ['OPENAI_API_KEY'] = 'Get here: https://platform.openai.com/account/api-keys'"
|
36 |
+
]
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"cell_type": "code",
|
40 |
+
"execution_count": 237,
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"text/plain": [
|
46 |
+
"False"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
"execution_count": 237,
|
50 |
+
"metadata": {},
|
51 |
+
"output_type": "execute_result"
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"source": [
|
55 |
+
"os.path.exists('noono.pj')"
|
56 |
]
|
57 |
},
|
58 |
{
|