Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
-
from
|
| 4 |
-
from
|
| 5 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 6 |
import os
|
| 7 |
|
|
@@ -95,10 +95,10 @@ Notes:
|
|
| 95 |
|
| 96 |
- The text may have been obtained via OCR, which could result in some errors.
|
| 97 |
- Disregard any text enclosed in <>. They separate different parts of the text.
|
| 98 |
-
- If the
|
|
|
|
| 99 |
- If the specific question is not present in the task content, mention that the question does not exist in the task response.
|
| 100 |
|
| 101 |
-
|
| 102 |
Task type: {task_type}
|
| 103 |
|
| 104 |
Task number: {task_number}
|
|
@@ -114,11 +114,11 @@ llm_model = ChatGoogleGenerativeAI(model="gemini-pro", temperature=0.7, top_p=0.
|
|
| 114 |
# Define the prompt template
|
| 115 |
prompt = PromptTemplate(input_variables=['task_type', 'task_number', 'question', 'content', 'description'], template=initial_prompt)
|
| 116 |
|
| 117 |
-
# Define the
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
)
|
| 122 |
|
| 123 |
def evaluate(task_type, task_number, question, image):
|
| 124 |
# Process the image to extract text
|
|
@@ -128,8 +128,8 @@ def evaluate(task_type, task_number, question, image):
|
|
| 128 |
# Select the appropriate description based on user input
|
| 129 |
description = descriptions.get((task_type, task_number), "")
|
| 130 |
|
| 131 |
-
# Run the
|
| 132 |
-
result =
|
| 133 |
'task_type': task_type,
|
| 134 |
'task_number': task_number,
|
| 135 |
'question': question,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from langchain_core.prompts import PromptTemplate
|
| 4 |
+
from langchain_core.runnables import RunnableSequence
|
| 5 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 6 |
import os
|
| 7 |
|
|
|
|
| 95 |
|
| 96 |
- The text may have been obtained via OCR, which could result in some errors.
|
| 97 |
- Disregard any text enclosed in <>. They separate different parts of the text.
|
| 98 |
+
- If the task type is empty, try to identify the task type from the question. If you cannot determine the task type, mention that the task type is unclear.
|
| 99 |
+
- If the question section is empty, try to identify the question in the task content.
|
| 100 |
- If the specific question is not present in the task content, mention that the question does not exist in the task response.
|
| 101 |
|
|
|
|
| 102 |
Task type: {task_type}
|
| 103 |
|
| 104 |
Task number: {task_number}
|
|
|
|
| 114 |
# Define the prompt template
|
| 115 |
prompt = PromptTemplate(input_variables=['task_type', 'task_number', 'question', 'content', 'description'], template=initial_prompt)
|
| 116 |
|
| 117 |
+
# Define the RunnableSequence
|
| 118 |
+
sequence = RunnableSequence([
|
| 119 |
+
prompt,
|
| 120 |
+
llm_model
|
| 121 |
+
])
|
| 122 |
|
| 123 |
def evaluate(task_type, task_number, question, image):
|
| 124 |
# Process the image to extract text
|
|
|
|
| 128 |
# Select the appropriate description based on user input
|
| 129 |
description = descriptions.get((task_type, task_number), "")
|
| 130 |
|
| 131 |
+
# Run the sequence
|
| 132 |
+
result = sequence({
|
| 133 |
'task_type': task_type,
|
| 134 |
'task_number': task_number,
|
| 135 |
'question': question,
|