Skip to content

Commit cc89889

Browse files
authored
Merge pull request #107 from PytorchConnectomics/agent-integration
integrated agentic functionality to chatbot
2 parents 1574555 + c3f16d1 commit cc89889

10 files changed

Lines changed: 713 additions & 363 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ scripts/start.sh # macOS / Linux
2929
scripts\start.ps1 # Windows
3030
```
3131

32+
If restarting after a crash or interrupted session, kill any lingering processes first:
33+
34+
```
35+
lsof -ti:8000 | xargs kill -9 # macOS / Linux
36+
```
37+
3238
## Before pushing changes
3339

3440
Format most code with `prettier`:

client/package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/components/Chatbot.js

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,83 @@ function Chatbot({ onClose }) {
157157
<ReactMarkdown
158158
components={{
159159
ul: ({ children }) => (
160-
<ul style={{ paddingLeft: "20px" }}>{children}</ul>
160+
<ul style={{ paddingLeft: "20px", margin: "8px 0" }}>
161+
{children}
162+
</ul>
161163
),
162164
ol: ({ children }) => (
163-
<ol style={{ paddingLeft: "20px" }}>{children}</ol>
165+
<ol style={{ paddingLeft: "20px", margin: "8px 0" }}>
166+
{children}
167+
</ol>
164168
),
169+
table: ({ children }) => (
170+
<div style={{ overflowX: "auto", margin: "8px 0" }}>
171+
<table
172+
style={{
173+
borderCollapse: "collapse",
174+
width: "100%",
175+
fontSize: "13px",
176+
}}
177+
>
178+
{children}
179+
</table>
180+
</div>
181+
),
182+
thead: ({ children }) => (
183+
<thead style={{ backgroundColor: "#e8e8e8" }}>
184+
{children}
185+
</thead>
186+
),
187+
th: ({ children }) => (
188+
<th
189+
style={{
190+
border: "1px solid #ddd",
191+
padding: "6px 8px",
192+
textAlign: "left",
193+
fontWeight: 600,
194+
}}
195+
>
196+
{children}
197+
</th>
198+
),
199+
td: ({ children }) => (
200+
<td
201+
style={{
202+
border: "1px solid #ddd",
203+
padding: "6px 8px",
204+
}}
205+
>
206+
{children}
207+
</td>
208+
),
209+
code: ({ inline, children }) =>
210+
inline ? (
211+
<code
212+
style={{
213+
backgroundColor: "#e8e8e8",
214+
padding: "2px 4px",
215+
borderRadius: "3px",
216+
fontSize: "12px",
217+
}}
218+
>
219+
{children}
220+
</code>
221+
) : (
222+
<pre
223+
style={{
224+
backgroundColor: "#1e1e1e",
225+
color: "#d4d4d4",
226+
padding: "8px",
227+
borderRadius: "4px",
228+
overflowX: "auto",
229+
fontSize: "12px",
230+
margin: "8px 0",
231+
}}
232+
>
233+
<code>{children}</code>
234+
</pre>
235+
),
236+
pre: ({ children }) => <>{children}</>,
165237
}}
166238
>
167239
{message.text}

client/src/views/Views.js

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from "react";
1+
import React, { useState, useEffect, useRef, useCallback } from "react";
22
import { Layout, Menu, message, Button, Drawer } from "antd";
33
import {
44
FolderOpenOutlined,
@@ -32,6 +32,8 @@ function Views() {
3232
const [visitedTabs, setVisitedTabs] = useState(new Set(["files"]));
3333
const [workflowModalVisible, setWorkflowModalVisible] = useState(false);
3434
const [isChatOpen, setIsChatOpen] = useState(false);
35+
const [chatWidth, setChatWidth] = useState(380);
36+
const isResizing = useRef(false);
3537
const [apiReady, setApiReady] = useState(false);
3638
const [hasShownApiWarning, setHasShownApiWarning] = useState(false);
3739

@@ -243,6 +245,33 @@ function Views() {
243245
};
244246
}, [current]);
245247

248+
const startResizing = useCallback((e) => {
249+
isResizing.current = true;
250+
e.preventDefault();
251+
}, []);
252+
253+
const stopResizing = useCallback(() => {
254+
isResizing.current = false;
255+
}, []);
256+
257+
const resize = useCallback((e) => {
258+
if (isResizing.current) {
259+
const newWidth = window.innerWidth - e.clientX;
260+
if (newWidth >= 280 && newWidth <= 800) {
261+
setChatWidth(newWidth);
262+
}
263+
}
264+
}, []);
265+
266+
useEffect(() => {
267+
window.addEventListener("mousemove", resize);
268+
window.addEventListener("mouseup", stopResizing);
269+
return () => {
270+
window.removeEventListener("mousemove", resize);
271+
window.removeEventListener("mouseup", stopResizing);
272+
};
273+
}, [resize, stopResizing]);
274+
246275
const renderTabContent = (key, component) => {
247276
if (!visitedTabs.has(key)) return null;
248277
return (
@@ -320,12 +349,32 @@ function Views() {
320349
placement="right"
321350
open={isChatOpen}
322351
onClose={() => setIsChatOpen(false)}
323-
width={380}
352+
width={chatWidth}
324353
mask={false}
325354
closable={false}
326355
destroyOnClose
327356
styles={{ header: { display: "none" }, body: { padding: 0 } }}
328357
>
358+
<div
359+
onMouseDown={startResizing}
360+
style={{
361+
position: "absolute",
362+
left: 0,
363+
top: 0,
364+
bottom: 0,
365+
width: "4px",
366+
cursor: "ew-resize",
367+
backgroundColor: "transparent",
368+
zIndex: 10,
369+
}}
370+
onMouseEnter={(e) =>
371+
(e.currentTarget.style.backgroundColor = "#1890ff")
372+
}
373+
onMouseLeave={(e) =>
374+
!isResizing.current &&
375+
(e.currentTarget.style.backgroundColor = "transparent")
376+
}
377+
/>
329378
<Chatbot onClose={() => setIsChatOpen(false)} />
330379
</Drawer>
331380
</Layout>

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies = [
1010
"fastapi==0.119.0",
1111
"h5py>=3.11",
1212
"imageio==2.37.0",
13+
"langchain>=0.3.0",
1314
"langchain-classic==1.0.0",
1415
"langchain-community==0.4.1",
1516
"langchain-ollama==1.0.0",

scripts/start.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -euo pipefail
44

5+
# Prefer Homebrew's Node over nvm to avoid version conflicts
6+
export PATH="/opt/homebrew/bin:$PATH"
7+
export OLLAMA_BASE_URL="http://cscigpu08.bc.edu:11434"
8+
export OLLAMA_MODEL="gpt-oss:20b"
9+
export OLLAMA_EMBED_MODEL="mistral:latest"
10+
511
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
612
CLIENT_DIR="${ROOT_DIR}/client"
713

0 commit comments

Comments
 (0)