File size: 4,600 Bytes
3943768
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
input_args_list = [
    "model_state",
    "my_db_state",
    "selection_docs_state",
    "requests_state",
    "roles_state",
]

no_default_param_names = [
    "instruction",
    "iinput",
    "context",
    "instruction_nochat",
    "iinput_nochat",
    "h2ogpt_key",
    "model_lock",
]

gen_hyper0 = [
    "num_beams",
    "max_new_tokens",
    "min_new_tokens",
    "early_stopping",
    "max_time",
    "repetition_penalty",
    "num_return_sequences",
    "do_sample",
    "seed",
]
gen_hyper = ["temperature", "top_p", "top_k", "penalty_alpha"] + gen_hyper0
reader_names = [
    "image_audio_loaders",
    "pdf_loaders",
    "url_loaders",
    "jq_schema",
    "extract_frames",
    "llava_prompt",
]

eval_func_param_names = (
        ["instruction", "iinput", "context", "stream_output", "enable_caching", "prompt_type", "prompt_dict", "chat_template"]
        + gen_hyper
        + [
            "chat",
            "instruction_nochat",
            "iinput_nochat",
            "langchain_mode",
            "add_chat_history_to_context",
            "langchain_action",
            "langchain_agents",
            "top_k_docs",
            "chunk",
            "chunk_size",

            "document_subset",
            "document_choice",
            "document_source_substrings",
            "document_source_substrings_op",
            "document_content_substrings",
            "document_content_substrings_op",

            "pre_prompt_query",
            "prompt_query",
            "pre_prompt_summary",
            "prompt_summary",
            "hyde_llm_prompt",
            "all_docs_start_prompt",
            "all_docs_finish_prompt",

            "user_prompt_for_fake_system_prompt",
            "json_object_prompt",
            "json_object_prompt_simpler",
            "json_code_prompt",
            "json_code_prompt_if_no_schema",
            "json_schema_instruction",
            "json_preserve_system_prompt",
            "json_object_post_prompt_reminder",
            "json_code_post_prompt_reminder",
            "json_code2_post_prompt_reminder",

            "system_prompt",
        ]
        + reader_names
        + [
            "visible_models",
            "visible_image_models",
            "image_size",
            "image_quality",
            "image_guidance_scale",
            "image_num_inference_steps",
            "h2ogpt_key",
            "add_search_to_context",
            "chat_conversation",
            "text_context_list",
            "docs_ordering_type",
            "min_max_new_tokens",
            "max_input_tokens",
            "max_total_input_tokens",
            "docs_token_handling",
            "docs_joiner",
            "hyde_level",
            "hyde_template",
            "hyde_show_only_final",
            "doc_json_mode",
            "metadata_in_context",
            "chatbot_role",
            "speaker",
            "tts_language",
            "tts_speed",
            "image_file",
            "image_control",
            "images_num_max",
            "image_resolution",
            "image_format",
            "rotate_align_resize_image",
            "video_frame_period",
            "image_batch_image_prompt",
            "image_batch_final_prompt",
            "image_batch_stream",
            "visible_vision_models",
            "video_file",
            "response_format",
            "guided_json",
            "guided_regex",
            "guided_choice",
            "guided_grammar",
            "guided_whitespace_pattern",

            "model_lock",
            "client_metadata",
        ]
)

# form evaluate defaults for submit_nochat_api
eval_func_param_names_defaults = eval_func_param_names.copy()
for k in no_default_param_names:
    if k in eval_func_param_names_defaults:
        eval_func_param_names_defaults.remove(k)

eval_extra_columns = ["prompt", "response", "score", "sources"]

# override default_kwargs if user_kwargs None for args evaluate() uses that are not just in model_state
# ensure prompt_type consistent with prep_bot(), so nochat API works same way
# see how default_kwargs is set in gradio_runner.py
key_overrides = ["prompt_type", "prompt_dict", "chat_template"]

in_model_state_and_evaluate = ['prompt_type', 'prompt_dict', 'chat_template',
                               'visible_models', 'h2ogpt_key', 'images_num_max',
                               'image_resolution',
                               'image_format', 'video_frame_period', 'visible_vision_models']

image_quality_choices = ['standard', 'hd', 'quick', 'manual']
image_size_default = "1024x1024"