gmshroff commited on
Commit
df3fc47
1 Parent(s): 0f79c21

commression functions for activity log

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. library.ipynb +15 -2
app.py CHANGED
@@ -5,7 +5,7 @@ import anvil.server
5
  import pathlib
6
  import textwrap
7
  import import_ipynb
8
- from library import call_gpt, call_gemini
9
  from background_service import BackgroundTaskService
10
  import numpy as np
11
 
@@ -33,6 +33,8 @@ encoder = AutoModel.from_pretrained('allenai/specter')
33
 
34
  anvil.server.callable(call_gpt)
35
  anvil.server.callable(call_gemini)
 
 
36
 
37
  service=BackgroundTaskService(max_tasks=10)
38
  service.register(call_gpt)
 
5
  import pathlib
6
  import textwrap
7
  import import_ipynb
8
+ from library import call_gpt, call_gemini, compress_bool_list, uncompress_bool_list
9
  from background_service import BackgroundTaskService
10
  import numpy as np
11
 
 
33
 
34
  anvil.server.callable(call_gpt)
35
  anvil.server.callable(call_gemini)
36
+ anvil.server.callable(compress_bool_list)
37
+ anvil.server.callable(uncompress_bool_list)
38
 
39
  service=BackgroundTaskService(max_tasks=10)
40
  service.register(call_gpt)
library.ipynb CHANGED
@@ -11,8 +11,21 @@
11
  "import pathlib\n",
12
  "import textwrap\n",
13
  "import google.generativeai as genai #comment this for local deployment and uncomment dummy def below\n",
14
- "# class genai:\n",
15
- "# pass"
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ]
17
  },
18
  {
 
11
  "import pathlib\n",
12
  "import textwrap\n",
13
  "import google.generativeai as genai #comment this for local deployment and uncomment dummy def below\n",
14
+ "import numpy as np"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "def compress_bool_list(bools):\n",
24
+ " compressed_bits = np.packbits(bools,bitorder='big')\n",
25
+ " return [compressed_bits,len(bools)]\n",
26
+ "\n",
27
+ "def uncompress_bool_list(log):\n",
28
+ " return [bool(b) for b in np.unpackbits(log[0],bitorder='big')[:log[1]]]"
29
  ]
30
  },
31
  {