Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
6d421b8
1
Parent(s):
ff7d32c
chore:为一些重要API增加命名,更新llama_index和gradio版本
Browse files- ChuanhuChatbot.py +5 -4
- modules/models/base_model.py +1 -0
- modules/presets.py +1 -1
- requirements.txt +2 -2
ChuanhuChatbot.py
CHANGED
@@ -27,6 +27,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
27 |
user_name = gr.State("")
|
28 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
29 |
user_question = gr.State("")
|
|
|
30 |
user_api_key = gr.State(my_api_key)
|
31 |
current_model = gr.State(create_new_model)
|
32 |
|
@@ -277,7 +278,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
277 |
current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
|
278 |
current_model.set_user_identifier(user_name)
|
279 |
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), get_history_names(False, user_name)
|
280 |
-
demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown])
|
281 |
chatgpt_predict_args = dict(
|
282 |
fn=predict,
|
283 |
inputs=[
|
@@ -329,7 +330,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
329 |
user_input.submit(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
|
330 |
user_input.submit(**get_usage_args)
|
331 |
|
332 |
-
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
|
333 |
submitBtn.click(**get_usage_args)
|
334 |
|
335 |
index_files.change(handle_file_upload, [current_model, index_files, chatbot], [index_files, chatbot, status_display])
|
@@ -386,10 +387,10 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
386 |
two_column.change(update_doc_config, [two_column], None)
|
387 |
|
388 |
# LLM Models
|
389 |
-
keyTxt.change(set_key, [current_model, keyTxt], [user_api_key, status_display]).then(**get_usage_args)
|
390 |
keyTxt.submit(**get_usage_args)
|
391 |
single_turn_checkbox.change(set_single_turn, [current_model, single_turn_checkbox], None)
|
392 |
-
model_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display, lora_select_dropdown], show_progress=True)
|
393 |
model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [like_dislike_area], show_progress=False)
|
394 |
lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display], show_progress=True)
|
395 |
|
|
|
27 |
user_name = gr.State("")
|
28 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
29 |
user_question = gr.State("")
|
30 |
+
assert type(my_api_key)==str
|
31 |
user_api_key = gr.State(my_api_key)
|
32 |
current_model = gr.State(create_new_model)
|
33 |
|
|
|
278 |
current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
|
279 |
current_model.set_user_identifier(user_name)
|
280 |
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), get_history_names(False, user_name)
|
281 |
+
demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown], api_name="load")
|
282 |
chatgpt_predict_args = dict(
|
283 |
fn=predict,
|
284 |
inputs=[
|
|
|
330 |
user_input.submit(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
|
331 |
user_input.submit(**get_usage_args)
|
332 |
|
333 |
+
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args, api_name="predict").then(**end_outputing_args)
|
334 |
submitBtn.click(**get_usage_args)
|
335 |
|
336 |
index_files.change(handle_file_upload, [current_model, index_files, chatbot], [index_files, chatbot, status_display])
|
|
|
387 |
two_column.change(update_doc_config, [two_column], None)
|
388 |
|
389 |
# LLM Models
|
390 |
+
keyTxt.change(set_key, [current_model, keyTxt], [user_api_key, status_display], api_name="set_key").then(**get_usage_args)
|
391 |
keyTxt.submit(**get_usage_args)
|
392 |
single_turn_checkbox.change(set_single_turn, [current_model, single_turn_checkbox], None)
|
393 |
+
model_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display, lora_select_dropdown], show_progress=True, api_name="get_model")
|
394 |
model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [like_dislike_area], show_progress=False)
|
395 |
lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display], show_progress=True)
|
396 |
|
modules/models/base_model.py
CHANGED
@@ -230,6 +230,7 @@ class BaseLLMModel:
|
|
230 |
similarity_top_k=5,
|
231 |
vector_store=index._vector_store,
|
232 |
docstore=index._docstore,
|
|
|
233 |
)
|
234 |
query_bundle = QueryBundle(real_inputs)
|
235 |
nodes = query_object.retrieve(query_bundle)
|
|
|
230 |
similarity_top_k=5,
|
231 |
vector_store=index._vector_store,
|
232 |
docstore=index._docstore,
|
233 |
+
response_synthesizer=None
|
234 |
)
|
235 |
query_bundle = QueryBundle(real_inputs)
|
236 |
nodes = query_object.retrieve(query_bundle)
|
modules/presets.py
CHANGED
@@ -164,7 +164,7 @@ ALREADY_CONVERTED_MARK = "<!-- ALREADY CONVERTED BY PARSER. -->"
|
|
164 |
|
165 |
small_and_beautiful_theme = gr.themes.Soft(
|
166 |
primary_hue=gr.themes.Color(
|
167 |
-
c50="
|
168 |
c100="rgba(2, 193, 96, 0.2)",
|
169 |
c200="#02C160",
|
170 |
c300="rgba(2, 193, 96, 0.32)",
|
|
|
164 |
|
165 |
small_and_beautiful_theme = gr.themes.Soft(
|
166 |
primary_hue=gr.themes.Color(
|
167 |
+
c50="rgba(2, 193, 96, 0.1)",
|
168 |
c100="rgba(2, 193, 96, 0.2)",
|
169 |
c200="#02C160",
|
170 |
c300="rgba(2, 193, 96, 0.32)",
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
gradio==3.
|
2 |
mdtex2html
|
3 |
pypinyin
|
4 |
tiktoken
|
@@ -7,7 +7,7 @@ tqdm
|
|
7 |
colorama
|
8 |
duckduckgo_search
|
9 |
Pygments
|
10 |
-
llama_index==0.5.
|
11 |
langchain
|
12 |
markdown
|
13 |
PyPDF2
|
|
|
1 |
+
gradio==3.28.0
|
2 |
mdtex2html
|
3 |
pypinyin
|
4 |
tiktoken
|
|
|
7 |
colorama
|
8 |
duckduckgo_search
|
9 |
Pygments
|
10 |
+
llama_index==0.5.25
|
11 |
langchain
|
12 |
markdown
|
13 |
PyPDF2
|