Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db):
|
|
58 |
# LLM initialisieren
|
59 |
def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db):
|
60 |
if vector_db is None:
|
61 |
-
return None, "Datenbank wurde nicht erstellt!"
|
62 |
llm_name = list_llm[llm_option]
|
63 |
qa_chain = initialize_llmchain(llm_name, llm_temperature, max_tokens, top_k, vector_db)
|
64 |
return qa_chain, "QA-Kette initialisiert. Chatbot ist bereit!"
|
@@ -71,8 +71,7 @@ def conversation(qa_chain, message, history):
|
|
71 |
return qa_chain, [{"role": "system", "content": "Bitte eine Frage eingeben!"}], history
|
72 |
response = qa_chain.invoke({"question": message, "chat_history": history})
|
73 |
response_text = response.get("answer", "Keine Antwort verfügbar.")
|
74 |
-
|
75 |
-
formatted_response = history + [{"role": "assistant", "content": response_text}]
|
76 |
return qa_chain, formatted_response, formatted_response
|
77 |
|
78 |
# Demo erstellen
|
@@ -88,7 +87,7 @@ def demo():
|
|
88 |
slider_maxtokens = gr.Slider(128, 2048, 512, label="Max Tokens")
|
89 |
slider_topk = gr.Slider(1, 10, 3, label="Top-k")
|
90 |
qachain_btn = gr.Button("Initialisiere QA-Chatbot")
|
91 |
-
chatbot = gr.Chatbot(label="Chatbot", height=400)
|
92 |
msg = gr.Textbox(label="Frage stellen")
|
93 |
submit_btn = gr.Button("Absenden")
|
94 |
|
|
|
58 |
# LLM initialisieren
|
59 |
def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db):
|
60 |
if vector_db is None:
|
61 |
+
return None, "Fehler: Datenbank wurde nicht erstellt!"
|
62 |
llm_name = list_llm[llm_option]
|
63 |
qa_chain = initialize_llmchain(llm_name, llm_temperature, max_tokens, top_k, vector_db)
|
64 |
return qa_chain, "QA-Kette initialisiert. Chatbot ist bereit!"
|
|
|
71 |
return qa_chain, [{"role": "system", "content": "Bitte eine Frage eingeben!"}], history
|
72 |
response = qa_chain.invoke({"question": message, "chat_history": history})
|
73 |
response_text = response.get("answer", "Keine Antwort verfügbar.")
|
74 |
+
formatted_response = history + [{"role": "user", "content": message}, {"role": "assistant", "content": response_text}]
|
|
|
75 |
return qa_chain, formatted_response, formatted_response
|
76 |
|
77 |
# Demo erstellen
|
|
|
87 |
slider_maxtokens = gr.Slider(128, 2048, 512, label="Max Tokens")
|
88 |
slider_topk = gr.Slider(1, 10, 3, label="Top-k")
|
89 |
qachain_btn = gr.Button("Initialisiere QA-Chatbot")
|
90 |
+
chatbot = gr.Chatbot(label="Chatbot", height=400, type="messages")
|
91 |
msg = gr.Textbox(label="Frage stellen")
|
92 |
submit_btn = gr.Button("Absenden")
|
93 |
|