File size: 4,233 Bytes
aa4411c
 
 
 
2d9fd1e
aa4411c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e96c9b
aa4411c
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
 
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
3e96c9b
 
aa4411c
 
 
 
 
 
 
 
 
 
 
4e3fc3a
aa4411c
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import os
from modelscope_studio.components.pro.chatbot import ChatbotActionConfig, ChatbotBotConfig, ChatbotUserConfig, ChatbotWelcomeConfig

# Env
api_key = os.getenv('OPENROUTER_API_KEY')
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ASSETS_DIR = os.path.join(BASE_DIR, "assets")
QWEN_LOGO_PATH = os.path.join(ASSETS_DIR, "requirementsassistant.png")


# Save history in browser
save_history = True


# Chatbot Config
def user_config(disabled_actions=None):
    return ChatbotUserConfig(
        class_names=dict(content="user-message-content"),
        actions=[
            "copy", "edit",
            ChatbotActionConfig(
                action="delete",
                popconfirm=dict(title="Delete the message",
                                description="Are you sure to delete this message?",
                                okButtonProps=dict(danger=True)))
        ],
        disabled_actions=disabled_actions)


def bot_config(disabled_actions=None):
    return ChatbotBotConfig(actions=[
        "copy", "edit",
        ChatbotActionConfig(
            action="retry",
            popconfirm=dict(
                title="Regenerate the message",
                description="Regenerate the message will also delete all subsequent messages.",
                okButtonProps=dict(danger=True))),
        ChatbotActionConfig(action="delete",
                            popconfirm=dict(
                                title="Delete the message",
                                description="Are you sure to delete this message?",
                                okButtonProps=dict(danger=True)))
    ],
                            avatar=QWEN_LOGO_PATH,
                            disabled_actions=disabled_actions)


def welcome_config():
    return ChatbotWelcomeConfig(
        variant="borderless",
        icon=QWEN_LOGO_PATH,
        title="Hello, I'm Requirements Assistant",
        description="Upload your requirements document and ask a question. I will help show compliance information.",
        prompts=dict(
            title="How can I help you today?",
            styles={
                "list": {
                    "width": '100%',
                },
                "item": {
                    "flex": 1,
                },
            },
            items=[{
                "label":
                "Check Requirements",
                "children": [{
                    "description": "What are lighting requirements when using intermediate or wet-weather tyres?",
                }, {
                    "description": "When using intermediate or wet-weather tyres in a race without a safety car, what are the regulations for the lights?",
                }, {
                    "description": "When there is a safety car during a race, when should lapped cars unlap themselves?",
                }]
            }]),
    )
    
DEFAULT_SUGGESTIONS = [{
    "label": "Requirements help",
    "value": "Requirements help",
    "children": [{
        "label": "Summarize spec",
        "value": "Summarize the uploaded requirements document and list the key deliverables."
    }, {
        "label": "Find gaps",
        "value": "Identify ambiguities, gaps, or missing details in the requirements."
    }, {
        "label": "Clarifying questions",
        "value": "Draft clarifying questions for the product owner based on the spec."
    }]
}, {
    "label": "Generate outputs",
    "value": "Generate outputs",
    "children": [{
        "label": "Jira ticket",
        "value": "Create a Jira-style ticket with summary, scope, acceptance criteria, and risks."
    }, {
        "label": "Compliance matrix",
        "value": "Generate a compliance matrix mapping requirements to tests or standards."
    }, {
        "label": "Risk/assumptions",
        "value": "List risks, assumptions, and dependencies for this requirement."
    }]
}]

DEFAULT_SYS_PROMPT = "You are a helpful and harmless assistant."

MIN_THINKING_BUDGET = 1

MAX_THINKING_BUDGET = 38

DEFAULT_THINKING_BUDGET = 38

DEFAULT_LOCALE = 'en_US'

DEFAULT_THEME = {
    "token": {
        "colorPrimary": "#6A57FF",
    }
}

DEFAULT_SETTINGS = {
    "sys_prompt": DEFAULT_SYS_PROMPT,
    "uploaded_file": None,
}