Update app.py
Browse files
app.py
CHANGED
@@ -87,13 +87,18 @@ def respond(message, system_prompt, history, model, temperature, num_calls, use_
|
|
87 |
logging.info(f"System Prompt: {system_prompt}")
|
88 |
|
89 |
try:
|
|
|
90 |
for main_content, sources in get_response_with_search(message, model, num_calls=num_calls, temperature=temperature, use_embeddings=use_embeddings, system_prompt=system_prompt):
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
94 |
except Exception as e:
|
95 |
logging.error(f"Error with {model}: {str(e)}")
|
96 |
-
|
|
|
97 |
|
98 |
def create_web_search_vectors(search_results):
|
99 |
embed = get_embeddings()
|
@@ -192,8 +197,7 @@ css = """
|
|
192 |
"""
|
193 |
|
194 |
demo = gr.ChatInterface(
|
195 |
-
fn=
|
196 |
-
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=True, render=False),
|
197 |
additional_inputs=[
|
198 |
gr.Textbox(label="System Prompt", lines=5, value=DEFAULT_SYSTEM_PROMPT),
|
199 |
gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3]),
|
|
|
87 |
logging.info(f"System Prompt: {system_prompt}")
|
88 |
|
89 |
try:
|
90 |
+
full_response = ""
|
91 |
for main_content, sources in get_response_with_search(message, model, num_calls=num_calls, temperature=temperature, use_embeddings=use_embeddings, system_prompt=system_prompt):
|
92 |
+
full_response += main_content
|
93 |
+
yield history + [(message, full_response)]
|
94 |
+
|
95 |
+
if sources:
|
96 |
+
full_response += f"\n\nSources:\n{sources}"
|
97 |
+
yield history + [(message, full_response)]
|
98 |
except Exception as e:
|
99 |
logging.error(f"Error with {model}: {str(e)}")
|
100 |
+
error_message = f"An error occurred with the {model} model: {str(e)}. Please try again or select a different model."
|
101 |
+
yield history + [(message, error_message)]
|
102 |
|
103 |
def create_web_search_vectors(search_results):
|
104 |
embed = get_embeddings()
|
|
|
197 |
"""
|
198 |
|
199 |
demo = gr.ChatInterface(
|
200 |
+
fn=respond,
|
|
|
201 |
additional_inputs=[
|
202 |
gr.Textbox(label="System Prompt", lines=5, value=DEFAULT_SYSTEM_PROMPT),
|
203 |
gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[3]),
|