GianJSX commited on
Commit
b95bc34
·
1 Parent(s): 5a8b1de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -47,10 +47,11 @@ if html_content:
47
  st.write("Please paste the HTML piece code, not the URL")
48
  html_content = None
49
 
50
- extract_button = st.button("Extract data format")
51
 
52
  if html_content and extract_button:
53
  try:
 
54
  output = gpt_assistant.chain_response_format(html_content)
55
  st.session_state['output_format'] = output
56
  except NameError:
@@ -61,16 +62,16 @@ if html_content and extract_button:
61
  if 'output_format' in st.session_state:
62
  output_format = st.code(st.session_state['output_format'], language="json")
63
 
64
- if st.button("Generate the code"):
65
- try:
66
- python_code = gpt_assistant.chain_code_generator(st.session_state['output_format'], html_content)
67
- st.session_state['code_generated'] = python_code
68
- st.session_state['code_generated_exec'] = python_code + "\nresult = extract_info(html_data)"
69
-
70
- except NameError:
71
- st.write("Complete the API key field")
72
- except AuthenticationError:
73
- st.write("Invalid API key")
74
 
75
  @traceable(run_type="tool")
76
  def test_the_code(code, full_content):
 
47
  st.write("Please paste the HTML piece code, not the URL")
48
  html_content = None
49
 
50
+ extract_button = st.button("Generate output format & code")
51
 
52
  if html_content and extract_button:
53
  try:
54
+ st.write("1/2: Generating the output format...")
55
  output = gpt_assistant.chain_response_format(html_content)
56
  st.session_state['output_format'] = output
57
  except NameError:
 
62
  if 'output_format' in st.session_state:
63
  output_format = st.code(st.session_state['output_format'], language="json")
64
 
65
+ try:
66
+ st.write("2/2: Generating the code...")
67
+ python_code = gpt_assistant.chain_code_generator(st.session_state['output_format'], html_content)
68
+ st.session_state['code_generated'] = python_code
69
+ st.session_state['code_generated_exec'] = python_code + "\nresult = extract_info(html_data)"
70
+
71
+ except NameError:
72
+ st.write("Complete the API key field")
73
+ except AuthenticationError:
74
+ st.write("Invalid API key")
75
 
76
  @traceable(run_type="tool")
77
  def test_the_code(code, full_content):