Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
@@ -645,15 +645,22 @@ def decode_qr_code(image_path: str) -> Optional[str]:
|
|
645 |
logger.error(f"QR decoding error: {e}")
|
646 |
return None
|
647 |
|
648 |
-
#
|
|
|
|
|
|
|
|
|
|
|
649 |
def datachat_interface(mode: str, data_source: str, json_input: str, qr_image: str, query: str) -> str:
|
650 |
-
"""Interface for DataChat functionality with binary data support"""
|
651 |
data = None
|
652 |
if data_source == "JSON Input":
|
653 |
data = json_input
|
654 |
elif data_source == "QR Code":
|
655 |
try:
|
656 |
decoded_data = decode_qr_code(qr_image)
|
|
|
|
|
|
|
657 |
|
658 |
# Handle base64 encoded data
|
659 |
if decoded_data and decoded_data.startswith("base64:"):
|
@@ -678,14 +685,12 @@ def datachat_interface(mode: str, data_source: str, json_input: str, qr_image: s
|
|
678 |
return f"Invalid QR code data provided: {e}"
|
679 |
else:
|
680 |
return "No valid data source selected."
|
681 |
-
|
682 |
if mode == "Trained with Data":
|
683 |
-
return datachat_trained(data, query)
|
684 |
elif mode == "Chat about Data":
|
685 |
-
return datachat_simple(data, query)
|
686 |
else:
|
687 |
return "Invalid mode selected."
|
688 |
-
|
689 |
def create_interface():
|
690 |
"""Create a comprehensive Gradio interface with advanced features"""
|
691 |
css = """
|
|
|
645 |
logger.error(f"QR decoding error: {e}")
|
646 |
return None
|
647 |
|
648 |
+
# Ensure this function is defined somewhere in your code
|
649 |
+
def datachat_trained(data, query):
|
650 |
+
# Your implementation here
|
651 |
+
return "Response from trained model."
|
652 |
+
|
653 |
+
|
654 |
def datachat_interface(mode: str, data_source: str, json_input: str, qr_image: str, query: str) -> str:
|
|
|
655 |
data = None
|
656 |
if data_source == "JSON Input":
|
657 |
data = json_input
|
658 |
elif data_source == "QR Code":
|
659 |
try:
|
660 |
decoded_data = decode_qr_code(qr_image)
|
661 |
+
# Handle base64 encoded data...
|
662 |
+
except Exception as e:
|
663 |
+
return f"Invalid QR code data provided: {e}"
|
664 |
|
665 |
# Handle base64 encoded data
|
666 |
if decoded_data and decoded_data.startswith("base64:"):
|
|
|
685 |
return f"Invalid QR code data provided: {e}"
|
686 |
else:
|
687 |
return "No valid data source selected."
|
|
|
688 |
if mode == "Trained with Data":
|
689 |
+
return datachat_trained(data, query) # Ensure this function is defined
|
690 |
elif mode == "Chat about Data":
|
691 |
+
return datachat_simple(data, query) # Ensure this function is defined
|
692 |
else:
|
693 |
return "Invalid mode selected."
|
|
|
694 |
def create_interface():
|
695 |
"""Create a comprehensive Gradio interface with advanced features"""
|
696 |
css = """
|