vsrinivas commited on
Commit
f4fdbf2
·
verified ·
1 Parent(s): 3613316

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -4,7 +4,7 @@ from nbformat.v4 import (new_notebook, new_markdown_cell, new_code_cell)
4
  import pdfplumber
5
  import google.generativeai as genai
6
  import nbformat
7
-
8
 
9
  def classify_page(statement):
10
  genai.configure(api_key='AIzaSyBjGNru-WJoLncbVrErEzJE184MgX1o_Kg')
@@ -98,8 +98,11 @@ def classify_page(statement):
98
  """
99
  response = chat_session.send_message(prompt)
100
  print(response.text)
 
101
  print(response.text.replace("```python\n", "").replace("```", "").strip())
102
- return ast.literal_eval(response.text.replace("```python\n", "").replace("```", "").strip())
 
 
103
 
104
  def create_notebook(file, tc, bc):
105
  notebook = new_notebook()
 
4
  import pdfplumber
5
  import google.generativeai as genai
6
  import nbformat
7
+ import re
8
 
9
  def classify_page(statement):
10
  genai.configure(api_key='AIzaSyBjGNru-WJoLncbVrErEzJE184MgX1o_Kg')
 
98
  """
99
  response = chat_session.send_message(prompt)
100
  print(response.text)
101
+ response = response.text.replace("```python\n", "").replace("```", "").strip()
102
  print(response.text.replace("```python\n", "").replace("```", "").strip())
103
+ response = re.sub(r"[^\x20-\x7E]", "", response)
104
+ print(response)
105
+ return ast.literal_eval(response)
106
 
107
  def create_notebook(file, tc, bc):
108
  notebook = new_notebook()