File size: 5,444 Bytes
be0aabb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# πŸ”Ž Discover Agent

Discover Agent is an AI-powered web search application that utilizes **LangGraph Agents**, **DuckDuckGo** search, and Groq-hosted **DeepSeek-R1 Distill LLaMA 70B** to dynamically fetch and synthesize information. Unlike traditional workflows, this project dynamically decides when, how and whether to use tools during execution, showcasing the power of autonomous **AI agents** in navigating uncertain tasks.

![img.png](img.png)

---

## πŸš€ Project Overview

This project creates a **Discover Agent** that:

* Accepts natural language queries via a web UI,
* Uses DeepSeek-R1 LLaMA 70B Distill (hosted on Groq) as the reasoning LLM,
* Employs tools such as:
  * DuckDuckGo Search for real-time web lookup, 
  * Datetime tool to fetch current date/time if needed,
* Routes the conversation intelligently via LangGraph,
* Displays real-time, concise answers.

## ✨ Features

* 🌐 Real-time Web Search (DuckDuckGo)
* πŸ•“ Current Date & Time Tool
* 🧭 deepseek-r1-distill-llama-70b via Groq for planning and response generation
* 🧱 LangGraph Agent with tool invocation and conditional logic
* πŸ”„ Stateful and flexible architecture
* πŸ–₯️ Streamlit-based user interface
* ⚑ FastAPI backend

---

## 🧠 What is an AI Agent?

An **AI Agent** is a self-directed system that:

* Interprets complex input (e.g., human questions),
* Perceives its environment (e.g., user queries and tools),
* Decides what actions (e.g., tools to use) to take independently,
* Acts autonomously (e.g., fetches and processes information),
* And adapts based on feedback or reasoning loops.

LangGraph provides a framework to build these agents with dynamic, branching logic and persistent memory, surpassing traditional workflows. LangGraph agents go beyond static workflows by supporting conditional branching, autonomous tool use decisions, and persistent state handling.

## πŸ”„ LangGraph vs. LangChain: Why LangGraph?

| Feature             | LangGraph                                | LangChain (Core)                    |
| ------------------- | ---------------------------------------- | ----------------------------------- |
| Execution Model     | **Graph-based execution**                | Linear or chain-of-tools            |
| Tool Decision Logic | Built-in conditional routing (agents)    | Requires manual logic or chains     |
| State Persistence   | **Explicit state tracking**              | Implicit through variables          |
| Flexibility         | Better for **multi-step, dynamic logic** | Suitable for **simple tool chains** |

**LangGraph** is ideal when you need an agent that decides *when* to use a tool and *how* to proceed after tool outputβ€”like in this project.

## 🧠 Discover Agent vs. Discover (Workflow)

Here is a [link](https://github.com/harshith-77/discover) to the previous version "Discover" for your reference

| Feature             | Discover Agent (LangGraph)                | Discover Workflow (Earlier Version)    |
| ------------------- | ----------------------------------------- | -------------------------------------- |
| Tool Decision       | Dynamic & Conditional                     | Predefined Steps                       |
| Extensibility       | Easy to plug in new tools / logic         | Hardcoded path                         |
| Autonomy            | Agent decides next step                   | Linear, no adaptive logic              |
| Complexity Handling | Better for multi-turn or tool-heavy tasks | Suitable for simple single-step tasks  |
| Maintenance         | Modular and easier to extend              | Less flexible, more code change needed |

**Drawbacks of agent-based approach:**

* Slightly more overhead to set up initially
* Graph logic can be overkill for very simple tasks

---

## βš™οΈ Installation

### 1. Clone the repository

```bash

git clone https://github.com/harshith-77/discover-agent.git

cd discover-agent

```

### 2. Install dependencies

```bash

pip install -r requirements.txt

```

### 3. Set up environment variables

Create a `.env` file with:

```

GEMINI_API_KEY=your_google_genai_key

```

## ▢️ Run the App

### Start the FastAPI backend:

```bash

python main.py

```

### Launch the Streamlit UI:

```bash

streamlit run main_ui.py

```

## 🧰 Tech Stack

| Layer       | Technology                                 |
| ----------- |--------------------------------------------|
| LLM         | DeepSeek-R1 LLaMA 70B Distill via Groq API |
| Agent       | LangGraph                                  |
| Tool        | DuckDuckGoSearchRun, Custom Datetime Tool  |
| UI          | Streamlit                                  |
| Backend     | FastAPI + Uvicorn                          |
| Env Manager | python-dotenv                              |

---

## πŸ“ File Structure

```

β”œβ”€β”€ main.py           # FastAPI backend

β”œβ”€β”€ main_ui.py        # Streamlit UI

β”œβ”€β”€ helper.py         # Agent logic with LangGraph

β”œβ”€β”€ .env              # API keys (not checked into git)

β”œβ”€β”€ requirements.txt  # Python dependencies

```

## πŸ—£ Example Usage

1. Open the Streamlit app.
2. Type a query like:
   **"Who won the IPL 2025 final?"**
3. The agent provides a concise response to the query by fetching from web if needed.

---

## πŸ“œ License

MIT License