thomascerniglia commited on
Commit
fd097e2
·
1 Parent(s): e87a452

Add semantics doc option to query tool

Browse files
Files changed (3) hide show
  1. config.py +2 -0
  2. main.py +8 -3
  3. question_runner.py +8 -3
config.py CHANGED
@@ -7,6 +7,8 @@ OPENROUTER_API_URL = "https://openrouter.ai/api/v1/chat/completions"
7
  # === GOOGLE DOCS INPUT ===
8
  SYNTAX_DOC_URL = "https://docs.google.com/document/d/1gxQbsAIek9CMDPalQOGlCq-fmi-WRrS69_yEx6b206U/export?format=txt"
9
  MORPHOLOGY_DOC_URL = "https://docs.google.com/document/d/1hIal62lGso9BqfqKfB0ws8g8pBZsX-LBSTrge3M6pBM/export?format=txt"
 
 
10
 
11
  # === MODEL PRIORITY ===
12
  # Ordered from best to weakest. Will try top → bottom until one succeeds.
 
7
  # === GOOGLE DOCS INPUT ===
8
  SYNTAX_DOC_URL = "https://docs.google.com/document/d/1gxQbsAIek9CMDPalQOGlCq-fmi-WRrS69_yEx6b206U/export?format=txt"
9
  MORPHOLOGY_DOC_URL = "https://docs.google.com/document/d/1hIal62lGso9BqfqKfB0ws8g8pBZsX-LBSTrge3M6pBM/export?format=txt"
10
+ SEMANTICS_DOC_URL="https://docs.google.com/document/d/1d_nFnKgFOsiAoCxYHoDkmnWab3bszEn3_6AXXNLrzqM/export?format=txt"
11
+
12
 
13
  # === MODEL PRIORITY ===
14
  # Ordered from best to weakest. Will try top → bottom until one succeeds.
main.py CHANGED
@@ -3,14 +3,19 @@ import gradio as gr
3
  from gradio.themes import Soft
4
 
5
  from question_runner import run_tool
6
- from config import MODEL_PRIORITY, SYNTAX_DOC_URL, MORPHOLOGY_DOC_URL
7
  from doc_utils import get_questions_from_doc
8
 
9
  # Estimate runtime based on # of questions
10
  def estimate_runtime(passage, doc_type):
11
  if not passage or not doc_type:
12
  return ""
13
- doc_url = SYNTAX_DOC_URL if doc_type.lower() == "syntax" else MORPHOLOGY_DOC_URL
 
 
 
 
 
14
  questions = get_questions_from_doc(doc_url)
15
  if not questions or (isinstance(questions, list) and questions and str(questions[0]).startswith("Error")):
16
  return "Unable to load questions."
@@ -27,7 +32,7 @@ with gr.Blocks(theme=Soft()) as demo:
27
 
28
  with gr.Row():
29
  passage_input = gr.Textbox(label="Latin or Greek Passage", lines=4)
30
- question_type = gr.Radio(["Syntax", "Morphology"], label="Question Type")
31
 
32
  top_model = MODEL_PRIORITY[0]
33
  full_model_list = "\n".join(f"- `{m}`" for m in MODEL_PRIORITY)
 
3
  from gradio.themes import Soft
4
 
5
  from question_runner import run_tool
6
+ from config import MODEL_PRIORITY, SYNTAX_DOC_URL, MORPHOLOGY_DOC_URL, SEMANTICS_DOC_URL
7
  from doc_utils import get_questions_from_doc
8
 
9
  # Estimate runtime based on # of questions
10
  def estimate_runtime(passage, doc_type):
11
  if not passage or not doc_type:
12
  return ""
13
+ if doc_type.lower() == "syntax":
14
+ doc_url = SYNTAX_DOC_URL
15
+ elif doc_type.lower() == "morphology":
16
+ doc_url = MORPHOLOGY_DOC_URL
17
+ else: # semantics
18
+ doc_url = SEMANTICS_DOC_URL
19
  questions = get_questions_from_doc(doc_url)
20
  if not questions or (isinstance(questions, list) and questions and str(questions[0]).startswith("Error")):
21
  return "Unable to load questions."
 
32
 
33
  with gr.Row():
34
  passage_input = gr.Textbox(label="Latin or Greek Passage", lines=4)
35
+ question_type = gr.Radio(["Syntax", "Morphology", "Semantics"], label="Question Type")
36
 
37
  top_model = MODEL_PRIORITY[0]
38
  full_model_list = "\n".join(f"- `{m}`" for m in MODEL_PRIORITY)
question_runner.py CHANGED
@@ -3,16 +3,21 @@
3
  import tempfile
4
  from router_client import query_model
5
  from doc_utils import get_questions_from_doc
6
- from config import SYNTAX_DOC_URL, MORPHOLOGY_DOC_URL
7
 
8
  def run_tool(passage, doc_type):
9
  if not passage.strip():
10
  return "Please enter a passage to analyze.", None, None
11
  if not doc_type:
12
- return "Please select either 'Syntax' or 'Morphology'.", None, None
13
 
14
  try:
15
- doc_url = SYNTAX_DOC_URL if doc_type.lower() == "syntax" else MORPHOLOGY_DOC_URL
 
 
 
 
 
16
  questions = get_questions_from_doc(doc_url)
17
 
18
  if not questions or questions[0].startswith("Error"):
 
3
  import tempfile
4
  from router_client import query_model
5
  from doc_utils import get_questions_from_doc
6
+ from config import SYNTAX_DOC_URL, MORPHOLOGY_DOC_URL, SEMANTICS_DOC_URL
7
 
8
  def run_tool(passage, doc_type):
9
  if not passage.strip():
10
  return "Please enter a passage to analyze.", None, None
11
  if not doc_type:
12
+ return "Please select 'Syntax', 'Morphology', or 'Semantics'.", None, None
13
 
14
  try:
15
+ if doc_type.lower() == "syntax":
16
+ doc_url = SYNTAX_DOC_URL
17
+ elif doc_type.lower() == "morphology":
18
+ doc_url = MORPHOLOGY_DOC_URL
19
+ else: # semantics
20
+ doc_url = SEMANTICS_DOC_URL
21
  questions = get_questions_from_doc(doc_url)
22
 
23
  if not questions or questions[0].startswith("Error"):