File size: 2,415 Bytes
8c27dd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from dotenv import load_dotenv
from crew.til import TilCrew
from streamlit_extras.capture import stdout
load_dotenv()



def main():
    st.markdown("<div class='container'>", unsafe_allow_html=True)

    st.markdown(
        """
        <div class="centered">
            <p class="title">Today I Learnt Feedback</p>
            <p class="description">Feedback on Today I Learnt</p>
        </div>
        """,
        unsafe_allow_html=True
    )
    til_content = st.text_area('Enter what you learnt today:',
                               "* Quantization is the process of reducing the size of LLM models by reducing the underlying weights.\n"
                               "* The weights are reduced by scaling down the datatypes from a datatype that takes larger space to a data type that takes a smaller space, this is also known as downcasting.\n"
                               "* Quantization offers benefits such as reduced storage space usage and faster computation.\n"
                               "* Disadvantages: Answers are less precise\n"
                               "* I learnt how to use Go Routines to handle concurrency in React.\n",
                               key='til_content', help='Enter what you learnt today')

    if st.button("Get Feedback"):
        with st.status(
            "🤖 **Analysing TIL...**", state="running", expanded=True
        ) as status:
            with st.container(height=500, border=False):
                log_container = st.empty()
                with stdout(log_container.code, terminator=""):
                    feedback = TilCrew()
                    inputs = {"content": til_content}
                    results = feedback.kickoff(inputs=inputs)["feedback"]
            status.update(
                label="✅ Feedback ready!",
                state="complete",
                expanded=False,
            )

        for result in results:
            st.markdown(f"#### TIL: {result['til']}")
            st.markdown(f"**Feedback:** {result['feedback']}")
            if result['feedback'] == "not_ok":
                st.markdown(f"**Criteria:** {result['feedback_criteria']}")
                st.markdown(f"**Reason:** {result['reason']}")
                if result.get('suggestion') is not None:
                    st.markdown(f"**Suggestion:** {result['suggestion']}")


if __name__ == "__main__":
    main()