File size: 3,808 Bytes
e5251bf
 
 
 
 
 
 
 
 
 
 
 
e6c3948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: Knowledge Mapper
emoji: 🐢
colorFrom: green
colorTo: pink
sdk: gradio
sdk_version: 5.33.1
app_file: app.py
pinned: false
short_description: AI agent that transforms a text to knowledge map
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference




# 🧠 AI Knowledge Map Generator

This project is an advanced AI-powered application that transforms unstructured text, topics, or questions into structured, interactive knowledge graphs. It leverages a agent system built with LangChain to analyze input, extract key concepts, identify relationships, and generate both a visual map and a textual summary, providing a powerful tool for learning and research.

**Tags**: `agent-demo-track`

---

## ✨ Features

* **Multi-Source Input**: Accepts direct text, a topic to search on Wikipedia, or a question requiring a web search.
* **Agentic Workflow**: Uses a system of AI agents to route requests, extract concepts, find relationships, and summarize the findings.
* **Interactive Visualization**: Generates a dynamic and interactive knowledge graph using Pyvis, where you can move nodes and explore connections.
* **AI-Generated Summaries**: Provides a coherent, LLM-generated summary that explains the concepts and their relationships in plain language.
* **Multi-LLM Support**: Easily switch between various LLM providers, including Gemini, OpenAI, Groq, Anthropic, and more.
* **Downloadable Output**: Allows you to download the generated knowledge graph as a self-contained HTML file.
---


## 🛠️ How It Works


1.  **Router Agent**: First the agent analyzes your input. It decides if the text is self-contained, if it needs to perform a Wikipedia search for a general topic, or if it requires a real-time web search.
2.  **Extraction Agent**: After gathering the necessary text, the agent reads it and extracts the most important concepts, assigning each an importance score.
3.  **Linking Agent**: The agent analyzes the extracted concepts and the source text to identify all the meaningful relationships between them, describing each link (e.g., "is a type of," "enables," "is composed of").
4.  **Summarizer Agent**: Finally, the agent takes the list of concepts and their relationships and generates a concise, human-readable summary of the entire knowledge graph.
5.  **Rendering**: The system uses the extracted data to render the interactive `pyvis` graph and display the summary in the Gradio interface.

---


## 🚀 Video Overview

Watch this short video for a complete overview of the app's purpose, features, and a demonstration of how to use it.

* **Video Link:** [**Knowledge Map Generator**](https://www.youtube.com/watch?v=z59nZBBHsko&)


---

## ⚙️ Setup and Configuration
To run this project locally, you'll need to install the required Python packages and configure your environment variables.

### 1. Software Dependencies
All the necessary Python libraries are listed in the requirements.txt file. You can install them all with a single command:
```bash
pip install -r requirements.txt
```

### 2. Environment Variables
This application requires API keys to connect to services. The recommended way to manage these is to create a .env file in the root directory of your project.

Create a file named .env and add the following content.
```bash
# ---------------- LangSmith Tracing (Recommended for Debugging) ----------------
# Set this to 'true' to enable detailed tracing of your agent's execution in LangSmith.
LANGCHAIN_TRACING_V2="true"
# Your LangSmith API key, available from the LangSmith settings page.
LANGCHAIN_API_KEY="YOUR_LANGSMITH_API_KEY_HERE"


# ---------------- Required Tool APIs ----------------
# The agent uses Tavily for its web search tool.
TAVILY_API_KEY="YOUR_TAVILY_API_KEY_HERE"
```