File size: 2,098 Bytes
e51667a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def init_state(session_state, config):
    initial_prompt_engineering_dict = config["PROMPT_ENGINEERING_DICT"]
    if "messages" not in session_state:
        session_state.messages = []

    if "tokens_used" not in session_state:
        session_state.tokens_used = 0

    if "tps" not in session_state:
        session_state.tps = 0

    if "temp" not in session_state:
        session_state.temp = 0.8

    if "history" not in session_state:
        session_state.history = [
            [
                initial_prompt_engineering_dict["SYSTEM_INSTRUCTION"],
                initial_prompt_engineering_dict["SYSTEM_RESPONSE"],
            ]
        ]

    if "n_crawl" not in session_state:
        session_state.n_crawl = 5

    if "repetion_penalty" not in session_state:
        session_state.repetion_penalty = 1

    if "rag_enabled" not in session_state:
        session_state.rag_enabled = True

    if "chat_bot" not in session_state:
        session_state.chat_bot = "Mixtral 8x7B v0.1"

    if "search_vendor" not in session_state:
        session_state.search_vendor = "Bing"

    if "system_instruction" not in session_state:
        session_state.system_instruction = initial_prompt_engineering_dict[
            "SYSTEM_INSTRUCTION"
        ]

    if "system_response" not in session_state:
        session_state.system_instruction = initial_prompt_engineering_dict[
            "SYSTEM_RESPONSE"
        ]

    if "pre_context" not in session_state:
        session_state.pre_context = initial_prompt_engineering_dict["PRE_CONTEXT"]

    if "post_context" not in session_state:
        session_state.post_context = initial_prompt_engineering_dict["POST_CONTEXT"]

    if "pre_prompt" not in session_state:
        session_state.pre_prompt = initial_prompt_engineering_dict["PRE_PROMPT"]

    if "post_prompt" not in session_state:
        session_state.post_prompt = initial_prompt_engineering_dict["POST_PROMPT"]

    if "pass_prev" not in session_state:
        session_state.pass_prev = False

    if "chunk_size" not in session_state:
        session_state.chunk_size = 512