import gradio as gr from transformers import pipeline # Load a free Hugging Face model (small + free to run) generator = pipeline("text2text-generation", model="google/flan-t5-small") # Agent function def agentic_ai(user_input): # Step 1: Analyze input analysis_prompt = f"Analyze the intent of this input: {user_input}" analysis = generator(analysis_prompt, max_length=50, do_sample=False)[0]['generated_text'] # Step 2: Decide what to do (simple rule-based agent) if "summarize" in user_input.lower(): task_prompt = f"Summarize this text in 2 lines: {user_input}" elif "question" in user_input.lower() or "?" in user_input: task_prompt = f"Answer this question briefly: {user_input}" else: task_prompt = f"Generate a helpful response: {user_input}" # Step 3: LLM Response response = generator(task_prompt, max_length=80, do_sample=False)[0]['generated_text'] # Step 4: Return both analysis + final response return f"šŸ”Ž Agent Analysis: {analysis}\n\nšŸ’” Agent Response: {response}" # Gradio UI demo = gr.Interface( fn=agentic_ai, inputs=gr.Textbox(lines=3, placeholder="Type your text here..."), outputs="text", title="šŸ¤– Mini Agentic LLM App", description="Smallest free demo of an Agentic AI using NLP + LLM on Hugging Face & Gradio. Input few lines or paragraph with question and Click Submit" ) if __name__ == "__main__": demo.launch()