| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| generator = pipeline("text2text-generation", model="google/flan-t5-small") |
|
|
| |
| def doc_agent(user_text): |
| |
| summary_prompt = f"Summarize this in 3 lines: {user_text}" |
| summary = generator(summary_prompt, max_length=80, do_sample=False)[0]['generated_text'] |
|
|
| |
| keyword_prompt = f"Extract 5 important keywords from this text: {user_text}" |
| keywords = generator(keyword_prompt, max_length=40, do_sample=False)[0]['generated_text'] |
| graph_nodes = [kw.strip() for kw in keywords.split(",") if kw.strip()] |
| graph_repr = " β ".join(graph_nodes) if graph_nodes else "No graph generated." |
|
|
| return f"π Summary:\n{summary}\n\nπΈοΈ Knowledge Graph:\n{graph_repr}" |
|
|
| |
| def career_agent(user_goal): |
| |
| analysis_prompt = f"Identify skill gap for this career goal: {user_goal}" |
| analysis = generator(analysis_prompt, max_length=50, do_sample=False)[0]['generated_text'] |
|
|
| |
| roadmap_prompt = f"Suggest a 3-step learning roadmap for: {user_goal}" |
| roadmap = generator(roadmap_prompt, max_length=80, do_sample=False)[0]['generated_text'] |
|
|
| return f"π Gap Analysis:\n{analysis}\n\nπ οΈ Skill Roadmap:\n{roadmap}" |
|
|
| |
| def agentic_ai(user_input, mode): |
| if mode == "Document Insight": |
| return doc_agent(user_input) |
| elif mode == "Career Roadmap": |
| return career_agent(user_input) |
| else: |
| return "β οΈ Please choose a valid mode." |
|
|
| |
| demo = gr.Interface( |
| fn=agentic_ai, |
| inputs=[ |
| gr.Textbox(lines=4, placeholder="Enter text or career goal..."), |
| gr.Radio(["Document Insight", "Career Roadmap"], label="Choose Mode") |
| ], |
| outputs="text", |
| title="π Mini Agentic AI MVP", |
| description=""" |
| This smallest MVP demonstrates: |
| - π Document Summarization |
| - πΈοΈ Knowledge Graph (mini keyword graph) |
| - π§βπ» Career Skill Gap Analysis |
| - π οΈ Personalized 3-step Roadmap |
| |
| Built with free Hugging Face + Gradio. Optimized for AI Research use cases. |
| """ |
| ) |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|