RDF Validation Deployment commited on
Commit
37cea3a
·
1 Parent(s): 2602b43

improve fixing processing

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -54,8 +54,8 @@ HF_ENDPOINT_URL = "https://evxgv66ksxjlfrts.us-east-1.aws.endpoints.huggingface.
54
  HF_MODEL = "lmstudio-community/Llama-3.3-70B-Instruct-GGUF" # Correct model name for your endpoint
55
 
56
  # AI Correction Configuration
57
- MAX_CORRECTION_ATTEMPTS = 2 # Reduced from 3 to speed up processing
58
- ENABLE_VALIDATION_LOOP = False # Disable validation loop to prevent hanging
59
 
60
  # OpenAI client configuration for the endpoint
61
  def get_openai_client():
@@ -430,7 +430,7 @@ def get_ai_correction(validation_results: str, rdf_content: str, template: str =
430
  # Add timeout protection
431
  import time
432
  start_time = time.time()
433
- timeout = 60 # 60 second timeout
434
  if steps_log is not None:
435
  steps_log.append(f"Timeout budget: {timeout}s total")
436
 
@@ -479,7 +479,7 @@ Return ONLY the corrected {class_name} XML section. No explanations."""
479
  ],
480
  max_tokens=1000,
481
  temperature=0.3,
482
- timeout=20 # Shorter timeout per section
483
  )
484
 
485
  corrected_section = chat_completion.choices[0].message.content.strip()
@@ -734,7 +734,7 @@ def get_ai_correction(validation_results: str, rdf_content: str, template: str =
734
  # Add timeout protection
735
  import time
736
  start_time = time.time()
737
- timeout = 60 # 60 second timeout
738
  if steps_log is not None:
739
  steps_log.append(f"Timeout budget: {timeout}s total")
740
 
@@ -785,7 +785,7 @@ Please provide the corrected RDF/XML that addresses all validation issues.
785
  ],
786
  max_tokens=2000,
787
  temperature=0.3,
788
- timeout=30 # 30 second timeout per API call
789
  )
790
 
791
  corrected_rdf = chat_completion.choices[0].message.content.strip()
@@ -1101,7 +1101,7 @@ def ensure_rdf_wrapper_and_namespaces(xml_text: str, original_text: Optional[str
1101
 
1102
  return updated
1103
 
1104
- def validate_rdf_interface(rdf_content: str, template: str, use_ai: bool = True, include_warnings: bool = False, iterate_until_valid: bool = False, max_attempts: int = 3, show_steps: bool = False):
1105
  """Main validation function for Gradio interface"""
1106
  if not rdf_content.strip():
1107
  return "❌ Error", "No RDF/XML data provided", "", "", "", "", ""
@@ -1320,14 +1320,14 @@ def create_interface():
1320
  with gr.Row():
1321
  iterate_checkbox = gr.Checkbox(
1322
  label="Iterate until valid",
1323
- value=False,
1324
  info="Try multiple correction attempts until validation passes or attempts run out"
1325
  )
1326
  max_attempts_slider = gr.Slider(
1327
  label="Max attempts",
1328
  minimum=1,
1329
  maximum=5,
1330
- value=3,
1331
  step=1,
1332
  info="Maximum number of correction attempts when iterating"
1333
  )
 
54
  HF_MODEL = "lmstudio-community/Llama-3.3-70B-Instruct-GGUF" # Correct model name for your endpoint
55
 
56
  # AI Correction Configuration
57
+ MAX_CORRECTION_ATTEMPTS = 5 # Increased to allow more retries
58
+ ENABLE_VALIDATION_LOOP = True # Enable validation loop by default
59
 
60
  # OpenAI client configuration for the endpoint
61
  def get_openai_client():
 
430
  # Add timeout protection
431
  import time
432
  start_time = time.time()
433
+ timeout = 120 # Increased to 120 second total timeout
434
  if steps_log is not None:
435
  steps_log.append(f"Timeout budget: {timeout}s total")
436
 
 
479
  ],
480
  max_tokens=1000,
481
  temperature=0.3,
482
+ timeout=45 # Increased per-section timeout
483
  )
484
 
485
  corrected_section = chat_completion.choices[0].message.content.strip()
 
734
  # Add timeout protection
735
  import time
736
  start_time = time.time()
737
+ timeout = 120 # Increased to 120 second total timeout
738
  if steps_log is not None:
739
  steps_log.append(f"Timeout budget: {timeout}s total")
740
 
 
785
  ],
786
  max_tokens=2000,
787
  temperature=0.3,
788
+ timeout=60 # Increased to 60 second timeout per API call
789
  )
790
 
791
  corrected_rdf = chat_completion.choices[0].message.content.strip()
 
1101
 
1102
  return updated
1103
 
1104
+ def validate_rdf_interface(rdf_content: str, template: str, use_ai: bool = True, include_warnings: bool = False, iterate_until_valid: bool = True, max_attempts: int = 5, show_steps: bool = True):
1105
  """Main validation function for Gradio interface"""
1106
  if not rdf_content.strip():
1107
  return "❌ Error", "No RDF/XML data provided", "", "", "", "", ""
 
1320
  with gr.Row():
1321
  iterate_checkbox = gr.Checkbox(
1322
  label="Iterate until valid",
1323
+ value=True,
1324
  info="Try multiple correction attempts until validation passes or attempts run out"
1325
  )
1326
  max_attempts_slider = gr.Slider(
1327
  label="Max attempts",
1328
  minimum=1,
1329
  maximum=5,
1330
+ value=5,
1331
  step=1,
1332
  info="Maximum number of correction attempts when iterating"
1333
  )