File size: 2,399 Bytes
8ab290f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import gradio as gr
from transformers import pipeline

# Load small + free LLM
generator = pipeline("text2text-generation", model="google/flan-t5-small")

# --- Agent 1: Summarizer + Knowledge Graph Builder ---
def doc_agent(user_text):
    # Step 1: Summarize
    summary_prompt = f"Summarize this in 3 lines: {user_text}"
    summary = generator(summary_prompt, max_length=80, do_sample=False)[0]['generated_text']

    # Step 2: Build a "mini knowledge graph" (keywords as nodes)
    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}"

# --- Agent 2: Career Skill Recommender ---
def career_agent(user_goal):
    # Step 1: Analyze career intent
    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']

    # Step 2: Recommend roadmap
    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}"

# --- Combined Agent Controller ---
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 UI ---
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()