Spaces:
Runtime error
Runtime error
Update app.py
Browse files138 unmodified lines13914014114214314414514614714814915015138 unmodified lines190191192193194195196197138 unmodified lineslogging.info(f"Number of API Calls: {num_calls}")logging.info(f"Use Embeddings: {use_embeddings}")logging.info(f"System Prompt: {system_prompt}")# Convert gradio history to the format expected by get_response_with_searchchat_history = []for human, assistant in history:chat_history.append({"role": "user", "content": human})if assistant:chat_history.append({"role": "assistant", "content": assistant})try:full_response = ""38 unmodified linesdef create_gradio_interface():custom_placeholder = "Enter your question here for web search."demo = gr.ChatInterface(fn=respond,additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=True, render=False),additional_inputs=[gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=6, label="System Prompt", placeholder="Enter your system prompt here"),138 unmodified lines13914014114214314414514614714814915015115215315415515615715815938 unmodified lines198199200201202203204205206207208209210211212213138 unmodified lineslogging.info(f"Number of API Calls: {num_calls}")logging.info(f"Use Embeddings: {use_embeddings}")logging.info(f"System Prompt: {system_prompt}")logging.info(f"History: {history}") # Log the history for debugging# Convert gradio history to the format expected by get_response_with_searchchat_history = []if history:for entry in history:if isinstance(entry, (list, tuple)) and len(entry) == 2:human, assistant = entrychat_history.append({"role": "user", "content": human})if assistant:chat_history.append({"role": "assistant", "content": assistant})elif isinstance(entry, str):# If it's a string, assume it's a user messagechat_history.append({"role": "user", "content": entry})# Ignore any other formatstry:full_response = ""38 unmodified linesdef create_gradio_interface():custom_placeholder = "Enter your question here for web search."async def wrapped_respond(*args):try:async for response in respond(*args):yield responseexcept Exception as e:logging.error(f"Error in wrapped_respond: {str(e)}")yield f"An error occurred: {str(e)}"demo = gr.ChatInterface(fn=wrapped_respond, # Use the wrapped versionadditional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=True, render=False),additional_inputs=[gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=6, label="System Prompt", placeholder="Enter your system prompt here"),
app.py+21-5