# app.py from gradio_client import Client import gradio as gr from tools import add_numbers def chatbot_function_calling(user_message, history): if "add" in user_message.lower(): # Przykładowe parsowanie komendy try: parts = user_message.split() a = int(parts[1]) b = int(parts[2]) result = add_numbers(a, b) response = f"Result: {result}" except Exception as e: response = f"Error: {str(e)}" else: response = "I'm sorry, I don't understand the command." history.append((user_message, response)) return history, history iface = gr.ChatInterface( fn=chatbot_function_calling, chatbot=gr.Chatbot(height=400), textbox=gr.Textbox(show_label=False, placeholder="Send a message..."), title="Function Calling Chatbot", description="This chatbot can perform simple operations like addition." ) iface.launch(server_name="0.0.0.0", server_port=7860)