import gradio as gr from typing import Dict, Union, List import json import uuid from storage.neo4j_dao import Neo4jDomainDAO from domain.chunk_d import DocumentD, ChunkD from query_pipeline.thesis_extractor import ThesisExtractor from query_pipeline.evaluation_engine import EvaluationEngine from proto.chunk_pb2 import Chunk, ChunkType from datetime import datetime import os import requests os.environ['NEO4J_USER'] = "neo4j" os.environ['NEO4J_PASSWORD'] = "dOIZwzF_GImgwjF-smChe60QGQgicq8ER8RUlZvornU" os.environ['NEO4J_URI'] = "neo4j+s://2317ae21.databases.neo4j.io" def check_internet_connection(): try: response = requests.get('http://www.google.com', timeout=5) if response.status_code == 200: return "Internet connection is available." else: return f"Received a response but not a successful status code: {response.status_code}" except requests.ConnectionError: return "No internet connection available." except requests.Timeout: return "The request timed out." def thesis_evaluation(thesis: str) -> str: thesis_document_d = DocumentD(file_path="", authors="user", publish_date="2024-06-18") thesis_chunk_d = ChunkD(chunk_text=thesis, chunk_type=ChunkType.CHUNK_TYPE_PAGE, chunk_index=0, parent_reference=thesis_document_d) thesis_entity_kg = ThesisExtractor().extract_relationships(thesis_chunk_d) with Neo4jDomainDAO() as neo4j_dao: full_db_kg = neo4j_dao.get_knowledge_graph() return EvaluationEngine(full_db_kg).evaluate_and_display_thesis(thesis_entity_kg) theme = gr.themes.Soft( primary_hue="cyan", secondary_hue="green", neutral_hue="slate", ) with gr.Blocks(theme=theme) as demo: gr.HTML("""

AthenaAIC MetisLLM Thesis Evaluation Tool

""") with gr.Row(): inp = gr.Textbox(placeholder="What is your thesis?", scale=3, lines=3, show_label=False) submit = gr.Button(scale=1, value="Evaluate") with gr.Row(): out = gr.HTML() with gr.Row(): checkInetButton = gr.Button(value="Check Internet Connection") with gr.Row(): status = gr.Textbox(placeholder="", scale=1, lines=1, show_label=False) submit.click(thesis_evaluation, inputs=inp, outputs=out) checkInetButton.click(check_internet_connection, outputs=status) demo.launch( auth=('athena-admin', 'athena') )