File size: 3,009 Bytes
55c4810
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from utils import get_api_key, get_response

def main():

    st.header('Welcome to SciDocuParse! πŸ§‘β€πŸ”¬πŸ“š')
    st.write('A scientific document parser, particularly specializing in graph analysis πŸ“Š and data interpretation πŸ”.')

    st.session_state["thought_process"] = ""
    st.session_state["response"] = ""

    with st.sidebar:
        st.header('SciDocuParse Sidebar πŸ”§')
        st.caption('A tool to help you analyze scientific papers and documents efficiently! πŸ“')
        
        paper = st.text_area('Paste scientific document citation here πŸ§‘β€πŸ«',
                                        """@article{wang2020automated,
        title={Automated diabetic retinopathy grading and lesion detection based on the modified R-FCN object-detection algorithm},
        author={Wang, Jialiang and Luo, Jianxu and Liu, Bin and Feng, Rui and Lu, Lina and Zou, Haidong},
        journal={IET Computer Vision},
        volume={14},
        number={1},
        pages={1--8},
        year={2020},
        publisher={Wiley Online Library}
        }""", height=350, help='Paste your document citation in BiBtex format.')
    
        if not paper:
            st.error('Provide a citation first! ⚠️')

        user_prompt = st.text_area("Enter your query for analysis πŸ”:", 
                                    "Summarize this document and highlight key findings in graphs πŸ“ˆ")

        persona = "You are a master Scientific Graph Analyzer skilled in interpreting graphs across all fields. Analyze trends (linear/exponential growth, correlations, outliers) and statistical patterns (mean, variance). Summarize key findings in plain language, Expalin data about causality, anomalies, or data limitations. Prioritize clarity: ensure outputs are accessible to technical and non-technical audiences. Combine technical precision with intuitive communication to deliver accurate, user-friendly interpretations."

        user_prompt = persona + paper + user_prompt

        # api_key = get_api_key()
        if st.button('Analyze with LLM πŸš€'):
            with st.spinner('Processing your document...'):
                api_key = get_api_key()

                thought_process, response = get_response(user_prompt, api_key) # uncommenting it to save tokens

                st.session_state["thought_process"] = thought_process
                st.session_state["response"] = response
    
    if "thought_process" in st.session_state and "response" in st.session_state:
        if len(st.session_state["thought_process"]) >= 1 and len(st.session_state["response"]) >= 1:
            with st.expander('Show thought process πŸ’­'):
                st.caption(thought_process)
            
            st.subheader('RESPONSE πŸ“')
            st.write(response)
            
    st.caption('SciDocuParse is made by John Manuel Carado')
    st.caption('Intelligent Systems course in WVSU - CICT, Midterm Requirement')
        
if __name__ == '__main__':
    main()