Dmitry Kirsanov commited on
Commit
4cf70e0
·
1 Parent(s): 43a6e83

first commit: start parsing code

Browse files
Files changed (4) hide show
  1. .env +2 -0
  2. app.py +19 -0
  3. parse.py +7 -0
  4. requirements.txt +3 -0
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Once you add your API key below, make sure to not share it with anyone! The API key should remain private.
2
+ OPENAI_API_KEY=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
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ import parse.py
5
+
6
+
7
+
8
+ def process(filename, model):
9
+ return parse.parse(filename)
10
+
11
+ gradio_app = gr.Interface(
12
+ fn=process,
13
+ allow_flagging="auto",
14
+ inputs=[gr.File(label="Input document (HTML)"), gr.Dropdown(choices=["gpt-3.5-turbo", "gpt-4", "gpt-4-turbo-preview"], value="gpt-3.5-turbo")],
15
+ outputs=[gr.Textbox(label="Parsed", lines=8))
16
+
17
+ if __name__ == "__main__":
18
+ gradio_app.launch()
19
+ #test()
parse.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from bs4 import BeautifulSoup
2
+
3
+ def parse(filepath):
4
+ soup = BeautifulSoup(open(filepath).read(), 'html.parser')
5
+ return soup.prettify()
6
+
7
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ python-dotenv
2
+ openai
3
+ bs4