File size: 2,123 Bytes
9041389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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

os.environ['OPENAI_API_KEY'] = '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'

os.environ['NEO4J_USER'] = "neo4j"
os.environ['NEO4J_PASSWORD'] = "dOIZwzF_GImgwjF-smChe60QGQgicq8ER8RUlZvornU"
os.environ['NEO4J_URI'] = "neo4j+s://2317ae21.databases.neo4j.io"

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(""" 
            <div style="background-color: rgb(171, 188, 251);">
                <div style="background-color: rgb(151, 168, 231); padding-top: 2px; padding-bottom: 7px; text-align: center;">
                    <h1>AthenaAIC MetisLLM Thesis Evaluation Tool</h1>
                </div>
            </div>""")
    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()

    submit.click(thesis_evaluation, inputs=inp, outputs=out)

demo.launch(
    auth=('athena-admin', 'athena'),
    share=True
)