Skip to content

Commit dea23fb

Browse files
committed
ready-for-deployment-agent
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
1 parent 9199a45 commit dea23fb

File tree

15 files changed

+571
-143
lines changed

15 files changed

+571
-143
lines changed

README.md

Lines changed: 184 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,209 @@
1-
# CoAgents Starter
21

3-
This example contains a simple starter project.
2+
# Learn Coding with CopilotKit, CoAgents, and LangGraphs 🚀
43

5-
**These instructions assume you are in the `coagents-starter/` directory**
4+
[![CopilotKit](https://img.shields.io/badge/Powered%20By-CopilotKit-brightgreen)](https://github.com/copilotkit)
5+
[![Frontend: Next.js](https://img.shields.io/badge/Frontend-Next.js-orange)](https://nextjs.org/)
6+
[![Demo Video](https://img.shields.io/badge/Watch-Demo%20Video-red)](https://youtu.be/E1q67IDcdMU)
7+
[![Website](https://img.shields.io/badge/Website-Live-brightgreen)](https://learn-coding-with-copilotkit.vercel.app/)
68

7-
## Running the Agent
9+
---
810

9-
First, install the dependencies:
11+
## 📖 **About**
1012

11-
```sh
12-
cd agent
13-
poetry install
14-
```
13+
**Not everyone can code, but everyone can learn.**
1514

16-
Then, create a `.env` file inside `./agent` with the following:
15+
This project is an AI-powered **DSA/Competitive Programming Helper** with an inbuilt editor to help you:
16+
- Prepare for **coding interviews**
17+
- Start learning how to code from scratch
18+
- **Visualize everything** with intuitive representations
1719

18-
```
19-
GROQ_API_KEY=...
20-
```
20+
**Experience the future of coding education!**
2121

22-
IMPORTANT:
23-
Make sure the OpenAI API Key you provide, supports gpt-4o.
22+
🌐 Live Demo: [learn-coding-with-copilotkit.vercel.app](https://learn-coding-with-copilotkit.vercel.app/)
2423

25-
Then, run the demo:
24+
---
2625

27-
```sh
28-
poetry run demo
29-
```
26+
## 🌟 **Why CopilotKit?**
3027

31-
## Running the UI
28+
- **Seamless Integration**: Build AI copilots that enhance user experiences effortlessly.
29+
- **Open Source**: Join a thriving community of developers using and contributing to CopilotKit.
30+
- **Future-Ready**: Perfect for in-app AI agents, context-aware chatbots, shared state and beyond!
3231

33-
First, install the dependencies:
32+
Learn more about [CopilotKit](https://github.com/copilotkit).
3433

35-
```sh
36-
cd ./ui
37-
pnpm i
38-
```
34+
---
3935

40-
Then, create a `.env` file inside `./ui` with the following:
4136

42-
```
43-
GROQ_API_KEY=...
44-
```
37+
## 🛠️ **Project Description**
4538

46-
Then, run the Next.js project:
39+
Learn coding in a revolutionary way using **CopilotKit**, **CoAgents**, and **LangGraphs**! This project showcases how cutting-edge tools can simplify coding education through interactive UI and AI-driven technologies.
4740

48-
```sh
49-
pnpm run dev
50-
```
41+
### Key Features:
42+
- **🌐 CopilotKit**: Effortlessly integrate AI copilots into your apps, enabling in-app chatbots, context-aware interactions, and more.
43+
- **🤖 CoAgents**: A robust infrastructure for connecting LangGraph agents to humans in the loop, enabling seamless collaboration.
44+
- **📊 LangGraphs**: Visual representations of programming languages to simplify understanding of their structure and syntax.
45+
- **🖥️ Inbuilt Editor**: A powerful coding editor designed to boost productivity and learning.
5146

52-
## Usage
47+
---
5348

54-
Navigate to [http://localhost:3000](http://localhost:3000).
5549

56-
# LangGraph Studio
50+
## Screenshots
5751

58-
Run LangGraph studio, then load the `./agent` folder into it.
52+
<details>
53+
<summary>View Achieved Accuracy</summary>
54+
55+
<div align="center">
56+
<img src="screenshots/codechef-one.png" alt="Screenshot 1" width="800px"/>
57+
<img src="screenshots/codechef-one-diagram.png" alt="Screenshot 2" width="800px"/>
58+
<img src="screenshots/codechef-two.png" alt="Screenshot 3" width="800px"/>
59+
<img src="screenshots/codechef-two-diagram.png" alt="Screenshot 4" width="800px"/>
60+
</div>
5961

60-
Make sure to create teh `.env` mentioned above first!
62+
</details>
6163

62-
# Troubleshooting
6364

64-
A few things to try if you are running into trouble:
65+
## 🏗️ **Tech Stack**
66+
67+
### Frontend:
68+
- [Next.js](https://nextjs.org/)
69+
- [ShadCN UI](https://shadcn.dev/)
70+
- [Tailwind CSS](https://tailwindcss.com/)
71+
- [CopilotKit-UI](https://github.com/copilotkit)
72+
73+
### Backend:
74+
- [Python](https://www.python.org/)
75+
- [FastAPI](https://fastapi.tiangolo.com/)
76+
- [LangGraphs](https://langgraphs.example)
77+
- [CopilotKit](https://github.com/copilotkit)
78+
79+
### APIs:
80+
- [Groq](https://groq.com/)
81+
- [Llama-70B](https://example.com/)
82+
83+
---
84+
85+
## 📚 **Topics Covered**
86+
87+
- **TypeScript**
88+
- **Next.js**
89+
- **Competitive Programming**
90+
- **Tailwind CSS**
91+
- **Render Deployment**
92+
- **Koyeb API**
93+
- **ShadCN-UI**
94+
- **Llama-70B**
95+
- **Groq AI**
96+
- **CopilotKit**
97+
- **LangGraph (Python)**
98+
- **CoAgents**
99+
100+
---
101+
102+
## ⚙️ **Installation**
103+
104+
Clone the repository:
105+
106+
```bash
107+
git clone https://github.com/<your-repo-name>.git
108+
```
109+
110+
---
111+
112+
### 🧩 **Configuration**
113+
114+
1. Install the dependencies for the backend:
115+
116+
```bash
117+
cd agent
118+
poetry install
119+
```
120+
121+
2. Create a `.env` file in the `./agent` directory:
122+
123+
```plaintext
124+
GROQ_API_KEY=your_groq_api_key_here
125+
```
126+
127+
3. Run the demo:
128+
129+
```bash
130+
poetry run demo
131+
```
132+
133+
---
134+
135+
### 🖥️ **Running the UI**
136+
137+
1. Install the dependencies for the frontend:
138+
139+
```bash
140+
cd ./frontend-interface
141+
npm i --legacy-peer-deps
142+
```
143+
144+
2. Create a `.env` file in the `./frontend-interface` directory:
145+
146+
```plaintext
147+
GROQ_API_KEY=your_groq_api_key_here
148+
```
149+
150+
3. Run the Next.js project:
151+
152+
```bash
153+
npm run dev
154+
```
155+
156+
4. Navigate to [http://localhost:3000](http://localhost:3000).
157+
158+
---
159+
160+
### 🖥️ **Running the Backend**
161+
162+
1. Install the dependencies for the backend:
163+
164+
```bash
165+
cd ./backend
166+
pip install -r -requirements.txt
167+
```
168+
169+
2. Create a `.env` file in the `./frontend-interface` directory:
170+
171+
```plaintext
172+
GROQ_API_KEY=your_groq_api_key_here
173+
```
174+
175+
3. Run the FAST API server:
176+
177+
```bash
178+
python run_agent.py
179+
```
180+
181+
---
182+
183+
184+
## 🧑‍💻 **Usage**
185+
186+
1. **Launch LangGraph Studio**:
187+
Run LangGraph Studio and load the `./agent` folder into it.
188+
189+
2. **Ensure proper configuration**: Make sure the `.env` file is properly configured as mentioned in the setup steps.
190+
191+
---
192+
193+
## 🔧 **Troubleshooting**
194+
195+
If you encounter any issues, try the following:
196+
197+
1. Ensure no other application is running on port `8000`.
198+
2. In `/agent/dsa_agent/demo.py`, change `0.0.0.0` to `127.0.0.1` or `localhost`.
199+
200+
---
201+
202+
## 📜 **License**
203+
204+
This project is [UN Licensed](LICENSE).
205+
206+
---
207+
208+
Give CopilotKit a ⭐ on [GitHub](https://github.com/copilotkit) if you love it!
65209

66-
1. Make sure there is no other local application server running on the 8000 port.
67-
2. Under `/agent/my_agent/demo.py`, change `0.0.0.0` to `127.0.0.1` or to `localhost`
330 KB
Binary file not shown.
157 KB
Binary file not shown.
60 KB
Binary file not shown.
77 Bytes
Binary file not shown.

agent/dsa_agent/edges/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
def new_question(state):
99
question = state["question"]
10-
# last_message = messages[-1]
11-
1210
if (
1311
isinstance(question, SystemMessage)
1412
and "QUESTION UPDATED" in question.content
@@ -60,11 +58,10 @@ def decide_to_generate_visualisation(state):
6058
"""
6159

6260
print("---ASSESS MERMAID VISUALISATION CODE---")
63-
code = state["code"]
64-
visualization = state["visualization"]
61+
question = state["question"]
6562

6663
print("---GRADE CODE---")
67-
score = visualisation_verify.invoke({"code": code,"visualization": visualization})
64+
score = visualisation_verify.invoke({"question": question})
6865
grade = score.binary_score
6966

7067
if grade == "yes":

agent/dsa_agent/edges/visualisation_verify.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ class VerifyVisualisation(BaseModel):
99
"""Binary output to verify the mermaid code generated to visualise the python code."""
1010

1111
binary_score: str = Field(
12-
description="Python Code generated is correctly visualised by the mermaid code, 'yes' or 'no'"
12+
description="Mermaid Code generated is correct, 'yes' or 'no'"
1313
)
1414

1515
llm = ChatGroq(model="llama-3.3-70b-versatile", temperature=0)
1616
viusalisation_verification = llm.with_structured_output(VerifyVisualisation)
1717

18-
system = """You a 4000 rated Competitive Programmer that visualises an optimised and fully detailed working code in python \n
19-
Given a question and the generated code for it \n
20-
You have to provide the appropriate mermaid code to visualise the code approach generated \n
21-
Make sure that your output contains only mermaid code"""
18+
system = """You provide visualisation of a complex problem by generating corresponding mermaid code\n
19+
Given the question\n
20+
You have to provide the appropriate mermaid code to visualise the solution\n
21+
Make sure that your output contains only mermaid flowchart code in the format ```mermaid\nFLOWCHART...```\n"""
2222

2323
visualisation_prompt = ChatPromptTemplate.from_messages(
2424
[
2525
("system", system),
26-
("human", "Python Code Generated: \n\n {code} \n\n Visualised Code Generated in Mermaid: {visualization}"),
26+
("human", "question: \n\n {question}"),
2727
]
2828
)
2929

agent/dsa_agent/nodes/visualiser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
llm = ChatGroq(model="llama-3.3-70b-versatile", temperature=0)
1010

11-
system = """You a 4000 rated Competitive Programmer that writes optimised and fully detailed working code in python \n
12-
Given a question and the generated code for it \n
13-
You have to provide the appropriate mermaid code to visualise the code approach generated \n
14-
Make sure that your output contains only mermaid code"""
11+
system = """You provide visualisation of a complex problem by generating corresponding mermaid flowchart code\n
12+
Given the question\n
13+
You have to provide the appropriate mermaid flowchart code to visualise the solution\n
14+
Make sure that your output contains only mermaid flowchart code in the format ```mermaid\n{code}\n```\n"""
1515

1616
visualisation_prompt = ChatPromptTemplate.from_messages(
1717
[
1818
("system", system),
19-
("human", "code: \n\n {code} \n\n User question: {question}"),
19+
("human", "question: \n\n {question}"),
2020
]
2121
)
2222

agent/dsa_agent/state.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class AgentState(TypedDict):
1919
"""
2020

2121
question: str
22-
# testCases: Optional[List[str]] # type: ignore
23-
# messages: Annotated[Sequence[BaseMessage], add_messages]
22+
2423
code: Optional[str]
2524
explanation: Optional[str]
2625
time_complexity: Optional[str]
2726
space_complexity: Optional[str]
28-
visualization: Optional[str]
27+
visualization: Optional[str]
28+
# testCases: Optional[List[str]] # type: ignore
29+
# messages: Annotated[Sequence[BaseMessage], add_messages]

frontend-interface/README.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)