import gradio as gr from fpl_client import FPLClient from nlp_utils import process_query # Theme builder # gr.themes.builder() theme = gr.themes.Soft( primary_hue="sky", neutral_hue="slate", ) # Initialize the FPL client fpl_client = FPLClient() # Function to handle user input and generate a response def chatbot_response(query): response = process_query(query, fpl_client) # if response if a JSON boject iterate over the elements and conver is a list like "a": "b" "/n" "c": "d" if isinstance(response, dict): response = "\n".join([f"{key}: {value}" for key, value in response.items()]) return response # Set up the Gradio interface iface = gr.Interface( fn=chatbot_response, inputs=gr.Textbox(label="Ask our FPL Expert"), outputs=gr.Textbox(label="Hope it helps!"), theme=theme, title="FPL Chatbot" ) if __name__ == "__main__": iface.launch()