File size: 1,018 Bytes
f8bf7df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr


class UISettings:
    """

    Utility class for managing UI settings.



    This class provides static methods for toggling UI components, such as a sidebar.

    """
    @staticmethod
    def toggle_sidebar(state):
        """

        Toggle the visibility state of a UI component.



        Parameters:

            state: The current state of the UI component.



        Returns:

            Tuple: A tuple containing the updated UI component state and the new state.

        """
        state = not state
        return gr.update(visible=state), state

    @staticmethod
    def feedback(data: gr.LikeData):
        """

        Process user feedback on the generated response.



        Parameters:

            data (gr.LikeData): Gradio LikeData object containing user feedback.

        """
        if data.liked:
            print("You upvoted this response: " + data.value)
        else:
            print("You downvoted this response: " + data.value)