thrag commited on
Commit
b96faa7
1 Parent(s): da4b287
Files changed (2) hide show
  1. app.py +16 -15
  2. demo-tools-1.ipynb +45 -16
app.py CHANGED
@@ -2,21 +2,22 @@
2
  import os
3
  import json
4
 
5
- # Load setting from Json outside of project.
6
- f = open('../../env/ai.json')
7
- settingsJson = json.load(f)
8
- del f
9
-
10
- for key in settingsJson:
11
- os.environ[key] = settingsJson[key]
12
-
13
- del settingsJson
14
-
15
- # # OR manually set them
16
- # os.environ['REQUESTS_CA_BUNDLE'] = '../../env/ZCert.pem'
17
- # os.environ['HUGGING_FACE_API_KEY'] = 'Get here: https://huggingface.co/settings/tokens'
18
- # os.environ['OPENAI_API_KEY'] = 'Get here: https://platform.openai.com/account/api-keys'
19
- # os.environ["SERPAPI_API_KEY"] = 'serpapi KEY, Get here: https://serpapi.com/manage-api-key'
 
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": 222,
6
  "metadata": {},
7
- "outputs": [],
 
 
 
 
 
 
 
 
8
  "source": [
9
  "import os\n",
10
  "import json\n",
11
  "\n",
12
- "# Load setting from Json outside of project.\n",
13
- "f = open('../../env/ai.json')\n",
14
- "settingsJson = json.load(f)\n",
15
- "del f\n",
 
 
 
16
  "\n",
17
- "for key in settingsJson:\n",
18
- " os.environ[key] = settingsJson[key]\n",
19
- " \n",
20
- "del settingsJson\n",
21
- " \n",
22
- "# # OR manually set them\n",
23
- "# os.environ['REQUESTS_CA_BUNDLE'] = '../../env/ZCert.pem'\n",
24
- "# os.environ['HUGGING_FACE_API_KEY'] = 'Get here: https://huggingface.co/settings/tokens'\n",
25
- "# os.environ['OPENAI_API_KEY'] = 'Get here: https://platform.openai.com/account/api-keys'\n",
26
- "# os.environ[\"SERPAPI_API_KEY\"] = 'serpapi KEY, Get here: https://serpapi.com/manage-api-key'"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  {