Update utils.py
Browse files
utils.py
CHANGED
@@ -11,6 +11,11 @@ def package_installer(import_name,package_name=None):
|
|
11 |
subprocess.run([sys.executable,'-m','pip','install',package_name,'--quiet'])
|
12 |
else:
|
13 |
pass
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def cell_number_extractor(input:str,token:str):
|
@@ -44,7 +49,7 @@ def cell_number_extractor(input:str,token:str):
|
|
44 |
"inputs": prompt,
|
45 |
})
|
46 |
|
47 |
-
|
48 |
output = output.replace(prompt,'').strip()
|
49 |
|
50 |
output = output.split('\n')
|
@@ -53,4 +58,19 @@ def cell_number_extractor(input:str,token:str):
|
|
53 |
|
54 |
output = '\n'.join(output)
|
55 |
|
56 |
-
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
subprocess.run([sys.executable,'-m','pip','install',package_name,'--quiet'])
|
12 |
else:
|
13 |
pass
|
14 |
+
|
15 |
+
def query(url,headers,payload):
|
16 |
+
import requests
|
17 |
+
response = requests.post(url, headers=headers, json=payload,timeout=120)
|
18 |
+
return response.json()
|
19 |
|
20 |
|
21 |
def cell_number_extractor(input:str,token:str):
|
|
|
49 |
"inputs": prompt,
|
50 |
})
|
51 |
|
52 |
+
output = output[0]['generated_text']
|
53 |
output = output.replace(prompt,'').strip()
|
54 |
|
55 |
output = output.split('\n')
|
|
|
58 |
|
59 |
output = '\n'.join(output)
|
60 |
|
61 |
+
return output
|
62 |
+
|
63 |
+
def convert_ipynb_to_html(input_file):
|
64 |
+
import nbformat
|
65 |
+
import nbconvert
|
66 |
+
# Load .ipynb file into a nbformat.NotebookNode object
|
67 |
+
notebook = nbformat.read(input_file, as_version=4)
|
68 |
+
|
69 |
+
# Convert using HTML exporter
|
70 |
+
html_exporter = nbconvert.HTMLExporter()
|
71 |
+
(body, resources) = html_exporter.from_notebook_node(notebook)
|
72 |
+
# Write to output html file
|
73 |
+
# with open(output_file, 'w') as f:
|
74 |
+
# f.write(body)
|
75 |
+
|
76 |
+
return body
|