Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import fitz # PyMuPDF
|
|
4 |
import time
|
5 |
|
6 |
# Set your OpenAI API key
|
7 |
-
openai.api_key = '
|
8 |
|
9 |
def extract_text_from_pdf(pdf_file):
|
10 |
text = ""
|
@@ -79,6 +79,9 @@ def evaluate(rubric_pdf, rubric_text, text):
|
|
79 |
if not text:
|
80 |
return "No text provided for evaluation."
|
81 |
|
|
|
|
|
|
|
82 |
evaluation = evaluate_text_against_rubric(rubric, text)
|
83 |
|
84 |
if isinstance(evaluation, str): # If it's an error message
|
@@ -101,7 +104,7 @@ with gr.Blocks() as interface:
|
|
101 |
|
102 |
rubric_pdf_input = gr.File(label="Upload Rubric PDF (optional)", type="binary")
|
103 |
rubric_text_input = gr.Textbox(lines=10, placeholder="Or enter your rubric text here...", label="Rubric Text (optional)")
|
104 |
-
text_input = gr.Textbox(lines=10, placeholder="Paste the text to be evaluated here (max 2000 characters)...", label="Text to Evaluate"
|
105 |
|
106 |
evaluate_button = gr.Button("Evaluate")
|
107 |
|
@@ -121,3 +124,4 @@ interface.launch()
|
|
121 |
|
122 |
|
123 |
|
|
|
|
4 |
import time
|
5 |
|
6 |
# Set your OpenAI API key
|
7 |
+
openai.api_key = 'your-openai-api-key'
|
8 |
|
9 |
def extract_text_from_pdf(pdf_file):
|
10 |
text = ""
|
|
|
79 |
if not text:
|
80 |
return "No text provided for evaluation."
|
81 |
|
82 |
+
if len(text) > 2000:
|
83 |
+
return "The text provided exceeds the 2000 character limit."
|
84 |
+
|
85 |
evaluation = evaluate_text_against_rubric(rubric, text)
|
86 |
|
87 |
if isinstance(evaluation, str): # If it's an error message
|
|
|
104 |
|
105 |
rubric_pdf_input = gr.File(label="Upload Rubric PDF (optional)", type="binary")
|
106 |
rubric_text_input = gr.Textbox(lines=10, placeholder="Or enter your rubric text here...", label="Rubric Text (optional)")
|
107 |
+
text_input = gr.Textbox(lines=10, placeholder="Paste the text to be evaluated here (max 2000 characters)...", label="Text to Evaluate")
|
108 |
|
109 |
evaluate_button = gr.Button("Evaluate")
|
110 |
|
|
|
124 |
|
125 |
|
126 |
|
127 |
+
|